diff --git a/.travis.yml b/.travis.yml index d16fa41..b578515 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_install: - docker run -d --name="postgis" kartoza/postgis - docker pull oscarfonts/geoserver - docker run --link postgis:postgis --name geoserver -d -p 8080:8080 oscarfonts/geoserver - - docker run --name geonetwork -d -p 8282:8282 pobsteta/docker-geonetwork:3.0.5 + - docker run --name geonetwork -d -p 8282:8080 pobsteta/docker-geonetwork:3.0.5 r: - oldrel diff --git a/DESCRIPTION b/DESCRIPTION index aedd4d2..3e6877c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ows4R Version: 0.1 -Date: 2018-02-14 +Date: 2018-02-16 Title: interface to OGC Web-Services (OWS) Authors@R: c(person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com"), person("Norbert", "Billet", role = c("ctb"))) diff --git a/NAMESPACE b/NAMESPACE index 20d4cae..aacdb45 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,7 +2,10 @@ export(CSWCapabilities) export(CSWClient) +export(OWSCapabilities) export(OWSClient) +export(OWSOperation) +export(OWSOperationsMetadata) export(OWSRequest) export(OWSServiceIdentification) export(OWSUtils) diff --git a/R/CSWCapabilities.R b/R/CSWCapabilities.R new file mode 100644 index 0000000..1570168 --- /dev/null +++ b/R/CSWCapabilities.R @@ -0,0 +1,38 @@ +#' CSWCapabilities +#' +#' @docType class +#' @export +#' @keywords OGC CSW Capabilities +#' @return Object of \code{\link{R6Class}} with methods for interfacing an OGC +#' Catalogue Service for the Web (CSW) Get Capabilities document. +#' @format \code{\link{R6Class}} object. +#' +#' @examples +#' \dontrun{ +#' CSWCapabilities$new("http://localhost:8080/geonetwork/csw", version = "2.0.2") +#' } +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(url, version)}}{ +#' This method is used to instantiate a WFSGetCapabilities object +#' } +#' } +#' +#' @author Emmanuel Blondel +#' +CSWCapabilities <- R6Class("CSWCapabilities", + inherit = OWSCapabilities, + private = list( + + ), + + public = list( + + #initialize + initialize = function(url, version) { + super$initialize(url, service = "CSW", version) + xmlObj <- self$getRequest()$response + } + ) +) \ No newline at end of file diff --git a/R/CSWGetCapabilities.R b/R/CSWGetCapabilities.R deleted file mode 100644 index 8e2b082..0000000 --- a/R/CSWGetCapabilities.R +++ /dev/null @@ -1,58 +0,0 @@ -#' CSWGetCapabilities -#' -#' @docType class -#' @export -#' @keywords OGC CSW GetCapabilities -#' @return Object of \code{\link{R6Class}} with methods for interfacing an OGC -#' Catalogue Service for the Web (CSW) Get Capabilities document. -#' @format \code{\link{R6Class}} object. -#' -#' @examples -#' \dontrun{ -#' CSWGetCapabilities$new("http://localhost:8080/geonetwork/csw", version = "2.0.2") -#' } -#' -#' @section Methods: -#' \describe{ -#' \item{\code{new(url, version)}}{ -#' This method is used to instantiate a WFSGetCapabilities object -#' } -#' \item{\code{getServiceIdentification()}}{ -#' Get the service identification -#' } -#' } -#' -#' @author Emmanuel Blondel -#' -CSWCapabilities <- R6Class("CSWCapabilities", - - private = list( - - url = NA, - version = NA, - request = NA, - serviceIdentification = NA, - - #buildRequest - buildRequest = function(url, version){ - namedParams <- list(request = "GetCapabilities", version = version) - request <- OWSRequest$new(url, namedParams, "text/xml") - return(request) - } - ), - - public = list( - - #initialize - initialize = function(url, version) { - private$request <- private$buildRequest(url, version) - xmlObj <- private$request$response - private$serviceIdentification <- OWSServiceIdentification$new(xmlObj, version, "CSW") - }, - - #getServiceIdentification - getServiceIdentification = function(){ - return(private$serviceIdentification) - } - ) -) \ No newline at end of file diff --git a/R/OWSCapabilities.R b/R/OWSCapabilities.R new file mode 100644 index 0000000..50b32e5 --- /dev/null +++ b/R/OWSCapabilities.R @@ -0,0 +1,92 @@ +#' OWSGetCapabilities +#' +#' @docType class +#' @export +#' @keywords OGC OWS GetCapabilities +#' @return Object of \code{\link{R6Class}} with methods for interfacing an abstract +#' OWS Get Capabilities document. +#' @format \code{\link{R6Class}} object. +#' +#' @examples +#' \dontrun{ +#' OWSCapabilities$new("http://localhost:8080/geoserver/wfs", service = "wfs" version = "1.1.0") +#' } +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(url, service, version)}}{ +#' This method is used to instantiate a OWSGetCapabilities object +#' } +#' \item{\code{getUrl()}}{ +#' Get URL +#' } +#' \item{\code{getVersion()}}{ +#' Get version +#' } +#' \item{\code{getRequest()}}{ +#' Get request +#' } +#' \item{\code{getServiceIdentification()}}{ +#' Get the service identification +#' } +#' \item{\code{getOperationsMetadata()}}{ +#' Get the service operations metadata +#' } +#' } +#' +#' @author Emmanuel Blondel +#' +OWSCapabilities <- R6Class("OWSCapabilities", + + private = list( + + url = NA, + version = NA, + request = NA, + serviceIdentification = NULL, + operationsMetadata = NULL, + + #buildRequest + buildRequest = function(url, service, version){ + namedParams <- list(request = "GetCapabilities", service, version = version) + request <- OWSRequest$new(url, namedParams, "text/xml") + return(request) + } + ), + + public = list( + + #initialize + initialize = function(url, service, version) { + private$request <- private$buildRequest(url, service, version) + xmlObj <- private$request$response + private$serviceIdentification <- OWSServiceIdentification$new(xmlObj, service, version) + private$operationsMetadata <- OWSOperationsMetadata$new(xmlObj, service, version) + }, + + #getUrl + getUrl = function(){ + return(private$url) + }, + + #getVersion + getVersion = function(){ + return(private$version) + }, + + #getRequest + getRequest = function(){ + return(private$request) + }, + + #getServiceIdentification + getServiceIdentification = function(){ + return(private$serviceIdentification) + }, + + #getOperationsMetadata + getOperationsMetadata = function(){ + return(private$operationsMetadata) + } + ) +) \ No newline at end of file diff --git a/R/OWSOperation.R b/R/OWSOperation.R new file mode 100644 index 0000000..2be7bb3 --- /dev/null +++ b/R/OWSOperation.R @@ -0,0 +1,44 @@ +#' OWSOperation +#' +#' @docType class +#' @export +#' @keywords OGC OWS operation +#' @return Object of \code{\link{R6Class}} for modelling an OGC Operation +#' @format \code{\link{R6Class}} object. +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xmlObj, service, version)}}{ +#' This method is used to instantiate an OWSOperation object +#' } +#' } +#' +#' @author Emmanuel Blondel +#' +OWSOperation <- R6Class("OWSOperation", + private = list( + name = NA, + parameters = list() + ), + public = list( + initialize = function(xmlObj, service, version){ + private$name <- xmlGetAttr(xmlObj, "name") + paramXML <- getNodeSet(xmlDoc(xmlObj), "//ns:Parameter", ns) + private$parameters <- lapply(paramXML, function(x){ + param <- xpathSApply(x, "//ns:Value", fun = xmlValue, namespaces = ns) + return(param) + }) + names(private$parameters) <- sapply(paramXML, xmlGetAttr, "name") + }, + + #getName + getName = function(){ + return(private$name) + }, + + #getParameters + getParameters = function(){ + return(private$parameters) + } + ) +) \ No newline at end of file diff --git a/R/OWSOperationsMetadata.R b/R/OWSOperationsMetadata.R new file mode 100644 index 0000000..32da8a3 --- /dev/null +++ b/R/OWSOperationsMetadata.R @@ -0,0 +1,68 @@ +#' OWSOperationsMetadata +#' +#' @docType class +#' @export +#' @keywords OGC OWS operation metadata +#' @return Object of \code{\link{R6Class}} for modelling an OGC Operations Metadata +#' @format \code{\link{R6Class}} object. +#' +#' @section Methods: +#' \describe{ +#' \item{\code{new(xmlObj, service, version)}}{ +#' This method is used to instantiate a OWSOperationsMetadata object +#' } +#' \item{\code{getOperations()}}{ +#' Get operations +#' } +#' } +#' +#' @author Emmanuel Blondel +#' +OWSOperationsMetadata <- R6Class("OWSOperationsMetadata", + private = list( + operations = list(), + + #fetchOperations + fetchOperations = function(xmlObj, service, version){ + namespaces <- NULL + if(all(class(xmlObj) == c("XMLInternalDocument","XMLAbstractDocument"))){ + namespaces <- OWSUtils$getNamespaces(xmlObj) + } + namespaces <- as.data.frame(namespaces) + namespace <- tolower(service) + + opXML <- NULL + if(nrow(namespaces) > 0){ + ns <- OWSUtils$findNamespace(namespaces, namespace) + if(length(ns)>0){ + opXML <- getNodeSet(xmlObj, "//ns:OperationsMetadata/ns:Operation", ns) + } + if(length(opXML)==0){ + ns <- OWSUtils$findNamespace(namespaces, "ows") + if(length(ns)>0){ + opXML <- getNodeSet(xmlObj, "//ns:OperationsMetadata/ns:Operation", ns) + } + } + }else{ + opXML <- getNodeSet(xmlObj, "//OperationsMetadata/Operation") + } + + operations <- list() + if(length(opXML)>0){ + operations <- lapply(opXML, function(x){return(OWSOperation$new(x, service, version))}) + } + return(operations) + + } + ), + public = list( + initialize = function(xmlObj, service, version){ + private$operations <- private$fetchOperations(xmlObj, service, version) + }, + + #getOperations + getOperations = function(){ + return(private$operations) + } + ) +) \ No newline at end of file diff --git a/R/OWSServiceIdentification.R b/R/OWSServiceIdentification.R index dedaf40..f2e32e6 100644 --- a/R/OWSServiceIdentification.R +++ b/R/OWSServiceIdentification.R @@ -49,28 +49,27 @@ OWSServiceIdentification <- R6Class("OWSServiceIdentification", accessConstraints = NA, #fetchServiceIdentification - fetchServiceIdentification = function(xmlObj, version, service){ + fetchServiceIdentification = function(xmlObj, service, version){ namespaces <- NULL if(all(class(xmlObj) == c("XMLInternalDocument","XMLAbstractDocument"))){ namespaces <- OWSUtils$getNamespaces(xmlObj) } namespaces <- as.data.frame(namespaces) - namespace <- tolower(service) serviceXML <- NULL if(nrow(namespaces) > 0){ ns <- OWSUtils$findNamespace(namespaces, namespace) - if(!is.null(ns)){ + if(length(ns)>0){ serviceXML <- getNodeSet(xmlObj, "//ns:Service", ns) if(length(serviceXML)==0) serviceXML <- getNodeSet(xmlObj, "//ns:ServiceIdentification", ns) - if(length(serviceXML)==0){ - ns <- OWSUtils$findNamespace(namespaces, "ows") - if(!is.null(ns)){ - serviceXML <- getNodeSet(xmlObj, "//ns:Service", ns) - if(length(serviceXML)==0) serviceXML <- getNodeSet(xmlObj, "//ns:ServiceIdentification", ns) - } + } + if(length(serviceXML)==0){ + ns <- OWSUtils$findNamespace(namespaces, "ows") + if(length(ns)>0){ + serviceXML <- getNodeSet(xmlObj, "//ns:Service", ns) + if(length(serviceXML)==0) serviceXML <- getNodeSet(xmlObj, "//ns:ServiceIdentification", ns) } } }else{ @@ -104,7 +103,7 @@ OWSServiceIdentification <- R6Class("OWSServiceIdentification", } if(!is.null(children$Keywords)){ - if(version == "1.0.0"){ + if(is.character(children$Keywords)){ serviceKeywords <- strsplit(gsub(" ", "", xmlValue(children$Keywords)), ",")[[1]] }else{ serviceKeywordListXML <- xmlChildren(children$Keywords) @@ -146,8 +145,8 @@ OWSServiceIdentification <- R6Class("OWSServiceIdentification", } ), public = list( - initialize = function(xmlObj, version, namespace){ - serviceIdentification <- private$fetchServiceIdentification(xmlObj, version, namespace) + initialize = function(xmlObj, service, version){ + serviceIdentification <- private$fetchServiceIdentification(xmlObj, service, version) private$name <- serviceIdentification$name private$title <- serviceIdentification$title private$abstract <- serviceIdentification$abstract @@ -192,12 +191,12 @@ OWSServiceIdentification <- R6Class("OWSServiceIdentification", #getServiceTypeVersion getServiceTypeVersion = function(){ return(private$serviceTypeVersion) - } + }, #getFees getFees = function(){ return(private$fees) - } + }, #getAccessConstraints getAccessConstraints = function(){ diff --git a/R/WFSCapabilities.R b/R/WFSCapabilities.R index 91335d1..3b67b9d 100644 --- a/R/WFSCapabilities.R +++ b/R/WFSCapabilities.R @@ -1,4 +1,4 @@ -#' WFSGetCapabilities +#' WFSCapabilities #' #' @docType class #' @export @@ -9,7 +9,7 @@ #' #' @examples #' \dontrun{ -#' WFSGetCapabilities$new("http://localhost:8080/geoserver/wfs", version = "1.1.1") +#' WFSCapabilities$new("http://localhost:8080/geoserver/wfs", version = "1.1.1") #' } #' #' @section Methods: @@ -17,9 +17,6 @@ #' \item{\code{new(url, version)}}{ #' This method is used to instantiate a WFSGetCapabilities object #' } -#' \item{\code{getServiceIdentification()}}{ -#' Get the service identification -#' } #' \item{\code{getFeatureTypes()}}{ #' Retrieves the list of feature types #' } @@ -31,22 +28,11 @@ #' @author Emmanuel Blondel #' WFSCapabilities <- R6Class("WFSCapabilities", - + inherit = OWSCapabilities, private = list( - url = NA, - version = NA, - request = NA, - serviceIdentification = NA, featureTypes = NA, - - #buildRequest - buildRequest = function(url, version){ - namedParams <- list(request = "GetCapabilities", version = version) - request <- OWSRequest$new(url, namedParams, "text/xml") - return(request) - }, - + #fetchFeatureTypes fetchFeatureTypes = function(xmlObj, url, version){ @@ -57,7 +43,6 @@ WFSCapabilities <- R6Class("WFSCapabilities", } featureTypesXML <- getNodeSet(xmlObj, "//ns:FeatureType", wfsNs) - featureTypesList <- lapply(featureTypesXML, function(x){ WFSFeatureType$new(x, url, version) @@ -73,17 +58,11 @@ WFSCapabilities <- R6Class("WFSCapabilities", #initialize initialize = function(url, version) { - private$request <- private$buildRequest(url, version) - xmlObj <- private$request$response - private$serviceIdentification <- OWSServiceIdentification$new(xmlObj, version, "WFS") + super$initialize(url, service = "WFS", version) + xmlObj <- self$getRequest()$response private$featureTypes = private$fetchFeatureTypes(xmlObj, url, version) }, - #getServiceIdentification - getServiceIdentification = function(){ - return(private$serviceIdentification) - }, - #getFeatureTypes getFeatureTypes = function(){ return(private$featureTypes) diff --git a/R/ows4R.R b/R/ows4R.R index 2a7c7be..6ff26a9 100644 --- a/R/ows4R.R +++ b/R/ows4R.R @@ -15,7 +15,7 @@ #' Type: \tab Package\cr #' Version #' : \tab 0.1\cr -#' Date: \tab 2018-02-14\cr +#' Date: \tab 2018-02-16\cr #' License: \tab MIT\cr #' LazyLoad: \tab yes\cr #' } diff --git a/man/CSWCapabilities.Rd b/man/CSWCapabilities.Rd index fc15d81..8e3ba6d 100644 --- a/man/CSWCapabilities.Rd +++ b/man/CSWCapabilities.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/CSWGetCapabilities.R +% Please edit documentation in R/CSWCapabilities.R \docType{class} \name{CSWCapabilities} \alias{CSWCapabilities} -\title{CSWGetCapabilities} +\title{CSWCapabilities} \format{\code{\link{R6Class}} object.} \usage{ CSWCapabilities @@ -13,7 +13,7 @@ Object of \code{\link{R6Class}} with methods for interfacing an OGC Catalogue Service for the Web (CSW) Get Capabilities document. } \description{ -CSWGetCapabilities +CSWCapabilities } \section{Methods}{ @@ -21,15 +21,12 @@ CSWGetCapabilities \item{\code{new(url, version)}}{ This method is used to instantiate a WFSGetCapabilities object } - \item{\code{getServiceIdentification()}}{ - Get the service identification - } } } \examples{ \dontrun{ - CSWGetCapabilities$new("http://localhost:8080/geonetwork/csw", version = "2.0.2") + CSWCapabilities$new("http://localhost:8080/geonetwork/csw", version = "2.0.2") } } @@ -37,5 +34,5 @@ CSWGetCapabilities Emmanuel Blondel } \keyword{CSW} -\keyword{GetCapabilities} +\keyword{Capabilities} \keyword{OGC} diff --git a/man/CSWClient.Rd b/man/CSWClient.Rd index 9ca2cb2..2fa4eb3 100644 --- a/man/CSWClient.Rd +++ b/man/CSWClient.Rd @@ -25,6 +25,9 @@ CSWClient 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{getCapabilities()}}{ + Get service capabilities. Inherited from OWS Client + } } } diff --git a/man/OWSCapabilities.Rd b/man/OWSCapabilities.Rd new file mode 100644 index 0000000..c5adf28 --- /dev/null +++ b/man/OWSCapabilities.Rd @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/OWSCapabilities.R +\docType{class} +\name{OWSCapabilities} +\alias{OWSCapabilities} +\title{OWSGetCapabilities} +\format{\code{\link{R6Class}} object.} +\usage{ +OWSCapabilities +} +\value{ +Object of \code{\link{R6Class}} with methods for interfacing an abstract +OWS Get Capabilities document. +} +\description{ +OWSGetCapabilities +} +\section{Methods}{ + +\describe{ + \item{\code{new(url, service, version)}}{ + This method is used to instantiate a OWSGetCapabilities object + } + \item{\code{getUrl()}}{ + Get URL + } + \item{\code{getVersion()}}{ + Get version + } + \item{\code{getRequest()}}{ + Get request + } + \item{\code{getServiceIdentification()}}{ + Get the service identification + } + \item{\code{getOperationsMetadata()}}{ + Get the service operations metadata + } +} +} + +\examples{ +\dontrun{ + OWSCapabilities$new("http://localhost:8080/geoserver/wfs", service = "wfs" version = "1.1.0") +} + +} +\author{ +Emmanuel Blondel +} +\keyword{GetCapabilities} +\keyword{OGC} +\keyword{OWS} diff --git a/man/OWSOperation.Rd b/man/OWSOperation.Rd new file mode 100644 index 0000000..2afb042 --- /dev/null +++ b/man/OWSOperation.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/OWSOperation.R +\docType{class} +\name{OWSOperation} +\alias{OWSOperation} +\title{OWSOperation} +\format{\code{\link{R6Class}} object.} +\usage{ +OWSOperation +} +\value{ +Object of \code{\link{R6Class}} for modelling an OGC Operation +} +\description{ +OWSOperation +} +\section{Methods}{ + +\describe{ + \item{\code{new(xmlObj, service, version)}}{ + This method is used to instantiate an OWSOperation object + } +} +} + +\author{ +Emmanuel Blondel +} +\keyword{OGC} +\keyword{OWS} +\keyword{operation} diff --git a/man/OWSOperationsMetadata.Rd b/man/OWSOperationsMetadata.Rd new file mode 100644 index 0000000..7ae8e63 --- /dev/null +++ b/man/OWSOperationsMetadata.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/OWSOperationsMetadata.R +\docType{class} +\name{OWSOperationsMetadata} +\alias{OWSOperationsMetadata} +\title{OWSOperationsMetadata} +\format{\code{\link{R6Class}} object.} +\usage{ +OWSOperationsMetadata +} +\value{ +Object of \code{\link{R6Class}} for modelling an OGC Operations Metadata +} +\description{ +OWSOperationsMetadata +} +\section{Methods}{ + +\describe{ + \item{\code{new(xmlObj, service, version)}}{ + This method is used to instantiate a OWSOperationsMetadata object + } + \item{\code{getOperations()}}{ + Get operations + } +} +} + +\author{ +Emmanuel Blondel +} +\keyword{OGC} +\keyword{OWS} +\keyword{metadata} +\keyword{operation} diff --git a/man/WFSCapabilities.Rd b/man/WFSCapabilities.Rd index 9bd880e..099e963 100644 --- a/man/WFSCapabilities.Rd +++ b/man/WFSCapabilities.Rd @@ -3,7 +3,7 @@ \docType{class} \name{WFSCapabilities} \alias{WFSCapabilities} -\title{WFSGetCapabilities} +\title{WFSCapabilities} \format{\code{\link{R6Class}} object.} \usage{ WFSCapabilities @@ -13,7 +13,7 @@ Object of \code{\link{R6Class}} with methods for interfacing an OGC Web Feature Service Get Capabilities document. } \description{ -WFSGetCapabilities +WFSCapabilities } \section{Methods}{ @@ -21,9 +21,6 @@ WFSGetCapabilities \item{\code{new(url, version)}}{ This method is used to instantiate a WFSGetCapabilities object } - \item{\code{getServiceIdentification()}}{ - Get the service identification - } \item{\code{getFeatureTypes()}}{ Retrieves the list of feature types } @@ -35,7 +32,7 @@ WFSGetCapabilities \examples{ \dontrun{ - WFSGetCapabilities$new("http://localhost:8080/geoserver/wfs", version = "1.1.1") + WFSCapabilities$new("http://localhost:8080/geoserver/wfs", version = "1.1.1") } } diff --git a/man/WFSClient.Rd b/man/WFSClient.Rd index c6f5848..7805170 100644 --- a/man/WFSClient.Rd +++ b/man/WFSClient.Rd @@ -25,6 +25,9 @@ WFSClient 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{getCapabilities()}}{ + Get service capabilities. Inherited from OWS Client + } \item{\code{describeFeatureType(typeName)}}{ Get the description of a given featureType } diff --git a/man/ows4R.Rd b/man/ows4R.Rd index 0b97d1c..7a4b0f8 100644 --- a/man/ows4R.Rd +++ b/man/ows4R.Rd @@ -17,7 +17,7 @@ service specifications such as Web Map Service (WMS), Web Coverage Service, or C Type: \tab Package\cr Version : \tab 0.1\cr - Date: \tab 2018-02-14\cr + Date: \tab 2018-02-16\cr License: \tab MIT\cr LazyLoad: \tab yes\cr }