]> granicus.if.org Git - postgis/commitdiff
minor speedups in distance()
authorSandro Santilli <strk@keybit.net>
Thu, 8 Sep 2005 22:58:47 +0000 (22:58 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 8 Sep 2005 22:58:47 +0000 (22:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@1895 b70326c6-7e19-0410-871a-916f4a2858ee

CHANGES
lwgeom/measures.c

diff --git a/CHANGES b/CHANGES
index af485f54f55bf4275693657b9a7588ce48029a8e..dd18184b0f51aeb81bde665661cc7c059f7cd363 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@ PostGIS 1.0.4
        - Looser syntax acceptance in box3d parser
        - Documentation improvements
        - More robust selectivity estimator 
+       - Minor speedup in distance()
 
 PostGIS 1.0.3
 2005/08/08
index 7fa33a1670f4bcbde73b92540ffa49187983361b..e0f5cc7235b9080ca863cd3682bdb3959ca469d7 100644 (file)
@@ -459,15 +459,21 @@ double distance2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2)
        //   if intersect, return 0
        for (i=0; i<poly1->nrings; i++)
        {
-               double dist = distance2d_ptarray_poly(poly1->rings[i], poly2);
-               if (i) mindist = LW_MIN(mindist, dist);
-               else mindist = dist;
+               int j;
+               for (j=0; j<poly2->nrings; j++)
+               {
+                       double d = distance2d_ptarray_ptarray(poly1->rings[i],
+                               poly2->rings[j]);
+                       if ( d <= 0 ) return 0.0;
+
+                       if (i) mindist = LW_MIN(mindist, d);
+                       else mindist = d;
+               }
 
 #ifdef PGIS_DEBUG
-               lwnotice("  ring%d dist: %f, mindist: %f", i, dist, mindist);
+               lwnotice("  ring%d dist: %f, mindist: %f", i, d, mindist);
 #endif
 
-               if ( mindist <= 0 ) return 0.0; // intersection
        }
 
        // otherwise return closest approach of rings (no intersection)