[SCM] PostGIS branch master updated. 3.4.0rc1-890-g5b2ae9ff0

git at osgeo.org git at osgeo.org
Sat Jan 20 12:37:08 PST 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  5b2ae9ff058387de2a0b015181190ded0b37b12a (commit)
      from  d2e93ca0dccdb7230ba356643585157595a208bb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5b2ae9ff058387de2a0b015181190ded0b37b12a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Sat Jan 20 12:37:03 2024 -0800

    Correctly handle max distance for point/polygon case, avoiding returning distance to points that are contained in the polygon (distance == 0). References #5639

diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c
index b22b2cca1..240b39bc6 100644
--- a/liblwgeom/measures.c
+++ b/liblwgeom/measures.c
@@ -238,6 +238,17 @@ lw_dist2d_comp(const LWGEOM *lw1, const LWGEOM *lw2, DISTPTS *dl)
 	return lw_dist2d_recursive(lw1, lw2, dl);
 }
 
+static int
+lw_dist2d_zero(DISTPTS *dl, const POINT2D *pt1, const POINT2D *pt2)
+{
+	dl->distance = 0.0;
+	if (pt1)
+		dl->p1 = *pt1;
+	if (pt2)
+		dl->p2 = *pt2;
+	return LW_TRUE;
+}
+
 static int
 lw_dist2d_is_collection(const LWGEOM *g)
 {
@@ -642,10 +653,6 @@ lw_dist2d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl)
 {
 	const POINT2D *p = getPoint2d_cp(point->point, 0);
 
-	/* Max distance? Check only outer ring.*/
-	if (dl->mode == DIST_MAX)
-		return lw_dist2d_pt_ptarray(p, poly->rings[0], dl);
-
 	/* Return distance to outer ring if not inside it */
 	if (ptarray_contains_point(poly->rings[0], p) == LW_OUTSIDE)
 		return lw_dist2d_pt_ptarray(p, poly->rings[0], dl);
@@ -661,10 +668,7 @@ lw_dist2d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl)
 			return lw_dist2d_pt_ptarray(p, poly->rings[i], dl);
 
 	/* Is inside the polygon */
-	dl->distance = 0.0;
-	dl->p1.x = dl->p2.x = p->x;
-	dl->p1.y = dl->p2.y = p->y;
-	return LW_TRUE;
+	return lw_dist2d_zero(dl, p, p);
 }
 
 int
@@ -762,12 +766,7 @@ lw_dist2d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS *dl)
 
 	/* Not in hole, so inside polygon */
 	if (dl->mode == DIST_MIN)
-	{
-		dl->distance = 0.0;
-		dl->p1.x = dl->p2.x = pt->x;
-		dl->p1.y = dl->p2.y = pt->y;
-	}
-	return LW_TRUE;
+		return lw_dist2d_zero(dl, p, p);
 }
 
 int

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/measures.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list