Skip to content
Permalink
Browse files
mapmssql2008.c: honour "wfs_use_default_extent_for_getfeature" "false…
…" LAYER.METADATA (fixes #5994)
  • Loading branch information
rouault committed Feb 24, 2020
1 parent 6df2d2f commit f9ca113daa12763acc6477ee71e32b5b2d2c5d2c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
@@ -1331,6 +1331,8 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)

char *pos_from, *pos_ftab, *pos_space, *pos_paren;
int hasFilter = MS_FALSE;
const rectObj rectInvalid = MS_INIT_INVALID_RECT;
const int bIsValidRect = memcmp(&rect, &rectInvalid, sizeof(rect)) != 0;

layerinfo = getMSSQL2008LayerInfo(layer);

@@ -1519,16 +1521,18 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
hasFilter = MS_TRUE;
}

/* adding spatial filter */
if (hasFilter == MS_FALSE)
query = msStringConcatenate(query, " WHERE ");
else
query = msStringConcatenate(query, " AND ");
if( bIsValidRect ) {
/* adding spatial filter */
if (hasFilter == MS_FALSE)
query = msStringConcatenate(query, " WHERE ");
else
query = msStringConcatenate(query, " AND ");

query = msStringConcatenate(query, layerinfo->geom_column);
query = msStringConcatenate(query, ".STIntersects(");
query = msStringConcatenate(query, box3d);
query = msStringConcatenate(query, ") = 1 ");
query = msStringConcatenate(query, layerinfo->geom_column);
query = msStringConcatenate(query, ".STIntersects(");
query = msStringConcatenate(query, box3d);
query = msStringConcatenate(query, ") = 1 ");
}

if (paging_query) {
paging_query = msStringConcatenate(paging_query, query);
@@ -2515,6 +2519,8 @@ int msMSSQL2008LayerGetShapeCount(layerObj *layer, rectObj rect, projectionObj *
SQLLEN retLen;
SQLRETURN rc;
int hasFilter = MS_FALSE;
const rectObj rectInvalid = MS_INIT_INVALID_RECT;
const int bIsValidRect = memcmp(&rect, &rectInvalid, sizeof(rect)) != 0;

rectObj searchrectInLayerProj = rect;

@@ -2590,16 +2596,22 @@ int msMSSQL2008LayerGetShapeCount(layerObj *layer, rectObj rect, projectionObj *
hasFilter = MS_TRUE;
}

/* adding spatial filter */
if (hasFilter == MS_FALSE)
query = msStringConcatenate(query, " WHERE ");
else
query = msStringConcatenate(query, " AND ");
if( bIsValidRect ) {
/* adding spatial filter */
if (hasFilter == MS_FALSE)
query = msStringConcatenate(query, " WHERE ");
else
query = msStringConcatenate(query, " AND ");

query = msStringConcatenate(query, layerinfo->geom_column);
query = msStringConcatenate(query, ".MakeValid().STIntersects(");
query = msStringConcatenate(query, box3d);
query = msStringConcatenate(query, ") = 1 ");
query = msStringConcatenate(query, layerinfo->geom_column);
query = msStringConcatenate(query, ".STIntersects(");
query = msStringConcatenate(query, box3d);
query = msStringConcatenate(query, ") = 1 ");
}

if (layer->debug) {
msDebug("query:%s\n", query);
}

if (!executeSQL(layerinfo->conn, query)) {
msFree(query);
@@ -750,7 +750,8 @@ int FLTLayerApplyPlainFilterToLayer(FilterEncodingNode *psNode, mapObj *map,
pszUseDefaultExtent = msOWSLookupMetadata(&(lp->metadata), "F",
"use_default_extent_for_getfeature");
if( pszUseDefaultExtent && !CSLTestBoolean(pszUseDefaultExtent) &&
lp->connectiontype == MS_OGR )
(lp->connectiontype == MS_OGR ||
((lp->connectiontype == MS_PLUGIN) && (strstr(lp->plugin_library,"msplugin_mssql2008") != NULL))) )
{
const rectObj rectInvalid = MS_INIT_INVALID_RECT;
rect = rectInvalid;
@@ -44,6 +44,7 @@ MAP
METADATA
"gml_include_items" "all"
"gml_types" "auto"
"wfs_use_default_extent_for_getfeature" "false"
END
END

0 comments on commit f9ca113

Please sign in to comment.