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

Even Rouault even.rouault at spatialys.com
Thu Nov 2 02:07:23 PDT 2023


Craig,

remove the leading end-of-line and spaces in your ExecuteSQL

l = ds.ExecuteSQL(
     """SELECT *
     FROM "open-data-platform:v_s_parcel_proposed"
     ORDER BY "parcel_pfi" ASC
     """
)

Also fixed perhttps://github.com/OSGeo/gdal/commit/f6c7d95e2c66ba1f62f6ff17e31af37f7f8f6bc8

Even

Le 02/11/2023 à 02:50, Craig de Stigter via gdal-dev a écrit :
> 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 
> <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 <tel:+64%2021%20256%209488> / koordinates.com 
> <http://koordinates.com/> / @koordinates <https://twitter.com/koordinates>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20231102/60917720/attachment.htm>


More information about the gdal-dev mailing list