[gdal-dev] Get WFS attributes form the gml namespace as OGR fields

Tamas Szekeres szekerest at gmail.com
Thu Oct 19 14:56:29 PDT 2017


It looks like DOWNLOAD_SCHEMA=NO would do the trick, but if I use this in a
VRT file this way it crashes GDAL.

<OGRVRTDataSource>
    <OGRVRTLayer name="OKCounties">
        <SrcDataSource>
http://cstest.coordinatesolutions.com/geoserver/wfs?VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=ogi:okcounties&SRSNAME=EPSG:900913
</SrcDataSource>
        <OpenOptions>
            <OOI key="DOWNLOAD_SCHEMA">NO</OOI>
        </OpenOptions>
        <LayerSRS>EPSG:900913</LayerSRS>
        <SrcSQL>SELECT *,
'BRUSH(fc:#00000000);PEN(c:#008000,w:3px);LABEL(f:"Arial",c:#008000,s:14px,t:{name})'
as OGR_STYLE from "okcounties"</SrcSQL>
    </OGRVRTLayer>
</OGRVRTDataSource>





2017-10-19 23:18 GMT+02:00 Even Rouault <even.rouault at spatialys.com>:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171019/36adad6e/attachment.html>


More information about the gdal-dev mailing list