[gdal-dev] WFS: How to use feature ordering?

Craig de Stigter craig.destigter at koordinates.com
Wed Nov 1 18:50:40 PDT 2023


Hey folks

We're having a lot of trouble getting data out of a WFS server that doesn't
have primary keys. (previous work on this)
<https://github.com/OSGeo/gdal/pull/8146>


The URL that's causing us grief is this one:
https://opendata.maps.vic.gov.au/geoserver/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=2.0.0&TYPENAMES=open-data-platform:v_s_parcel_proposed&STARTINDEX=0&COUNT=2

* we can't disable pagination, because the server only returns 5000 records
even if we ask for more.
* we can't paginate without ordering, because there's no PK.

So, adding a `&SORTBY=parcel_pfi` to the querystring fixes the issue. But I
can't seem to get GDAL to do that for us.

There does seem to be code for applying an "ORDER BY" clause from
ExecuteSQL to the WFS 1.1+ SORTBY field. However, I can't get it to work.

I made a test script
<https://gist.github.com/craigds/4fc8c0f61d02c0293b7c5005b8492744#file-wfs-order-by-test-py>
to demonstrate the problem. It uses ExecuteSQL to apply an ORDER BY clause,
but the resulting curl queries don't have a SORTBY parameter. Then it
crashes after the server returns a 400 error due to the missing SORTBY.

I assume there's something I need to do to cause GDAL to use the SORTBY
parameter but I'm not sure what it is. Any tips would be appreciated.

-- 
Regards,
Craig

Platform Engineer
Koordinates

+64 21 256 9488 <+64%2021%20256%209488> / koordinates.com / @koordinates
<https://twitter.com/koordinates>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20231102/2bd6590a/attachment.htm>


More information about the gdal-dev mailing list