<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Craig,</p>
<p>Both options you propose are reasonable. I'd perhaps have a
slight preference for option 2 (is my understanding correct that
the user would be responsible to issue GetFeatureCount() manually
before calling GetNextFeature() ? we don't want to systematically
call GetFeatureCount() because it could be potentially a rather
costly operation for some servers).</p>
<p>It could be enhanced with allowing a CHECK_WITH_HITS value for
OGR_WFS_PAGING_ALLOWED (or perhaps through a new specific open
option ?) that would automatically issue the feature count request
(that could be useful for ogr2ogr types of scenario where the user
can't easily cause ogr2ogr to issue GetFeatureCount())</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 03/05/2023 à 03:10, Craig de Stigter
a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CAF1M8pdXRmdPpgRSNZRd3m1FkHqV8CpP_fEvaTFFYO4MW+q-qw@mail.gmail.com">
<div dir="ltr">
<div>Hi folks</div>
<div><br>
</div>
<div>We're having trouble with OGR trying to fetch a response
from this WFS2 URL: <a
href="https://geo.irceline.be/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=realtime:pm25_24hmean_station&COUNT=1000000&STARTINDEX=0"
moz-do-not-send="true">https://geo.irceline.be/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=realtime:pm25_24hmean_station&COUNT=1000000&STARTINDEX=0</a></div>
<div><br>
</div>
<div>The error from the server is</div>
<div><br>
</div>
<blockquote class="gmail_quote">
<div>Cannot do natural order without a primary key, please add
it or specify a manual sort over existing attributes</div>
</blockquote>
<div><br>
</div>
<div>This seems fair enough on the surface - we specified <span><b>STARTINDEX=0</b></span>
but the server is unable to support paging for this dataset
due to no natural sort order.<br>
</div>
<div><br>
</div>
<div>We'd happily disable paging for this dataset - it has a
fairly low number of features - but we would prefer to
implement a general purpose solution rather than special-case
this particular dataset.</div>
<div><br>
</div>
<div>It would make sense to open the datasource, check the
feature count by doing a 'hits' query (we're doing this
anyway), and then use paging if there are more than 1000000
features - otherwise don't use paging.</div>
<div><br>
</div>
<div>However I can't find a way to accomplish this with GDAL.
The <b><span>OGR_WFS_PAGING_ALLOWED</span></b> config var is
only checked when the datasource is opened - so you can't open
the datasource, check the feature count and then change the
paging behaviour.</div>
<div><br>
</div>
<div>I can imagine either of these changes in GDAL itself might
fix this:</div>
<div><br>
</div>
<div>1. GDAL could check <b><span>OGR_WFS_PAGING_ALLOWED</span></b>
when actually first issuing GetFeature requests, rather than
during datasource creation</div>
<div>2. GDAL could omit the pagination parameters if the feature
count is already known and is less than the page size<br>
</div>
<div><br>
</div>
<div>How would you suggest we proceed?<br>
</div>
<div><br>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>Regards,</div>
<div>Craig</div>
<div><br>
</div>
<div>Platform Engineer<br>
</div>
<div>Koordinates</div>
<div><br>
</div>
<div><a href="tel:+64%2021%20256%209488" target="_blank"
moz-do-not-send="true">+64 21 256 9488</a> / <a
href="http://koordinates.com/" target="_blank"
moz-do-not-send="true">koordinates.com</a> / <a
href="https://twitter.com/koordinates" target="_blank"
moz-do-not-send="true">@koordinates</a></div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>