Skip to content

Commit

Permalink
Merge branch 'branch-7-0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jul 30, 2016
2 parents adac43d + 375a7ae commit 701ea31
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mapogr.cpp
Expand Up @@ -1729,6 +1729,7 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
bIsOKForSQLCompose = (hFeature != NULL);
if( hFeature )
{
select = msStrdup(psInfo->pszLayerDef);
msFree(pszSpatialFilterTableName);
pszSpatialFilterTableName = msStrdup( OGR_F_GetFieldAsString( hFeature, 0 ) );
pszRowId = msStrdup( OGR_F_GetFieldAsString( hFeature, 1 ) );
Expand Down Expand Up @@ -1797,7 +1798,7 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
// side evaluation by unsetting it.
if( !bIsOKForSQLCompose && dialect != NULL && layer->filter.native_string )
{
msDebug("msOGRFileWhichShapes(): unsetting native_string\n");
msDebug("msOGRFileWhichShapes(): unsetting native_string. Falling back to MapServer only evaluation\n");
msFree( layer->filter.native_string );
layer->filter.native_string = NULL;
dialect = NULL;
Expand Down
38 changes: 38 additions & 0 deletions msautotest/wxs/expected/wfs_ogr_native_sql_34.xml
@@ -0,0 +1,38 @@
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=towns_select&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<!-- WARNING: FeatureId item 'ID' not found in typename 'towns_select'. -->
<gml:featureMember>
<ms:towns_select>
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:name>Fanano</ms:name>
<ms:peoples>2910</ms:peoples>
<ms:localcounc>1</ms:localcounc>
<ms:county>0</ms:county>
<ms:region>0</ms:region>
</ms:towns_select>
</gml:featureMember>
</wfs:FeatureCollection>

38 changes: 38 additions & 0 deletions msautotest/wxs/expected/wfs_ogr_native_sql_35.xml
@@ -0,0 +1,38 @@
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=myview_select&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<!-- WARNING: FeatureId item 'ID' not found in typename 'myview_select'. -->
<gml:featureMember>
<ms:myview_select>
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:name>Fanano</ms:name>
<ms:peoples>2910</ms:peoples>
<ms:localcounc>1</ms:localcounc>
<ms:county>0</ms:county>
<ms:region>0</ms:region>
</ms:myview_select>
</gml:featureMember>
</wfs:FeatureCollection>

38 changes: 38 additions & 0 deletions msautotest/wxs/expected/wfs_ogr_native_sql_36.xml
@@ -0,0 +1,38 @@
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=select_too_complex_for_optim&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<!-- WARNING: FeatureId item 'ID' not found in typename 'select_too_complex_for_optim'. -->
<gml:featureMember>
<ms:select_too_complex_for_optim>
<gml:boundedBy>
<gml:Box srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000 643513.360000,4896928.190000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:32632">
<gml:coordinates>643513.360000,4896928.190000</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:name>Fanano</ms:name>
<ms:peoples>2910</ms:peoples>
<ms:localcounc>1</ms:localcounc>
<ms:county>0</ms:county>
<ms:region>0</ms:region>
</ms:select_too_complex_for_optim>
</gml:featureMember>
</wfs:FeatureCollection>

76 changes: 76 additions & 0 deletions msautotest/wxs/wfs_ogr_native_sql.map
Expand Up @@ -64,6 +64,16 @@
#
# Same as wfs_ogr_native_sql_02 on a view
# RUN_PARMS: wfs_ogr_native_sql_33.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=myview&OUTPUTFORMAT=GML2&FILTER=<Filter><AND><BBOX><PropertyName>Geometry</PropertyName><Box srsName='EPSG:32632'><coordinates>643159,4877386 696879,4898059</coordinates></Box></BBOX><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>Fanano</Literal></PropertyIsEqualTo></AND></Filter>" > [RESULT]
#
# Same as wfs_ogr_native_sql_02 on a "SELECT ... FROM " a table
# RUN_PARMS: wfs_ogr_native_sql_34.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=towns_select&OUTPUTFORMAT=GML2&FILTER=<Filter><AND><BBOX><PropertyName>Geometry</PropertyName><Box srsName='EPSG:32632'><coordinates>643159,4877386 696879,4898059</coordinates></Box></BBOX><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>Fanano</Literal></PropertyIsEqualTo></AND></Filter>" > [RESULT]
#
# Same as wfs_ogr_native_sql_02 on a "SELECT ... FROM " a_view
# RUN_PARMS: wfs_ogr_native_sql_35.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=myview_select&OUTPUTFORMAT=GML2&FILTER=<Filter><AND><BBOX><PropertyName>Geometry</PropertyName><Box srsName='EPSG:32632'><coordinates>643159,4877386 696879,4898059</coordinates></Box></BBOX><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>Fanano</Literal></PropertyIsEqualTo></AND></Filter>" > [RESULT]
#
# Same as wfs_ogr_native_sql_02 on a SELECT too complex to be edited, so falling back to client side evaluation
# RUN_PARMS: wfs_ogr_native_sql_36.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=select_too_complex_for_optim&OUTPUTFORMAT=GML2&FILTER=<Filter><AND><BBOX><PropertyName>Geometry</PropertyName><Box srsName='EPSG:32632'><coordinates>643159,4877386 696879,4898059</coordinates></Box></BBOX><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>Fanano</Literal></PropertyIsEqualTo></AND></Filter>" > [RESULT]
#

MAP

Expand Down Expand Up @@ -121,6 +131,28 @@ LAYER
TEMPLATE "wfs_ogr_native_sql.map"
END # Layer

LAYER
NAME towns_select
DATA "SELECT * FROM towns"
CONNECTIONTYPE OGR
CONNECTION "./data/db.sqlite"
PROCESSING "NATIVE_SQL=YES"
METADATA
"ows_title" "towns_select"
"wfs_featureid" "ID"
"gml_include_items" "all"
"gml_types" "auto"
"wfs_getfeature_formatlist" "ogrgml"
END
TYPE POINT
STATUS ON
PROJECTION
"init=epsg:32632"
END

TEMPLATE "wfs_ogr_native_sql.map"
END # Layer

LAYER
NAME myview
DATA myview
Expand All @@ -143,4 +175,48 @@ LAYER
TEMPLATE "wfs_ogr_native_sql.map"
END # Layer

LAYER
NAME myview_select
DATA "SELECT * FROM myview"
CONNECTIONTYPE OGR
CONNECTION "./data/db.sqlite"
PROCESSING "NATIVE_SQL=YES"
METADATA
"ows_title" "myview_select"
"wfs_featureid" "ID"
"gml_include_items" "all"
"gml_types" "auto"
"wfs_getfeature_formatlist" "ogrgml"
END
TYPE POINT
STATUS ON
PROJECTION
"init=epsg:32632"
END

TEMPLATE "wfs_ogr_native_sql.map"
END # Layer

LAYER
NAME select_too_complex_for_optim
DATA "SELECT * FROM towns WHERE 1"
CONNECTIONTYPE OGR
CONNECTION "./data/db.sqlite"
PROCESSING "NATIVE_SQL=YES"
METADATA
"ows_title" "select_too_complex_for_optim"
"wfs_featureid" "ID"
"gml_include_items" "all"
"gml_types" "auto"
"wfs_getfeature_formatlist" "ogrgml"
END
TYPE POINT
STATUS ON
PROJECTION
"init=epsg:32632"
END

TEMPLATE "wfs_ogr_native_sql.map"
END # Layer

END # Map File

0 comments on commit 701ea31

Please sign in to comment.