[gdal-dev] WFS driver bug2 - MAXFEATURES not working
Odd Ragnar Lydersen
Odd-Ragnar.Lydersen at powel.no
Thu Sep 29 04:18:54 PDT 2016
So it seems I have to do a bit more testing then.
Perhaps it's the server I'm accessing which is buggy then.
I'll have a go with the testserver you're using, and compare.
Thanks for the answer.
>Odd-Ragnar<
-----Opprinnelig melding-----
Fra: Even Rouault [mailto:even.rouault at spatialys.com]
Sendt: torsdag 29. september 2016 11.20
Til: gdal-dev at lists.osgeo.org
Kopi: Odd Ragnar Lydersen <Odd-Ragnar.Lydersen at powel.no>
Emne: Re: [gdal-dev] WFS driver bug2 - MAXFEATURES not working
Le jeudi 29 septembre 2016 10:06:12, Odd Ragnar Lydersen a écrit :
> So I have tried to dig a bit more into this, and I have noticed a few
> things.
>
>
> 1) I set MAXFEATURES=60 in the url
>
> 2) I select the layer I want to work with, let's call it MyLayer.
>
> 3) I call SetSpatialFilterRect() on the MyLayer and set it to a small
> area containing 11 points.
>
> 4) I call GetFeatureCount() on MyLayer, and then I get 60 features
> returned, even though I know it should be spatially bound to an area
> containing only 11 features.
>
> 5) Then I should be iterating through all the features, using
> GetNextFeature(), but no features are read.
>
> In 4), the result from GetFeatureCount(), should have been 11.
> In 5), I should have been able to read the expected 11 features.
>
The WFS driver has quite a bunch of optimizations (and workarounds for buggy implementations), which are as many doors for more or less subtle bugs, but in my below testing, that seems to work :
$ python
>>> from osgeo import ogr
>>> ds =
>>> ogr.Open('WFS:http://demo.mapserver.org/cgi-bin/wfs?VERSION=1.0.0&MA
>>> XFEATURES=1') lyr = ds.GetLayerByName('continents')
>>> lyr.SetSpatialFilterRect(0,45,15,50)
>>> print(lyr.GetFeatureCount())
1
>>> f = lyr.GetNextFeature()
>>> print(f['NA2DESC'])
'Italy'
>>> f = lyr.GetNextFeature()
>>> print(f)
None
or from the command line :
$ ogrinfo -ro "WFS:http://demo.mapserver.org/cgi-bin/wfs?VERSION=1.0.0&MAXFEATURES=1" continents -al -spat 0 45 15 50
INFO: Open of `WFS:http://demo.mapserver.org/cgi-bin/wfs?VERSION=1.0.0&MAXFEATURES=1'
using driver `WFS' successful.
Metadata:
ABSTRACT=This demonstration server showcases MapServer (www.mapserver.org) and its OGC support
TITLE=WMS Demo Server for MapServer
Layer name: continents
Metadata:
TITLE=World continents
Geometry: Unknown (any)
Feature Count: 1
Extent: (13.427750, 45.697224) - (13.439472, 45.711639) Layer SRS WKT:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
Geometry Column = msGeometry
gml_id: String (0.0) NOT NULL
NA2DESC: String (0.0)
NA3DESC: String (0.0)
OGRFeature(continents):22518
gml_id (String) = continents.22518
NA2DESC (String) = Italy
NA3DESC (String) = Europe
POLYGON ((13.437944 45.708195,13.438861 45.706806,13.439472 45.705387,13.438694 45.702862,13.436277 45.700832,13.432834 45.697224,13.431194 45.697472,13.430611
45.699085,13.432083 45.702999,13.432167 45.704613,13.430305 45.707443,13.42775 45.709583,13.4285 45.711639,13.43275 45.710167,13.437944 45.708195))
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list