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

CHANGES
lwgeom/measures.c

diff --git a/CHANGES b/CHANGES
index ec218bad5ab45c639d5408354b7fb9104e0b5efd..5846b19a0c1e047a6c3a688c52f13a6d49643749 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,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)