minor speedups in distance()

git-svn-id: http://svn.osgeo.org/postgis/trunk@1896 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2005-09-08 22:59:18 +00:00
parent 5b8fcb6507
commit eb0831b1c9
2 changed files with 12 additions and 5 deletions

View file

@ -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

View 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)