-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,723 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r | ||
language: R | ||
sudo: required | ||
cache: packages | ||
|
||
services: | ||
- docker | ||
|
||
before_install: | ||
- docker pull kartoza/postgis | ||
- docker run -d --name="postgis" kartoza/postgis | ||
- docker pull oscarfonts/geoserver | ||
- docker run --link postgis:postgis -d -p 8080:8080 oscarfonts/geoserver | ||
|
||
r: | ||
- oldrel | ||
- release | ||
- devel | ||
|
||
r_binary_packages: | ||
- rgdal | ||
|
||
r_packages: | ||
- R6 | ||
- httr | ||
- XML | ||
- testthat | ||
- covr | ||
|
||
r_check_args: --as-cran | ||
|
||
after_script: | ||
- ./travis-tool.sh dump_logs | ||
|
||
after_success: | ||
- Rscript -e 'library(covr); codecov()' | ||
|
||
notifications: | ||
email: | ||
on_success: change | ||
on_failure: change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Version: 0.1 | |
Date: 2018-02-14 | ||
Title: interface to OGC Web-Services (OWS) | ||
Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "[email protected]"), | ||
person("Norbert", "Billet", role = c("ctb"), email = "[email protected]")) | ||
person("Norbert", "Billet", role = c("ctb"))) | ||
Maintainer: Emmanuel Blondel <[email protected]> | ||
Depends: R (>= 2.15) | ||
Imports: R6, httr, XML (>= 3.96-1.1), sp, rgdal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(OWSClient) | ||
export(OWSRequest) | ||
export(OWSServiceIdentification) | ||
export(OWSUtils) | ||
export(OWSUtilsInternal) | ||
export(WFSCapabilities) | ||
export(WFSClient) | ||
export(WFSDescribeFeatureType) | ||
export(WFSFeatureType) | ||
export(WFSFeatureTypeElement) | ||
export(WFSGetFeature) | ||
import(XML) | ||
import(httr) | ||
import(rgdal) | ||
import(sp) | ||
importFrom(R6,R6Class) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#' OWSClient | ||
#' | ||
#' @docType class | ||
#' @importFrom R6 R6Class | ||
#' @import httr | ||
#' @import XML | ||
#' @import sp | ||
#' @import rgdal | ||
#' @export | ||
#' @keywords OGC Common OWS | ||
#' @return Object of \code{\link{R6Class}} with methods for interfacing | ||
#' a Common OGC web-service. | ||
#' @format \code{\link{R6Class}} object. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' OWSClient$new("http://localhost:8080/geoserver/ows", version = "1.1.0") | ||
#' } | ||
#' | ||
#' @field loggerType the type of logger | ||
#' @field verbose.info if basic logs have to be printed | ||
#' @field verbose.debug if verbose logs have to be printed | ||
#' @field url the Base url of OWS service | ||
#' @field version the version of OWS service | ||
#' | ||
#' @section Methods: | ||
#' \describe{ | ||
#' \item{\code{new(url, version, user, pwd, logger)}}{ | ||
#' This method is used to instantiate a OWSClient with the \code{url} of the | ||
#' OGC service. Authentication (\code{user}/\code{pwd}) is not yet supported and will | ||
#' be added with the support of service transactional modes. By default, the \code{logger} | ||
#' argument will be set to \code{NULL} (no logger). This argument accepts two possible | ||
#' values: \code{INFO}: to print only \pkg{ows4R} logs, \code{DEBUG}: to print more verbose logs | ||
#' } | ||
#' \item{\code{logger(type, text)}}{ | ||
#' Basic logger to report logs. Used internally | ||
#' } | ||
#' \item{\code{INFO(text)}}{ | ||
#' Logger to report information. Used internally | ||
#' } | ||
#' \item{\code{WARN(text)}}{ | ||
#' Logger to report warnings. Used internally | ||
#' } | ||
#' \item{\code{ERROR(text)}}{ | ||
#' Logger to report errors. Used internally | ||
#' } | ||
#' \item{\code{getUrl()}}{ | ||
#' Get the service URL | ||
#' } | ||
#' \item{\code{getVersion()}}{ | ||
#' Get the service version | ||
#' } | ||
#' \item{\code{getCapabilities()}}{ | ||
#' Get the service capabilities | ||
#' } | ||
#' \item{\code{getClassName()}}{ | ||
#' Retrieves the name of the class instance | ||
#' } | ||
#' } | ||
#' | ||
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com> | ||
#' | ||
OWSClient <- R6Class("OWSClient", | ||
|
||
lock_objects = FALSE, | ||
|
||
#TODO for support of transactional operations | ||
#TODO provider specific formatter to prevent these fields to be printable | ||
private = list( | ||
user = NA, | ||
pwd = NA | ||
), | ||
|
||
public = list( | ||
#logger | ||
verbose.info = FALSE, | ||
verbose.debug = FALSE, | ||
loggerType = NULL, | ||
logger = function(type, text){ | ||
if(self$verbose.info){ | ||
cat(sprintf("[ows4R][%s] %s \n", type, text)) | ||
} | ||
}, | ||
INFO = function(text){self$logger("INFO", text)}, | ||
WARN = function(text){self$logger("WARN", text)}, | ||
ERROR = function(text){self$logger("ERROR", text)}, | ||
|
||
#fields | ||
url = NA, | ||
version = NA, | ||
capabilities = NA, | ||
|
||
#initialize | ||
initialize = function(url, version, user = NULL, pwd = NULL, logger = NULL) { | ||
|
||
#logger | ||
if(!missing(logger)){ | ||
if(!is.null(logger)){ | ||
self$loggerType <- toupper(logger) | ||
if(!(self$loggerType %in% c("INFO","DEBUG"))){ | ||
stop(sprintf("Unknown logger type '%s", logger)) | ||
} | ||
if(self$loggerType == "INFO"){ | ||
self$verbose.info = TRUE | ||
}else if(self$loggerType == "DEBUG"){ | ||
self$verbose.info = TRUE | ||
self$verbose.debug = TRUE | ||
} | ||
} | ||
} | ||
|
||
#fields | ||
if (!missing(url)) self$url <- url | ||
if (substring(self$url, nchar(self$url)) != "?"){ | ||
self$url <- paste(self$url, "?", sep = "") | ||
} | ||
if (!missing(version)) self$version <- version | ||
}, | ||
|
||
#getUrl | ||
getUrl = function(){ | ||
return(self$url) | ||
}, | ||
|
||
#getVersion | ||
getVersion = function(){ | ||
return(self$version) | ||
}, | ||
|
||
#getCapabilities | ||
getCapabilities = function() { | ||
return(self$capabilities) | ||
}, | ||
|
||
#getClassName | ||
getClassName = function(){ | ||
return(class(self)[1]) | ||
} | ||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#' @export | ||
OWSRequest <- R6Class("OWSRequest", | ||
#private methods | ||
private = list( | ||
#buildRequest | ||
buildRequest = function(baseUrl, namedParams, mimeType){ | ||
params <- paste(names(namedParams), namedParams, sep = "=", collapse = "&") | ||
request <- paste(baseUrl, "&", params, sep = "") | ||
message("Fetching ", request) | ||
r <- GET(request) | ||
responseContent <- NULL | ||
if(is.null(mimeType)){ | ||
responseContent <- content(r) | ||
}else{ | ||
if(regexpr("xml",mimeType)>0){ | ||
responseContent <- xmlParse(content(r, type = "text")) | ||
}else{ | ||
responseContent <- content(r, type = mimeType) | ||
} | ||
} | ||
response <- list(request = request, status = status_code(r), response = responseContent) | ||
return(response) | ||
} | ||
), | ||
#public methods | ||
public = list( | ||
request = NA, | ||
status = NA, | ||
response = NA, | ||
#initialize | ||
initialize = function(baseUrl, namedParams, mimeType = "text/xml") { | ||
req <- private$buildRequest(baseUrl, namedParams, mimeType) | ||
self$request <- req$request | ||
self$status <- req$status | ||
self$response <- req$response | ||
} | ||
), | ||
|
||
) |
Oops, something went wrong.