eblondel / ows4R

R Interface for OGC Web-Services (OWS)

Home Page:https://eblondel.github.io/ows4R/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate feature with findFeatureTypeByName

maelle opened this issue · comments

👋 here from EMODnetWFS 😸 cc @annakrystalli

I've just noticed that the exact parameter of

findFeatureTypeByName = function(expr, exact = TRUE){
isn't implemented yet?

Here's an example where I get both "biotic" and "abiotic" observations.

wfs <- ows4R::WFSClient$new(
    "http://geo.vliz.be/geoserver/Dataportal/wfs", 
    serviceVersion = "2.0.0"
)
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
capabilities <- wfs$getCapabilities()
capabilities$findFeatureTypeByName("biotic_observations")
#> [[1]]
#> <WFSFeatureType>
#>   Inherits from: <OGCAbstractObject>
#>   Public:
#>     attrs: list
#>     clone: function (deep = FALSE) 
#>     defaults: list
#>     description: NULL
#>     element: AbstractObject
#>     encode: function (addNS = TRUE, geometa_validate = TRUE, geometa_inspire = FALSE, 
#>     ERROR: function (text) 
#>     features: NULL
#>     getAbstract: function () 
#>     getBoundingBox: function () 
#>     getClass: function () 
#>     getClassName: function () 
#>     getDefaultCRS: function () 
#>     getDescription: function (pretty = FALSE) 
#>     getFeatures: function (..., outputFormat = NULL, paging = FALSE, paging_length = 1000, 
#>     getKeywords: function () 
#>     getName: function () 
#>     getNamespaceDefinition: function (recursive = FALSE) 
#>     getTitle: function () 
#>     INFO: function (text) 
#>     initialize: function (xmlObj, capabilities, version, logger = NULL) 
#>     isFieldInheritedFrom: function (field) 
#>     logger: function (type, text) 
#>     loggerType: NULL
#>     namespace: OWSNamespace, R6
#>     verbose.debug: FALSE
#>     verbose.info: FALSE
#>     WARN: function (text) 
#>     wrap: FALSE
#>   Private:
#>     abstract: 
#>     capabilities: WFSCapabilities, OWSCapabilities, OGCAbstractObject, R6
#>     defaultCRS: crs
#>     fetchFeatureType: function (xmlObj, version) 
#>     fromComplexTypes: function (value) 
#>     gmlIdAttributeName: gml_id
#>     keywords: NULL
#>     name: Dataportal:abiotic_observations
#>     system_fields: verbose.info verbose.debug loggerType wrap element names ...
#>     title: Dataportal - Abiotic observations
#>     url: http://geo.vliz.be/geoserver/Dataportal/wfs
#>     version: 2.0.0
#>     WGS84BoundingBox: 0 0 5.08056797730202 51.687394885
#>     xmlElement: AbstractObject
#>     xmlExtraNamespaces: NULL
#>     xmlNamespacePrefix: OWS
#>     xmlNodeToCharacter: function (x, ..., indent = "", tagSeparator = "\n") 
#> 
#> [[2]]
#> <WFSFeatureType>
#>   Inherits from: <OGCAbstractObject>
#>   Public:
#>     attrs: list
#>     clone: function (deep = FALSE) 
#>     defaults: list
#>     description: NULL
#>     element: AbstractObject
#>     encode: function (addNS = TRUE, geometa_validate = TRUE, geometa_inspire = FALSE, 
#>     ERROR: function (text) 
#>     features: NULL
#>     getAbstract: function () 
#>     getBoundingBox: function () 
#>     getClass: function () 
#>     getClassName: function () 
#>     getDefaultCRS: function () 
#>     getDescription: function (pretty = FALSE) 
#>     getFeatures: function (..., outputFormat = NULL, paging = FALSE, paging_length = 1000, 
#>     getKeywords: function () 
#>     getName: function () 
#>     getNamespaceDefinition: function (recursive = FALSE) 
#>     getTitle: function () 
#>     INFO: function (text) 
#>     initialize: function (xmlObj, capabilities, version, logger = NULL) 
#>     isFieldInheritedFrom: function (field) 
#>     logger: function (type, text) 
#>     loggerType: NULL
#>     namespace: OWSNamespace, R6
#>     verbose.debug: FALSE
#>     verbose.info: FALSE
#>     WARN: function (text) 
#>     wrap: FALSE
#>   Private:
#>     abstract: 
#>     capabilities: WFSCapabilities, OWSCapabilities, OGCAbstractObject, R6
#>     defaultCRS: crs
#>     fetchFeatureType: function (xmlObj, version) 
#>     fromComplexTypes: function (value) 
#>     gmlIdAttributeName: gml_id
#>     keywords: NULL
#>     name: Dataportal:biotic_observations
#>     system_fields: verbose.info verbose.debug loggerType wrap element names ...
#>     title: Dataportal - Biotic observations
#>     url: http://geo.vliz.be/geoserver/Dataportal/wfs
#>     version: 2.0.0
#>     WGS84BoundingBox: 2.913889 3.58333333333333 51.4583333333333 51.657788
#>     xmlElement: AbstractObject
#>     xmlExtraNamespaces: NULL
#>     xmlNamespacePrefix: OWS
#>     xmlNodeToCharacter: function (x, ..., indent = "", tagSeparator = "\n")

Created on 2022-03-02 by the reprex package (v2.0.1)

Hi @maelle I set it as bug since it's supposed to be implemented already, I think some regression ocurred in the past on that. Just pushed some fix. However, 'exact' really means exact for the feature type name. In the case of Geoserver, the name includes the namespace as prefix, if you don't put it you will get an empty list

Good to know!

Could ows4R automatically apply the namespacing or is that a bad idea?

wfs <- ows4R::WFSClient$new(
    url = "https://www.ifremer.fr/services/wfs/emodnet_chemistry2",
    serviceVersion = "2.0.0"
)
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
capabilities <- wfs$getCapabilities()
capabilities$findFeatureTypeByName("sl_fishing", exact = FALSE)
#> <WFSFeatureType>
#>   Inherits from: <OGCAbstractObject>
#>   Public:
#>     attrs: list
#>     clone: function (deep = FALSE) 
#>     defaults: list
#>     description: NULL
#>     element: AbstractObject
#>     encode: function (addNS = TRUE, geometa_validate = TRUE, geometa_inspire = FALSE, 
#>     ERROR: function (text) 
#>     features: NULL
#>     getAbstract: function () 
#>     getBoundingBox: function () 
#>     getClass: function () 
#>     getClassName: function () 
#>     getDefaultCRS: function () 
#>     getDescription: function (pretty = FALSE) 
#>     getFeatures: function (..., outputFormat = NULL, paging = FALSE, paging_length = 1000, 
#>     getKeywords: function () 
#>     getName: function () 
#>     getNamespaceDefinition: function (recursive = FALSE) 
#>     getTitle: function () 
#>     INFO: function (text) 
#>     initialize: function (xmlObj, capabilities, version, logger = NULL) 
#>     isFieldInheritedFrom: function (field) 
#>     logger: function (type, text) 
#>     loggerType: NULL
#>     namespace: OWSNamespace, R6
#>     verbose.debug: FALSE
#>     verbose.info: FALSE
#>     WARN: function (text) 
#>     wrap: FALSE
#>   Private:
#>     abstract: NULL
#>     capabilities: WFSCapabilities, OWSCapabilities, OGCAbstractObject, R6
#>     defaultCRS: crs
#>     fetchFeatureType: function (xmlObj, version) 
#>     fromComplexTypes: function (value) 
#>     gmlIdAttributeName: gml_id
#>     keywords: NULL
#>     name: ms:sl_fishing
#>     system_fields: verbose.info verbose.debug loggerType wrap element names ...
#>     title: Seabed litter - Fishing related items density (Nb. Items ...
#>     url: https://www.ifremer.fr/services/wfs/emodnet_chemistry2
#>     version: 2.0.0
#>     WGS84BoundingBox: -180 -90 180 90
#>     xmlElement: AbstractObject
#>     xmlExtraNamespaces: NULL
#>     xmlNamespacePrefix: OWS
#>     xmlNodeToCharacter: function (x, ..., indent = "", tagSeparator = "\n")
capabilities$findFeatureTypeByName("sl_fishing", exact = TRUE)
#> list()
capabilities$findFeatureTypeByName("ms:sl_fishing", exact = TRUE)
#> <WFSFeatureType>
#>   Inherits from: <OGCAbstractObject>
#>   Public:
#>     attrs: list
#>     clone: function (deep = FALSE) 
#>     defaults: list
#>     description: NULL
#>     element: AbstractObject
#>     encode: function (addNS = TRUE, geometa_validate = TRUE, geometa_inspire = FALSE, 
#>     ERROR: function (text) 
#>     features: NULL
#>     getAbstract: function () 
#>     getBoundingBox: function () 
#>     getClass: function () 
#>     getClassName: function () 
#>     getDefaultCRS: function () 
#>     getDescription: function (pretty = FALSE) 
#>     getFeatures: function (..., outputFormat = NULL, paging = FALSE, paging_length = 1000, 
#>     getKeywords: function () 
#>     getName: function () 
#>     getNamespaceDefinition: function (recursive = FALSE) 
#>     getTitle: function () 
#>     INFO: function (text) 
#>     initialize: function (xmlObj, capabilities, version, logger = NULL) 
#>     isFieldInheritedFrom: function (field) 
#>     logger: function (type, text) 
#>     loggerType: NULL
#>     namespace: OWSNamespace, R6
#>     verbose.debug: FALSE
#>     verbose.info: FALSE
#>     WARN: function (text) 
#>     wrap: FALSE
#>   Private:
#>     abstract: NULL
#>     capabilities: WFSCapabilities, OWSCapabilities, OGCAbstractObject, R6
#>     defaultCRS: crs
#>     fetchFeatureType: function (xmlObj, version) 
#>     fromComplexTypes: function (value) 
#>     gmlIdAttributeName: gml_id
#>     keywords: NULL
#>     name: ms:sl_fishing
#>     system_fields: verbose.info verbose.debug loggerType wrap element names ...
#>     title: Seabed litter - Fishing related items density (Nb. Items ...
#>     url: https://www.ifremer.fr/services/wfs/emodnet_chemistry2
#>     version: 2.0.0
#>     WGS84BoundingBox: -180 -90 180 90
#>     xmlElement: AbstractObject
#>     xmlExtraNamespaces: NULL
#>     xmlNamespacePrefix: OWS
#>     xmlNodeToCharacter: function (x, ..., indent = "", tagSeparator = "\n")

Created on 2022-03-03 by the reprex package (v2.0.1)

capabilities itself does not seem to have the namespace.

realizing this was a stupid question, we have the namespace elsewhere.

no, we can't add the logic of namespace here, it's not an OGC standard feature but specific feature to Geoserver, so you will have to implement it on the Emodnet Geoserver R package.