[mapserver-commits] r9514 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Oct 28 10:43:05 EDT 2009


Author: sdlime
Date: 2009-10-28 10:43:04 -0400 (Wed, 28 Oct 2009)
New Revision: 9514

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapsearch.c
Log:
Applied code simplification patch for mapsearch.c (#3189)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-10-26 17:18:18 UTC (rev 9513)
+++ trunk/mapserver/HISTORY.TXT	2009-10-28 14:43:04 UTC (rev 9514)
@@ -14,6 +14,9 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Applied code clean up patch for mapsearch.c. Results in some modest
+  performance gains in certain query use cases.
+
 - Fixed labels centering when the label is longer than the line (#2867)
 
 - Ensure Python MapScript building doesn't reorder the libraries, support the 

Modified: trunk/mapserver/mapsearch.c
===================================================================
--- trunk/mapserver/mapsearch.c	2009-10-26 17:18:18 UTC (rev 9513)
+++ trunk/mapserver/mapsearch.c	2009-10-28 14:43:04 UTC (rev 9514)
@@ -228,56 +228,48 @@
   for(c1=0; c1<line1->numlines; c1++)
     for(v1=1; v1<line1->line[c1].numpoints; v1++)
       for(c2=0; c2<line2->numlines; c2++)
-  for(v2=1; v2<line2->line[c2].numpoints; v2++)
-    if(msIntersectSegments(&(line1->line[c1].point[v1-1]), &(line1->line[c1].point[v1]), &(line2->line[c2].point[v2-1]), &(line2->line[c2].point[v2])) ==  MS_TRUE)
-      return(MS_TRUE);
+        for(v2=1; v2<line2->line[c2].numpoints; v2++)
+          if(msIntersectSegments(&(line1->line[c1].point[v1-1]), &(line1->line[c1].point[v1]),
+              &(line2->line[c2].point[v2-1]), &(line2->line[c2].point[v2])) ==  MS_TRUE)
+            return(MS_TRUE);
 
   return(MS_FALSE);
 }
 
 int msIntersectPolylinePolygon(shapeObj *line, shapeObj *poly) {
-  int c1,v1,c2,v2;
+  int i;
 
   /* STEP 1: polygon might competely contain the polyline or one of it's parts (only need to check one point from each part) */
-  for(c1=0; c1<line->numlines; c1++) {
-    if(msIntersectPointPolygon(&(line->line[c1].point[0]), poly) == MS_TRUE) /* this considers holes and multiple parts */
+  for(i=0; i<line->numlines; i++) {
+    if(msIntersectPointPolygon(&(line->line[i].point[0]), poly) == MS_TRUE) /* this considers holes and multiple parts */
       return(MS_TRUE);
   }
 
-
   /* STEP 2: look for intersecting line segments */
-  for(c1=0; c1<line->numlines; c1++)
-    for(v1=1; v1<line->line[c1].numpoints; v1++)
-      for(c2=0; c2<poly->numlines; c2++)
-  for(v2=1; v2<poly->line[c2].numpoints; v2++)
-    if(msIntersectSegments(&(line->line[c1].point[v1-1]), &(line->line[c1].point[v1]), &(poly->line[c2].point[v2-1]), &(poly->line[c2].point[v2])) ==  MS_TRUE)
-      return(MS_TRUE);
-  
+  if (msIntersectPolylines(line, poly) == MS_TRUE)
+    return (MS_TRUE);
+
   return(MS_FALSE);
 }
 
 int msIntersectPolygons(shapeObj *p1, shapeObj *p2) {
-  int c1,v1,c2,v2;
+  int i;
 
   /* STEP 1: polygon 1 completely contains 2 (only need to check one point from each part) */
-  for(c2=0; c2<p2->numlines; c2++) {
-    if(msIntersectPointPolygon(&(p2->line[c2].point[0]), p1) == MS_TRUE) /* this considers holes and multiple parts */
+  for(i=0; i<p2->numlines; i++) {
+    if(msIntersectPointPolygon(&(p2->line[i].point[0]), p1) == MS_TRUE) /* this considers holes and multiple parts */
       return(MS_TRUE);
   }
 
   /* STEP 2: polygon 2 completely contains 1 (only need to check one point from each part) */
-  for(c1=0; c1<p1->numlines; c1++) {
-    if(msIntersectPointPolygon(&(p1->line[c1].point[0]), p2) == MS_TRUE) /* this considers holes and multiple parts */
+  for(i=0; i<p1->numlines; i++) {
+    if(msIntersectPointPolygon(&(p1->line[i].point[0]), p2) == MS_TRUE) /* this considers holes and multiple parts */
       return(MS_TRUE);
   }
 
   /* STEP 3: look for intersecting line segments */
-  for(c1=0; c1<p1->numlines; c1++)
-    for(v1=1; v1<p1->line[c1].numpoints; v1++)
-      for(c2=0; c2<p2->numlines; c2++)
-  for(v2=1; v2<p2->line[c2].numpoints; v2++)
-    if(msIntersectSegments(&(p1->line[c1].point[v1-1]), &(p1->line[c1].point[v1]), &(p2->line[c2].point[v2-1]), &(p2->line[c2].point[v2])) ==  MS_TRUE)     
-      return(MS_TRUE);
+  if (msIntersectPolylines(p1, p2) == MS_TRUE)
+    return(MS_TRUE);
 
   /*
   ** At this point we know there are are no intersections between edges. There may be other tests necessary



More information about the mapserver-commits mailing list