[mapserver-commits] r10826 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Jan 3 00:28:27 EST 2011


Author: sdlime
Date: 2011-01-02 21:28:27 -0800 (Sun, 02 Jan 2011)
New Revision: 10826

Modified:
   trunk/mapserver/mapprimitive.c
   trunk/mapserver/mapprimitive.h
   trunk/mapserver/mapquery.c
   trunk/mapserver/mapserver.h
Log:
Added result index to shapeObj and resultSetMemberObj in preparation for RFC 65. It looks to be safest to simply track a new index value and not re-purpose the tile index.

Modified: trunk/mapserver/mapprimitive.c
===================================================================
--- trunk/mapserver/mapprimitive.c	2011-01-03 00:53:04 UTC (rev 10825)
+++ trunk/mapserver/mapprimitive.c	2011-01-03 05:28:27 UTC (rev 10826)
@@ -104,7 +104,7 @@
 
   /* bookkeeping component */
   shape->classindex = 0; /* default class */
-  shape->tileindex = shape->index = -1;
+  shape->tileindex = shape->index = shape->resultindex = -1;
 
   shape->scratch = MS_FALSE; /* not a temporary/scratch shape */
 }
@@ -129,6 +129,7 @@
   to->classindex = from->classindex;
   to->index = from->index;
   to->tileindex = from->tileindex;
+  to->resultindex = from->resultindex;
 
   if(from->values) {    
     to->values = (char **)msSmallMalloc(sizeof(char *)*from->numvalues);

Modified: trunk/mapserver/mapprimitive.h
===================================================================
--- trunk/mapserver/mapprimitive.h	2011-01-03 00:53:04 UTC (rev 10825)
+++ trunk/mapserver/mapprimitive.h	2011-01-03 05:28:27 UTC (rev 10826)
@@ -88,6 +88,7 @@
   char *text;
   
   int scratch;
+  int resultindex; /* index within a query result set */
 } shapeObj;
 
 typedef lineObj multipointObj;

Modified: trunk/mapserver/mapquery.c
===================================================================
--- trunk/mapserver/mapquery.c	2011-01-03 00:53:04 UTC (rev 10825)
+++ trunk/mapserver/mapquery.c	2011-01-03 05:28:27 UTC (rev 10826)
@@ -135,7 +135,7 @@
   return MS_FALSE;
 }
 
-static int addResult(resultCacheObj *cache, int classindex, int shapeindex, int tileindex)
+static int addResult(resultCacheObj *cache, shapeObj *shape)
 {
   int i;
 
@@ -153,11 +153,17 @@
 
   i = cache->numresults;
 
-  cache->results[i].classindex = classindex;
-  cache->results[i].tileindex = tileindex;
-  cache->results[i].shapeindex = shapeindex;
+  cache->results[i].classindex = shape->classindex;
+  cache->results[i].tileindex = shape->tileindex;
+  cache->results[i].shapeindex = shape->index;
+  cache->results[i].resultindex = shape->resultindex;
   cache->numresults++;
 
+  if(cache->numresults == 1)
+    cache->bounds = shape->bounds;
+  else
+    msMergeRect(&(cache->bounds), &(shape->bounds));
+
   return(MS_SUCCESS);
 }
 
@@ -494,11 +500,7 @@
     return(MS_FAILURE);
   }
 
-  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-  if(lp->resultcache->numresults == 1)
-    lp->resultcache->bounds = shape.bounds;
-  else
-    msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
+  addResult(lp->resultcache, &shape);
 
   msFreeShape(&shape);
   /* msLayerClose(lp); */
@@ -654,13 +656,8 @@
       lp->project = MS_FALSE;
 #endif
 
-    addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
+    addResult(lp->resultcache, &shape);
     
-    if(lp->resultcache->numresults == 1)
-      lp->resultcache->bounds = shape.bounds;
-    else
-      msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
-    
     msFreeShape(&shape);
 
     if(map->query.mode == MS_QUERY_SINGLE) { /* no need to look any further */
@@ -837,14 +834,8 @@
 	}
       }	
 
-      if(status == MS_TRUE) {
-	addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-	
-	if(lp->resultcache->numresults == 1)
-	  lp->resultcache->bounds = shape.bounds;
-	else
-	  msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
-      }
+      if(status == MS_TRUE)
+	addResult(lp->resultcache, &shape);
 
       msFreeShape(&shape);
     } /* next shape */
@@ -1125,15 +1116,9 @@
 	  break; /* should never get here as we test for selection shape type explicitly earlier */
 	}
 
-	if(status == MS_TRUE) {
-	  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
+	if(status == MS_TRUE)
+	  addResult(lp->resultcache, &shape);
 
-	  if(lp->resultcache->numresults == 1)
-	    lp->resultcache->bounds = shape.bounds;
-	  else
-	    msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
-	}
-
 	msFreeShape(&shape);
       } /* next shape */
 
@@ -1315,15 +1300,10 @@
       if( d <= t ) { /* found one */
 	if(map->query.mode == MS_QUERY_SINGLE) {
 	  lp->resultcache->numresults = 0;
-	  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-	  lp->resultcache->bounds = shape.bounds;
+	  addResult(lp->resultcache, &shape);	  
 	  t = d; /* next one must be closer */
 	} else {
-	  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-	  if(lp->resultcache->numresults == 1)
-	    lp->resultcache->bounds = shape.bounds;
-	  else
-	    msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
+	  addResult(lp->resultcache, &shape);
 	}
       }
  
@@ -1574,14 +1554,8 @@
 	break; /* should never get here as we test for selection shape type explicitly earlier */
       }
 
-      if(status == MS_TRUE) {
-	addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-	
-	if(lp->resultcache->numresults == 1)
-	  lp->resultcache->bounds = shape.bounds;
-	else
-	  msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
-      }
+      if(status == MS_TRUE)
+	addResult(lp->resultcache, &shape);
 
       msFreeShape(&shape);
     } /* next shape */
@@ -1601,7 +1575,6 @@
   return(MS_FAILURE);
 }
 
-
 /************************************************************************/
 /*                            msQueryByOperator                         */
 /*                                                                      */
@@ -1807,14 +1780,8 @@
           return(MS_FAILURE);
       }
 
-      if(status == MS_TRUE) {
-        addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
-	
-        if(lp->resultcache->numresults == 1)
-          lp->resultcache->bounds = shape.bounds;
-        else
-          msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
-      }
+      if(status == MS_TRUE)
+        addResult(lp->resultcache, &shape);
 
       msFreeShape(&shape);
     } /* next shape */

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-01-03 00:53:04 UTC (rev 10825)
+++ trunk/mapserver/mapserver.h	2011-01-03 05:28:27 UTC (rev 10826)
@@ -1080,6 +1080,7 @@
 typedef struct {
   long shapeindex;
   int tileindex;
+  int resultindex;
   int classindex;
 } resultCacheMemberObj;
 #ifdef SWIG



More information about the mapserver-commits mailing list