[mapserver-commits] r9887 - branches/branch-5-6/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Feb 23 14:30:58 EST 2010
Author: assefa
Date: 2010-02-23 14:30:57 -0500 (Tue, 23 Feb 2010)
New Revision: 9887
Modified:
branches/branch-5-6/mapserver/HISTORY.TXT
branches/branch-5-6/mapserver/mapdraw.c
branches/branch-5-6/mapserver/mapfile.c
branches/branch-5-6/mapserver/mapgml.c
branches/branch-5-6/mapserver/mapogcfilter.c
branches/branch-5-6/mapserver/mapows.h
branches/branch-5-6/mapserver/mappostgis.c
branches/branch-5-6/mapserver/mapquery.c
branches/branch-5-6/mapserver/mapserver.h
branches/branch-5-6/mapserver/mapwfs.c
Log:
issues with one pass query and flters #3305 #3346
Modified: branches/branch-5-6/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-6/mapserver/HISTORY.TXT 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/HISTORY.TXT 2010-02-23 19:30:57 UTC (rev 9887)
@@ -27,7 +27,14 @@
- Got rid of invalid warning about missing EPSG proj in WMs GetCapabilities
when map has a valid EPSG proj, but layer doesn't (#2028)
+Current Version
+---------------
+- Correct one pass query problems and OGC filter query (#3305)
+
+- Correct QueryByOperator (#3346)
+
+
Version 5.6.1 (2010-01-08):
---------------------------
Modified: branches/branch-5-6/mapserver/mapdraw.c
===================================================================
--- branches/branch-5-6/mapserver/mapdraw.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapdraw.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -1212,7 +1212,10 @@
msInitShape(&shape);
for(i=0; i<layer->resultcache->numresults; i++) {
- status = msLayerResultsGetShape(layer, &shape, layer->resultcache->results[i].tileindex, layer->resultcache->results[i].shapeindex);
+ if(layer->resultcache->usegetshape)
+ status = msLayerGetShape(layer, &shape, layer->resultcache->results[i].tileindex, layer->resultcache->results[i].shapeindex);
+ else
+ status = msLayerResultsGetShape(layer, &shape, layer->resultcache->results[i].tileindex, layer->resultcache->results[i].shapeindex);
if(status != MS_SUCCESS) {
msFree(colorbuffer);
msFree(mindistancebuffer);
Modified: branches/branch-5-6/mapserver/mapfile.c
===================================================================
--- branches/branch-5-6/mapserver/mapfile.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapfile.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -5616,3 +5616,14 @@
}
}
+void initResultCache(resultCacheObj *resultcache)
+{
+ if (resultcache)
+ {
+ resultcache->results = NULL;
+ resultcache->numresults = 0;
+ resultcache->cachesize = 0;
+ resultcache->bounds.minx = resultcache->bounds.miny = resultcache->bounds.maxx = resultcache->bounds.maxy = -1;
+ resultcache->usegetshape = MS_FALSE;
+ }
+}
Modified: branches/branch-5-6/mapserver/mapgml.c
===================================================================
--- branches/branch-5-6/mapserver/mapgml.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapgml.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -1413,8 +1413,11 @@
** msGMLWriteWFSQuery()
**
** Similar to msGMLWriteQuery() but tuned for use with WFS 1.0.0
+** bUseGetShape is used when the query passed through a commplex filter
+** encoding #3305
*/
-int msGMLWriteWFSQuery(mapObj *map, FILE *stream, int maxfeatures, char *default_namespace_prefix, int outputformat)
+int msGMLWriteWFSQuery(mapObj *map, FILE *stream, int maxfeatures, char *default_namespace_prefix,
+ int outputformat, int bUseGetShape)
{
#ifdef USE_WFS_SVR
int status;
@@ -1510,7 +1513,11 @@
}
for(j=0; j<lp->resultcache->numresults; j++) {
- status = msLayerResultsGetShape(lp, &shape, lp->resultcache->results[j].tileindex, lp->resultcache->results[j].shapeindex);
+ if (bUseGetShape)
+ status = msLayerGetShape(lp, &shape, lp->resultcache->results[j].tileindex, lp->resultcache->results[j].shapeindex);
+ else
+ status = msLayerResultsGetShape(lp, &shape, lp->resultcache->results[j].tileindex, lp->resultcache->results[j].shapeindex);
+
if(status != MS_SUCCESS)
return(status);
Modified: branches/branch-5-6/mapserver/mapogcfilter.c
===================================================================
--- branches/branch-5-6/mapserver/mapogcfilter.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapogcfilter.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -633,14 +633,11 @@
}
psLayer->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj));
+ initResultCache(psLayer->resultcache);
- psLayer->resultcache->results = NULL;
- psLayer->resultcache->numresults = 0;
- psLayer->resultcache->cachesize = 0;
- psLayer->resultcache->bounds.minx = -1;
- psLayer->resultcache->bounds.miny = -1;
- psLayer->resultcache->bounds.maxx = -1;
- psLayer->resultcache->bounds.maxy = -1;
+ /*this will force the queries to retrive the shapes using
+ their unique id #3305*/
+ psLayer->resultcache->usegetshape = MS_TRUE;
status = msLayerOpen(psLayer);
@@ -662,7 +659,8 @@
for (i=0; i<nSize; i++)
{
msInitShape(&shape);
- status = msLayerResultsGetShape(psLayer, &shape, -1, anValues[i]);
+ /*status = msLayerResultsGetShape(psLayer, &shape, -1, anValues[i]);*/
+ status = msLayerGetShape(psLayer, &shape, -1, anValues[i]);
if (status != MS_SUCCESS)
nClassIndex = -1;
Modified: branches/branch-5-6/mapserver/mapows.h
===================================================================
--- branches/branch-5-6/mapserver/mapows.h 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapows.h 2010-02-23 19:30:57 UTC (rev 9887)
@@ -399,7 +399,8 @@
#ifdef USE_WFS_SVR
-MS_DLL_EXPORT int msGMLWriteWFSQuery(mapObj *map, FILE *stream, int maxfeatures, char *wfs_namespace, int outputformat);
+MS_DLL_EXPORT int msGMLWriteWFSQuery(mapObj *map, FILE *stream, int maxfeatures, char *wfs_namespace,
+ int outputformat, int bUseGetShape);
#endif
Modified: branches/branch-5-6/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-6/mapserver/mappostgis.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mappostgis.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -1363,7 +1363,7 @@
}
-int msPostGISReadShape(layerObj *layer, shapeObj *shape, int random) {
+int msPostGISReadShape(layerObj *layer, shapeObj *shape) {
char *wkbstr = NULL;
unsigned char *wkb = NULL;
@@ -1461,26 +1461,21 @@
}
}
- if( random ) {
- /* t is the geometry, t+1 is the uid */
- tmp = PQgetvalue(layerinfo->pgresult, layerinfo->rownum, t + 1);
- if( tmp ) {
- uid = strtol( tmp, NULL, 10 );
- }
- else {
- uid = 0;
- }
- if( layer->debug > 4 ) {
- msDebug("msPostGISReadShape: Setting shape->index = %d\n", uid);
- }
- shape->index = uid;
- } else {
- if( layer->debug > 4 ) {
- msDebug("msPostGISReadShape: Setting shape->index = %d\n", layerinfo->rownum);
- }
- shape->index = layerinfo->rownum;
+ /* t is the geometry, t+1 is the uid */
+ tmp = PQgetvalue(layerinfo->pgresult, layerinfo->rownum, t + 1);
+ if( tmp ) {
+ uid = strtol( tmp, NULL, 10 );
}
-
+ else {
+ uid = 0;
+ }
+ if( layer->debug > 4 ) {
+ msDebug("msPostGISReadShape: Setting shape->index = %d\n", uid);
+ msDebug("msPostGISReadShape: Setting shape->tileindex = %d\n", layerinfo->rownum);
+ }
+ shape->index = uid;
+ shape->tileindex = layerinfo->rownum;
+
if( layer->debug > 2 ) {
msDebug("msPostGISReadShape: [index] %d\n", shape->index);
}
@@ -1845,7 +1840,7 @@
if (layerinfo->rownum < PQntuples(layerinfo->pgresult)) {
int rv;
/* Retrieve this shape, cursor access mode. */
- rv = msPostGISReadShape(layer, shape, 0);
+ rv = msPostGISReadShape(layer, shape);
if( shape->type != MS_SHAPE_NULL ) {
(layerinfo->rownum)++; /* move to next shape */
return MS_SUCCESS;
@@ -1887,9 +1882,14 @@
assert(layer->layerinfo != NULL);
if (layer->debug) {
- msDebug("msPostGISLayerGetShape called for record = %i\n", record);
+ msDebug("msPostGISLayerResultsGetShape called for record = %i\n", record);
}
+ if( tile < 0 ) {
+ msDebug("msPostGISLayerResultsGetShape called for record = %i\n", record);
+ return msPostGISLayerResultsGetShape(layer, shape, tile, record);
+ }
+
layerinfo = (msPostGISLayerInfo*) layer->layerinfo;
/* Check the validity of the open result. */
@@ -1912,21 +1912,21 @@
}
/* Check the validity of the requested record number. */
- if( record >= PQntuples(pgresult) ) {
- msDebug("msPostGISLayerResultsGetShape got record request (%d) but only has %d tuples.\n", record, PQntuples(pgresult));
+ if( tile >= PQntuples(pgresult) ) {
+ msDebug("msPostGISLayerResultsGetShape got request for (%d) but only has %d tuples.\n", tile, PQntuples(pgresult));
msSetError( MS_MISCERR,
"Got request larger than result set.",
"msPostGISLayerResultsGetShape()");
return MS_FAILURE;
}
- layerinfo->rownum = record; /* Only return one result. */
+ layerinfo->rownum = tile; /* Only return one result. */
/* We don't know the shape type until we read the geometry. */
shape->type = MS_SHAPE_NULL;
/* Return the shape, cursor access mode. */
- result = msPostGISReadShape(layer, shape, 0);
+ result = msPostGISReadShape(layer, shape);
return (shape->type == MS_SHAPE_NULL) ? MS_FAILURE : MS_SUCCESS;
#else
@@ -2013,7 +2013,7 @@
if (num_tuples > 0) {
/* Get shape in random access mode. */
- result = msPostGISReadShape(layer, shape, 1);
+ result = msPostGISReadShape(layer, shape);
}
return (shape->type == MS_SHAPE_NULL) ? MS_FAILURE : ( (num_tuples > 0) ? MS_SUCCESS : MS_DONE );
Modified: branches/branch-5-6/mapserver/mapquery.c
===================================================================
--- branches/branch-5-6/mapserver/mapquery.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapquery.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -362,9 +362,7 @@
if(map->query.clear_resultcache || lp->resultcache == NULL) {
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
}
msInitShape(&shape);
@@ -521,9 +519,7 @@
}
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
nclasses = 0;
classgroup = NULL;
@@ -674,9 +670,7 @@
}
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
nclasses = 0;
classgroup = NULL;
@@ -908,9 +902,7 @@
if(i == 0) {
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
}
nclasses = 0;
@@ -1166,9 +1158,7 @@
}
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
nclasses = 0;
classgroup = NULL;
@@ -1357,9 +1347,7 @@
}
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
nclasses = 0;
classgroup = NULL;
@@ -1528,11 +1516,8 @@
if(status != MS_SUCCESS) return(MS_FAILURE);
/* identify target shapes */
- searchrect.minx = map->extent.minx;
- searchrect.miny = map->extent.miny;
- searchrect.maxx = map->extent.maxx;
- searchrect.maxy = map->extent.maxy;
-
+ searchrect = qshape->bounds;
+
#ifdef USE_PROJ
if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
@@ -1549,9 +1534,7 @@
}
lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
- lp->resultcache->results = NULL;
- lp->resultcache->numresults = lp->resultcache->cachesize = 0;
- lp->resultcache->bounds.minx = lp->resultcache->bounds.miny = lp->resultcache->bounds.maxx = lp->resultcache->bounds.maxy = -1;
+ initResultCache( lp->resultcache);
classgroup = NULL;
if (lp->classgroup && lp->numclasses > 0)
Modified: branches/branch-5-6/mapserver/mapserver.h
===================================================================
--- branches/branch-5-6/mapserver/mapserver.h 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapserver.h 2010-02-23 19:30:57 UTC (rev 9887)
@@ -997,6 +997,9 @@
%mutable;
#endif /* SWIG */
+ /*used to force the result retreiving to use getshape instead of msLayerResultGetShape #3305*/
+ int usegetshape;
+
} resultCacheObj;
@@ -1599,6 +1602,7 @@
MS_DLL_EXPORT void initGrid( graticuleObj *pGraticule );
MS_DLL_EXPORT void initWeb(webObj *web);
MS_DLL_EXPORT void freeWeb(webObj *web);
+MS_DLL_EXPORT void initResultCache(resultCacheObj *resultcache);
MS_DLL_EXPORT featureListNodeObjPtr insertFeatureList(featureListNodeObjPtr *list, shapeObj *shape);
MS_DLL_EXPORT void freeFeatureList(featureListNodeObjPtr list);
Modified: branches/branch-5-6/mapserver/mapwfs.c
===================================================================
--- branches/branch-5-6/mapserver/mapwfs.c 2010-02-23 18:28:46 UTC (rev 9886)
+++ branches/branch-5-6/mapserver/mapwfs.c 2010-02-23 19:30:57 UTC (rev 9887)
@@ -1025,9 +1025,13 @@
char **papszPropertyName = NULL;
int nPropertyNames = 0;
+ /*use msLayerGetShape instead of msLayerResultsGetShape of complex filter #3305*/
+ int bUseGetShape = MS_FALSE;
+
/* Default filter is map extents */
bbox = map->extent;
+
/* Read CGI parameters */
/* */
/* __TODO__ Need to support XML encoded requests */
@@ -1453,6 +1457,9 @@
return msWFSException(map, "mapserv", "NoApplicableCode", paramsObj->pszVersion);
}
}
+
+ if (bUseGetShape == MS_FALSE)
+ bUseGetShape = (!FLTIsSimpleFilter(psNode));
FLTFreeFilterEncodingNode( psNode );
psNode = NULL;
@@ -1548,6 +1555,9 @@
return msWFSException(map, "mapserv", "NoApplicableCode", paramsObj->pszVersion);
}
+ if (bUseGetShape == MS_FALSE)
+ bUseGetShape = (!FLTIsSimpleFilter(psNode));
+
FLTFreeFilterEncodingNode( psNode );
psNode = NULL;
break;
@@ -1804,7 +1814,7 @@
/* handle case of maxfeatures = 0 */
if(maxfeatures != 0 && iResultTypeHits == 0)
- msGMLWriteWFSQuery(map, stdout, maxfeatures, pszNameSpace, outputformat);
+ msGMLWriteWFSQuery(map, stdout, maxfeatures, pszNameSpace, outputformat,bUseGetShape);
if (((iNumberOfFeatures==0) || (maxfeatures == 0)) && iResultTypeHits == 0) {
msIO_printf(" <gml:boundedBy>\n");
More information about the mapserver-commits
mailing list