<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">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" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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 style="font-family:monospace"><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 style="font-family:monospace">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 style="font-family:monospace">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 style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Regards,</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Craig</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Platform Engineer<br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">Koordinates</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><a href="tel:+64%2021%20256%209488" style="color:rgb(17,85,204)" target="_blank">+64 21 256 9488</a> / <a href="http://koordinates.com/" style="color:rgb(17,85,204)" target="_blank">koordinates.com</a> / <a href="https://twitter.com/koordinates" style="color:rgb(17,85,204)" target="_blank">@koordinates</a></div></div></div></div></div>