Skip to content

Commit

Permalink
WFS: supports PropertyIsNULL on GeoPackage (MapServer#6446)
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterVisscher committed Dec 17, 2021
1 parent bd4b7d7 commit 4d66157
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mapogcfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3280,7 +3280,7 @@ int FLTProcessPropertyIsNull(FilterEncodingNode *psFilterNode,

/* Horrible HACK to compensate for the lack of null testing in MapServer */
if( (lp->connectiontype == MS_POSTGIS ||
(lp->connectiontype == MS_OGR && msOGRIsSpatialite(lp))) &&
(lp->connectiontype == MS_OGR && msOGRSupportsIsNull(lp))) &&
strcmp(psFilterNode->pszValue, "PropertyIsNull") == 0 )
{
msFree(psFilterNode->pszValue);
Expand Down
4 changes: 2 additions & 2 deletions mapogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4227,11 +4227,11 @@ static int msOGRLayerIsOpen(layerObj *layer)
return MS_FALSE;
}

int msOGRIsSpatialite(layerObj* layer)
int msOGRSupportsIsNull(layerObj* layer)
{
msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
if (psInfo && psInfo->dialect &&
EQUAL(psInfo->dialect, "Spatialite") )
(EQUAL(psInfo->dialect, "Spatialite") || EQUAL(psInfo->dialect, "GPKG")))
{
// reasons to not produce native string: not simple layer, or an explicit deny
char *do_this = msLayerGetProcessingKey(layer, "NATIVE_SQL"); // default is YES
Expand Down
2 changes: 1 addition & 1 deletion mapserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ shapeObj *msOffsetCurve(shapeObj *p, double offset);
shapeObj *msGEOSOffsetCurve(shapeObj *p, double offset);
#endif

int msOGRIsSpatialite(layerObj* layer);
int msOGRSupportsIsNull(layerObj* layer);

#endif /* SWIG */

Expand Down
Binary file added msautotest/wxs/data/test_6446.gpkg
Binary file not shown.
35 changes: 35 additions & 0 deletions msautotest/wxs/expected/wfs_ogr_gpkg_propertyisnull.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" ?>
<wfs:FeatureCollection
xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
http://mapserver.gis.umn.edu/mapserver http://localhost/path/to/wfs_simple?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=test_6446&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>2.000000,49.000000 2.000000,49.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:test_6446 fid="test_6446.1">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>2.000000,49.000000 2.000000,49.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>2.000000,49.000000</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:id>1</ms:id>
<ms:name>some place in France</ms:name>
<ms:fieldisnull></ms:fieldisnull>
</ms:test_6446>
</gml:featureMember>
</wfs:FeatureCollection>

21 changes: 21 additions & 0 deletions msautotest/wxs/wfs_ogr_gpkg.map
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# Filter using intersect with point
# RUN_PARMS: wfs_ogr_gpkg_filter_intersects_point.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=test_6325&FILTER=<Filter><Intersects><PropertyName>msGeometry</PropertyName><gml:Point srsName=%22EPSG:4326%22><gml:coordinates>1.000000,0.000000</gml:coordinates></gml:Point></Intersects></Filter>" > [RESULT]
#
# PropertyIsNull
# RUN_PARMS: wfs_ogr_gpkg_propertyisnull.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=test_6446&FILTER=<Filter><PropertyIsNull><PropertyName>fieldisnull</PropertyName></PropertyIsNull></Filter>" > [RESULT]
#

MAP

Expand Down Expand Up @@ -107,4 +110,22 @@ LAYER
END
END # Layer

LAYER
NAME "test_6446"
CONNECTIONTYPE OGR
CONNECTION "./data/test_6446.gpkg"
METADATA
"ows_title" "test_6446"
"wfs_featureid" "id"
"gml_include_items" "all"
"gml_types" "auto"
"wfs_use_default_extent_for_getfeature" "no"
END
TYPE POINT
STATUS ON
PROJECTION
"init=epsg:4326"
END
END # Layer

END # Map File

0 comments on commit 4d66157

Please sign in to comment.