[SCM] PostGIS branch master updated. 3.5.0alpha2-18-ge734cac9b

git at osgeo.org git at osgeo.org
Fri Aug 2 13:22:34 PDT 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  e734cac9b58fed05ec1729f47ca53be0f58f296d (commit)
      from  80806376a566ebd1b2edfe0dd0a69dc1c3f718cd (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 e734cac9b58fed05ec1729f47ca53be0f58f296d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Aug 2 13:22:24 2024 -0700

    Return the appropriate closest points in the geography close point calculation, references #5752

diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c
index d4b676f39..09f878155 100644
--- a/liblwgeom/cunit/cu_geodetic.c
+++ b/liblwgeom/cunit/cu_geodetic.c
@@ -1593,6 +1593,7 @@ static void test_lwgeom_area_sphere(void)
 	/* end #3393 */
 }
 
+
 static void test_gbox_to_string_truncated(void)
 {
 	GBOX g = {
diff --git a/liblwgeom/cunit/cu_tree.c b/liblwgeom/cunit/cu_tree.c
index 0491ce223..d5ab0dbf8 100644
--- a/liblwgeom/cunit/cu_tree.c
+++ b/liblwgeom/cunit/cu_tree.c
@@ -605,6 +605,28 @@ static void test_itree_degenerate_poly(void)
 	test_itree_once(wktPoly, 0, 0, ITREE_BOUNDARY);
 }
 
+
+static void test_geography_tree_closestpoint(void)
+{
+	LWGEOM *lwg1, *lwg2, *lwg3;
+	LWPOINT *lwpt;
+	POINT2D pt;
+
+	/* Simple case */
+	lwg1 = lwgeom_from_wkt("LINESTRING (18 9, 18 1)", LW_PARSER_CHECK_NONE);
+	lwg2 = lwgeom_from_wkt("POINT (16 4)", LW_PARSER_CHECK_NONE);
+	lwg3 = geography_tree_closestpoint(lwg1, lwg2, 0.1);
+	lwpt = (LWPOINT *)lwg3;
+
+	lwpoint_getPoint2d_p(lwpt, &pt);
+	CU_ASSERT_DOUBLE_EQUAL(pt.x, 18, 0.0001);
+	CU_ASSERT_DOUBLE_EQUAL(pt.y, 4.0024302, 0.0001);
+
+	lwgeom_free(lwg1);
+	lwgeom_free(lwg2);
+	lwgeom_free(lwg3);
+}
+
 /*
 ** Used by test harness to register the tests in this file.
 */
@@ -622,4 +644,5 @@ void tree_suite_setup(void)
 	PG_ADD_TEST(suite, test_tree_circ_pip2);
 	PG_ADD_TEST(suite, test_tree_circ_distance);
 	PG_ADD_TEST(suite, test_tree_circ_distance_threshold);
+	PG_ADD_TEST(suite, test_geography_tree_closestpoint);
 }
diff --git a/liblwgeom/lwgeodetic_tree.c b/liblwgeom/lwgeodetic_tree.c
index a425046a0..cbede3750 100644
--- a/liblwgeom/lwgeodetic_tree.c
+++ b/liblwgeom/lwgeodetic_tree.c
@@ -770,11 +770,11 @@ circ_tree_distance_tree_internal(const CIRC_NODE* n1, const CIRC_NODE* n2, doubl
 			/* Node 2 is a point */
 			else
 			{
-				geographic_point_init(n2->p1->x, n2->p1->y, &gp1);
+				geographic_point_init(n2->p1->x, n2->p1->y, &gp2);
 				geographic_point_init(n1->p1->x, n1->p1->y, &(e.start));
 				geographic_point_init(n1->p2->x, n1->p2->y, &(e.end));
-				close1 = gp1;
-				d = edge_distance_to_point(&e, &gp1, &close2);
+				close2 = gp2;
+				d = edge_distance_to_point(&e, &gp2, &close1);
 			}
 			LWDEBUGF(4, "  got distance %g", d);
 		}
diff --git a/regress/core/geography_expected b/regress/core/geography_expected
index a7062388c..a5ead8c91 100644
--- a/regress/core/geography_expected
+++ b/regress/core/geography_expected
@@ -66,4 +66,4 @@ lrs_llp_2|0.00
 lrs_llp_3|1.00
 ERROR:  geography_line_locate_point: 2st arg is not a point
 lrs_substr_1|LINESTRING(9.28 23.25,18.97 25.93)
-lrs_sl_1|LINESTRING(25 40,25 42.79)
+lrs_sl_1|LINESTRING(25 42.79,25 40)

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

Summary of changes:
 liblwgeom/cunit/cu_geodetic.c   |  1 +
 liblwgeom/cunit/cu_tree.c       | 23 +++++++++++++++++++++++
 liblwgeom/lwgeodetic_tree.c     |  6 +++---
 regress/core/geography_expected |  2 +-
 4 files changed, 28 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list