Skip to content

Commit

Permalink
WFS: fix paging with GPKG/Spatialite datasources and non-point geomet…
Browse files Browse the repository at this point in the history
…ries (fixes #6325)
  • Loading branch information
rouault authored and github-actions[bot] committed May 12, 2021
1 parent 91b01e2 commit ce8dc4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 20 additions & 4 deletions mapogr.cpp
Expand Up @@ -2368,16 +2368,32 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
msFree(points);
filter = msStringConcatenate(filter, "))");
}
else if( psInfo->dialect && EQUAL(psInfo->dialect, "Spatialite") &&
psInfo->pszMainTableName != NULL && !psInfo->bHasSpatialIndex )
else if( psInfo->dialect &&
(EQUAL(psInfo->dialect, "Spatialite") ||
EQUAL(psInfo->dialect, "GPKG")) &&
psInfo->pszMainTableName != NULL )
{
const bool isGPKG = EQUAL(psInfo->dialect, "GPKG");
if (filter) filter = msStringConcatenate(filter, " AND");
const char *col = OGR_L_GetGeometryColumn(psInfo->hLayer); // which geom field??
filter = msStringConcatenate(filter, " MbrIntersects(\"");
filter = msStringConcatenate(filter, " Intersects(");
if( isGPKG )
{
// Casting GeoPackage geometries to spatialie ones is done
// automatically normally, since GDAL enables the
// "amphibious" mode, but without it
// explicilty specified, spatialite 4.3.0a does an
// out-of-bounds access.
filter = msStringConcatenate(filter, "GeomFromGPB(");
}
filter = msStringConcatenate(filter, "\"");
char* escaped = msLayerEscapePropertyName(layer, col);
filter = msStringConcatenate(filter, escaped);
msFree(escaped);
filter = msStringConcatenate(filter, "\", BuildMbr(");
filter = msStringConcatenate(filter, "\"");
if( isGPKG )
filter = msStringConcatenate(filter, ")");
filter = msStringConcatenate(filter, ", BuildMbr(");
char *points = (char *)msSmallMalloc(30*2*5);
snprintf(points, 30*4, "%lf,%lf,%lf,%lf", rect.minx, rect.miny, rect.maxx, rect.maxy);
filter = msStringConcatenate(filter, points);
Expand Down
3 changes: 2 additions & 1 deletion msautotest/wxs/expected/wfs_ogr_gpkg_issue_6325.xml
Expand Up @@ -7,7 +7,8 @@ Content-Type: text/xml; subtype="gml/3.2.1"; charset=UTF-8
xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://localhost/path/to/wfs_simple?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAME=test_6325&OUTPUTFORMAT=application%2Fgml%2Bxml%3B%20version%3D3.2 http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd"
timeStamp="" numberMatched="unknown" numberReturned="1">
timeStamp="" numberMatched="unknown" numberReturned="1"
next="http://localhost/path/to/wfs_simple?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=test_6325&BBOX=0.75%2C0.75%2C9%2C9&COUNT=1&STARTINDEX=1">
<wfs:boundedBy>
<gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326">
<gml:lowerCorner>0.00000 0.00000</gml:lowerCorner>
Expand Down

0 comments on commit ce8dc4d

Please sign in to comment.