[gdal-dev] Get WFS attributes form the gml namespace as OGR fields
Even Rouault
even.rouault at spatialys.com
Thu Oct 19 14:18:23 PDT 2017
On jeudi 19 octobre 2017 22:55:50 CEST Tamas Szekeres wrote:
> Hi all,
>
> It looks like whenever we have a dataset (shapefile,db table,etc...) which
> has a
> column with such names like "description", "name", "location" GeoServer
> maps it to the elements in the gml namespace (in a 1.1 request),
> therefore DescribeFeatureType doesn't contain these attributes.
>
> For example this response doesn't include the name attribute
>
> http://cstest.coordinatesolutions.com/geoserver/wfs?VERSION=1.1.0&SERVICE=WF
> S&REQUEST=DescribeFeatureType&TYPENAME=ogi:okcounties
>
> However that attribute is returned in the GetFeature request in the
> gml:name section, like:
>
> http://cstest.coordinatesolutions.com/geoserver/wfs?VERSION=1.1.0&REQUEST=Ge
> tFeature&TYPENAME=ogi:okcounties
>
> But as the result of this behaviour the WFS driver doesn't include this
> item in the layer definition. Is that possible to retrieve these attributes
> from the WFS driver as OGR fields for example to use them in SQL
> expressions?
Hi Tamas,
If your need is to filter on the server, then you'll need to compose the full
URL at hand.
If you want to post-filter, you can downloader the GetFeature request and open
the GML file with the DOWNLOAD_SCHEMA=NO open option (or
GML_DOWNLOAD_WFS_SCHEMA=NO configuration option)
This will prevent the GML driver from trying to use the schema, and then it
will discover the gml:name element.
OGRFeature(okcounties):155
gml_id (String) = okcounties.155
name (String) = BEAVER
state (Integer) = 40
county (Integer) = 7
stateplane (String) = N
MULTIPOLYGON (((-100.945566 ....)))
The XSD parser used by the WFS and GML drivers could also possibly be modified
to hard-code the definition of those few GML fields (although they might
depend on the GML version).
Otherwise you can also use the GMLAS driver, but the result will be a bit
inconvenient to use as it will create a dedicated layer for the name attribute
(as gml:name can be repeated):
$ ogrinfo GMLAS:out.xml
INFO: Open of `GMLAS:out.xml'
using driver `GMLAS' successful.
1: okcounties (Multi Surface)
2: okcounties_metadataproperty (None)
3: okcounties_name (None)
4: location (None)
OGRFeature(okcounties):1
ogr_pkid (String) = 213FC01A8AA5FA1E1ADC65B21904DA34_okcounties_1
id (String) = okcounties.155
state (Integer64) = 40
county (Integer64) = 7
stateplane (String) = N
MULTIPOLYGON (((-100.945566....)))
OGRFeature(okcounties_name):1
ogr_pkid (String) = 213FC01A8AA5FA1E1ADC65B21904DA34_okcounties_1_name_1
parent_ogr_pkid (String) = 213FC01A8AA5FA1E1ADC65B21904DA34_okcounties_1
value (String) = BEAVER
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list