<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Calibri Light";
        panose-1:2 15 3 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB">Hi all,<br>
<br>
I am running into a problem with WFS 2.0 paged GetFeature request. The problem is that for a particular boundingbox a series of paged WFS 2.0 GetFeature requests fails to retrieve all the features. The geometry type of the layer is of `MULTILINESTRING`, the
 datasource is a GeoPackage file. Running on version 7.6.2. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">The problem is that the second paged response (<a href="https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=1000">https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=1000</a>
 ) is missing the next link. The missing next link does actually produces the expected features (<a href="https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=2000">https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=2000</a>
 ) and contains a next link itself. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">In the MapServer logs, when requesting the page with the missing next link, I see the following log output: `msOGRFileNextShape: Returning MS_DONE (no more shapes)`. This log output also shows when requesting the last
 page of results, of a paged WFS request. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">The interesting thing is that this behaviour does not occur when requesting a slightly bigger bbox:
<a href="https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6%2C452005.1%2C81976.8%2C453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding">
https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6%2C452005.1%2C81976.8%2C453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding</a>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">The SQL query used by Mapserver when requesting the page (<a href="https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=1000">https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&SERVICE=WFS&version=2.0.0&service=wfs&request=Getfeature&bbox=80034.6,452005.1,81976.8,453965.8&outputformat=gml3&srsname=EPSG%3A28992&typename=gwsw%3Abeheer_leiding&STARTINDEX=1000</a>
 ) with the missing next link is:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">```<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">SELECT "beheer_leiding"."uri" AS "uri", "beheer_leiding"."geometry" AS "geometry" FROM "beheer_leiding" JOIN "rtree_beheer_leiding_geometry" ms_spat_idx ON "beheer_leiding".ROWID = ms_spat_idx.id AND ms_spat_idx.minx
 <= 81976.8 AND ms_spat_idx.maxx >= 80034.6 AND ms_spat_idx.miny <= 453965.8 AND ms_spat_idx.maxy >= 452005.1  ORDER BY "beheer_leiding".ROWID LIMIT 1001 OFFSET 1000<br>
```<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">This query actually produces 1001 features as expected (other paged requests with more features to come have the same result). So not sure why MapServer decides there are no more results left. The MS_DONE value is returned
 from <a href="https://github.com/MapServer/MapServer/blob/dfdda8a18c69f22806c7d6e46bb2bf59f67ed941/mapogr.cpp#L2818">
here</a> (7.6.2 release) in the MapServer source code.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">The problem seems to be caused by an interaction between the data, the requested bbox  and a (by me) suspected bug in MapServer. In particul in the code that determines if there are any features left in the result set.
 Or maybe I am missing something obvious and there is a mistake in the mapfile causing the issue. Did anyone see this behaviour before? Btw when changing the datasource to a GeoJSON file this behaviour does not occur, but it does occur with a PostGIS datasource.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">I created a repo (<a href="https://github.com/arbakker/debug-ms-bbox-issue">https://github.com/arbakker/debug-ms-bbox-issue</a>) with a minimal example to reproduce the issue. The repo contains the mapfile, docker-compose,
 test script, data and a README describing steps in more detail to reproduce the issue.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="color:#201F1E;mso-fareast-language:NL"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:white"><b><span style="color:#00889E;mso-fareast-language:NL">Anton Bakker</span></b><b><span style="color:#201F1E;mso-fareast-language:NL"><o:p></o:p></span></b></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Calibri Light",sans-serif;color:black;mso-fareast-language:NL">Software Engineer<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="color:#201F1E;mso-fareast-language:NL"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black;mso-fareast-language:NL">IT
</span><span style="color:#00889E;mso-fareast-language:NL">| </span><span style="color:black;mso-fareast-language:NL">Geo- en Vastgoedinformatie en Advies
</span><span style="color:#00889E;mso-fareast-language:NL">|</span><span style="color:black;mso-fareast-language:NL">PDOK</span><span style="color:#201F1E;mso-fareast-language:NL"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black;mso-fareast-language:NL">06-29 73 73 51 </span><span style="color:#00889E;mso-fareast-language:NL">|</span><span style="color:black;mso-fareast-language:NL"> </span><span style="color:#0563C1;mso-fareast-language:NL"><a href="mailto:anton.bakker@kadaster.nl"><span style="color:blue">anton.bakker@kadaster.nl</span></a></span><span style="color:#201F1E;mso-fareast-language:NL"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;color:black;mso-fareast-language:NL"><o:p> </o:p></span></p>
<p class="MsoNormal"><a href="http://www.kadaster.nl/"><span style="font-size:12.0pt;color:black;mso-fareast-language:NL;text-decoration:none"><img border="0" width="124" height="117" style="width:1.2916in;height:1.2187in" id="Afbeelding_x0020_1" src="cid:image001.png@01D7473E.086BB5A0"></span></a><span style="font-size:12.0pt;color:black;mso-fareast-language:NL"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black;mso-fareast-language:NL"><img border="0" width="80" height="20" style="width:.8333in;height:.2083in" id="Afbeelding_x0020_2" src="cid:image002.png@01D7473E.086BB5A0"><span style="background:white"> </span></span><a href="http://www.linkedin.com/company/kadaster" title=""http://www.linkedin.com/company/kadaster" "><span style="font-size:12.0pt;color:blue;background:white;mso-fareast-language:NL;text-decoration:none"><img border="0" width="22" height="20" style="width:.2291in;height:.2083in" id="Afbeelding_x0020_3" src="cid:image003.png@01D7473E.086BB5A0"></span></a><a href="http://www.twitter.com/het_kadaster" title=""http://www.twitter.com/het_kadaster" "><span style="font-size:12.0pt;color:blue;background:white;mso-fareast-language:NL;text-decoration:none"><img border="0" width="22" height="20" style="width:.2291in;height:.2083in" id="Afbeelding_x0020_4" src="cid:image004.png@01D7473E.086BB5A0"></span></a><a href="http://www.facebook.com/HetKadaster/" title=""http://www.facebook.com/HetKadaster/" "><span style="font-size:12.0pt;color:blue;background:white;mso-fareast-language:NL;text-decoration:none"><img border="0" width="22" height="20" style="width:.2291in;height:.2083in" id="Afbeelding_x0020_5" src="cid:image005.png@01D7473E.086BB5A0"></span></a><a href="http://www.youtube.com/user/HetKadaster" title=""http://www.youtube.com/user/HetKadaster" "><span style="font-size:12.0pt;color:blue;background:white;mso-fareast-language:NL;text-decoration:none"><img border="0" width="22" height="20" style="width:.2291in;height:.2083in" id="Afbeelding_x0020_6" src="cid:image006.png@01D7473E.086BB5A0"></span></a><a href="http://www.instagram.com/kadaster.nl/" title=""http://www.instagram.com/kadaster.nl/" "><span style="font-size:12.0pt;color:blue;background:white;mso-fareast-language:NL;text-decoration:none"><img border="0" width="22" height="20" style="width:.2291in;height:.2083in" id="Afbeelding_x0020_7" src="cid:image007.png@01D7473E.086BB5A0"></span></a><span style="font-size:12.0pt;color:black;mso-fareast-language:NL"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<br>
<font size="2">Disclaimer:<br>
De inhoud van dit bericht is uitsluitend bestemd voor geadresseerde.<br>
Gebruik van de inhoud van dit bericht door anderen zonder toestemming van het Kadaster<br>
is onrechtmatig. Mocht dit bericht ten onrechte bij u terecht komen, dan verzoeken wij u<br>
dit direct te melden aan de verzender en het bericht te vernietigen.<br>
Aan de inhoud van dit bericht kunnen geen rechten worden ontleend.<br>
<br>
Disclaimer:<br>
The content of this message is meant to be received by the addressee only.<br>
Use of the content of this message by anyone other than the addressee without the consent<br>
of the Kadaster is unlawful. If you have received this message, but are not the addressee,<br>
please contact the sender immediately and destroy the message.<br>
No rights can be derived from the content of this message.<br>
</font>
</body>
</html>