2

I am writing a Python script to fetch data from GeoServer WFS 2.0.0. To avoid downloading too large an amount of data I am using pagination with count and startIndex. The problem I am facing is how to know the amount of data in feature layer. In the JSON sent by the server a field called totalFeatures is included but this figure change in the last page.

Is there any way to get the number of features in advance?

resultType=hits& does not work in version 2.0.0

1 Answer 1

1

It works for me -

if I ask for resulttype=hits:

http://localhost:8080/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&typenames=sf:bugsites&filter=%3Cfes:Filter%20xmlns:fes=%22http://www.opengis.net/fes/2.0%22%3E%3Cfes:ResourceId%20rid=%22bugsites.3%22/%3E%3C/fes:Filter%3E&RESULTTYPE=hits

I get the following response:

<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" next="http://localhost:8080/geoserver/wfs?FILTER=%3Cfes%3AFilter%20xmlns%3Afes%3D%22http%3A%2F%2Fwww.opengis.net%2Ffes%2F2.0%22%3E%3Cfes%3AResourceId%20rid%3D%22bugsites.3%22%2F%3E%3C%2Ffes%3AFilter%3E&amp;REQUEST=GetFeature&amp;RESULTTYPE=results&amp;VERSION=2.0.0&amp;TYPENAMES=sf%3Abugsites&amp;SERVICE=WFS&amp;STARTINDEX=0" numberMatched="1" numberReturned="0" timeStamp="2019-07-17T16:26:26.106Z" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd"/>

which has the attribute numberMatched="1" as expected.

Update

Though oddly I get exactly the same result with &outputFormat=application%2Fjson which is odd and possibly a bug, but I would need to read the WFS spec more closely to be sure.

Further Update

Seems I've seen this before 3 years ago but no one cares enough to fix it or fund a fix.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.