[SCM] PostGIS branch stable-3.3 updated. 3.3.6-32-g70a47eee6

git at osgeo.org git at osgeo.org
Tue Aug 6 13:41:39 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, stable-3.3 has been updated
       via  70a47eee6fd6baa5d366e8f7afa34b30aeaefd17 (commit)
       via  e6a822547804589781559ef2b465652266876d96 (commit)
      from  0e67b844d2fd365a41ced24987dbb1febd48c97a (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 70a47eee6fd6baa5d366e8f7afa34b30aeaefd17
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 6 13:41:35 2024 -0700

    entry for #5765

diff --git a/NEWS b/NEWS
index 489f2e51d..2555b237c 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ and PostgreSQL 15+.
  - #5687, #5756 Support for PostgreSQL 17, revise postgis_get_full_version_schema()
           to not rely on search_path
  - #5740, ST_DistanceSpheroid(geometry) incorrectly handles polygons (Paul Ramsey)
+ - #5765, Handle nearly co-linear edges with slightly less slop (Paul Ramsey)
 
 
 PostGIS 3.3.6

commit e6a822547804589781559ef2b465652266876d96
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 6 13:25:24 2024 -0700

    Handle nearly co-linear edges with slightly less slop, reference #5765

diff --git a/liblwgeom/cunit/cu_tree.c b/liblwgeom/cunit/cu_tree.c
index ce46c1c4f..f43d8795b 100644
--- a/liblwgeom/cunit/cu_tree.c
+++ b/liblwgeom/cunit/cu_tree.c
@@ -182,6 +182,34 @@ static void test_tree_circ_distance(void)
 
 	spheroid_init(&s, 1.0, 1.0);
 
+	/* Ticket 5765 */
+	/* Two very close segments (1.64m) with mid-line points */
+	lwg1 = lwgeom_from_wkt("LINESTRING (-1.7485638876537 52.477970467863,-1.7485727216213 52.477970486617)", LW_PARSER_CHECK_NONE);
+	lwg2 = lwgeom_from_wkt("LINESTRING (-1.7486648265496 52.477955848635,-1.7485639721184 52.477955634571)", LW_PARSER_CHECK_NONE);
+	c1 = lwgeom_calculate_circ_tree(lwg1);
+	c2 = lwgeom_calculate_circ_tree(lwg2);
+	d1 = circ_tree_distance_tree(c1, c2, &s, threshold);
+	d2 = lwgeom_distance_spheroid(lwg1, lwg2, &s, threshold);
+	e1 = d1 * WGS84_RADIUS;
+	e2 = d2 * WGS84_RADIUS;
+
+	// printf("\nRadians (tree and brute force)\n");
+	// printf("  d1 = %g r   d2 = %g r\n", d1, d2);
+	// printf("\nMeters (tree and brute force)\n");
+	// printf("  e1 = %g m   e2 = %g m\n\n", e1, e2);
+	// printf("linestring a\n");
+	// circ_tree_print(c1, 0);
+	// printf("linestring b\n");
+	// circ_tree_print(c2, 0);
+
+	circ_tree_free(c1);
+	circ_tree_free(c2);
+	lwgeom_free(lwg1);
+	lwgeom_free(lwg2);
+	CU_ASSERT_DOUBLE_EQUAL(e1, e2, 0.0001);
+
+	return;
+
 	/* Ticket #4223 */
 	/* tall skinny rectangle */
 	lwg1 = lwgeom_from_wkt("POLYGON((58.5112113206308 0,58.5112113200772 0.000901937525203378,58.511300910044 0.000901937636668872,58.5113009105976 0,58.5112113206308 0))", LW_PARSER_CHECK_NONE);
@@ -193,12 +221,6 @@ static void test_tree_circ_distance(void)
 	d2 = lwgeom_distance_spheroid(lwg1, lwg2, &s, threshold);
 	e1 = d1 * WGS84_RADIUS;
 	e2 = d2 * WGS84_RADIUS;
-	// printf("d1 = %g   d2 = %g\n", d1, d2);
-	// printf("e1 = %g   e2 = %g\n", e1, e2);
-	// printf("polygon a\n");
-	// circ_tree_print(c1, 0);
-	// printf("polygon b\n");
-	// circ_tree_print(c2, 0);
 	circ_tree_free(c1);
 	circ_tree_free(c2);
 	lwgeom_free(lwg1);
@@ -213,11 +235,6 @@ static void test_tree_circ_distance(void)
 	c2 = lwgeom_calculate_circ_tree(lwg2);
 	d1 = circ_tree_distance_tree(c1, c2, &s, threshold);
 	d2 = lwgeom_distance_spheroid(lwg1, lwg2, &s, threshold);
-//	printf("d1 = %g   d2 = %g\n", d1 * WGS84_RADIUS, d2 * WGS84_RADIUS);
-//	printf("line\n");
-//	circ_tree_print(c1, 0);
-//	printf("poly\n");
-//	circ_tree_print(c2, 0);
 	circ_tree_free(c1);
 	circ_tree_free(c2);
 	lwgeom_free(lwg1);
diff --git a/liblwgeom/lwgeodetic.c b/liblwgeom/lwgeodetic.c
index b830bac39..32e191999 100644
--- a/liblwgeom/lwgeodetic.c
+++ b/liblwgeom/lwgeodetic.c
@@ -3392,7 +3392,14 @@ edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const P
 	/* Are A-plane and B-plane basically the same? */
 	ab_dot = dot_product(&AN, &BN);
 
-	if ( FP_EQUALS(fabs(ab_dot), 1.0) )
+	/*
+	* https://trac.osgeo.org/postgis/ticket/5765
+	* Failure because the colinearity check was
+	* triggering due to an overly loose equality
+	* check here.
+	* if ( FP_EQUALS(fabs(ab_dot), 1.0) )
+	*/
+	if ( 1.0 - fabs(ab_dot) <= 10e-16 )
 	{
 		/* Co-linear case */
 		if ( point_in_cone(A1, A2, B1) || point_in_cone(A1, A2, B2) ||
diff --git a/liblwgeom/lwgeodetic_tree.c b/liblwgeom/lwgeodetic_tree.c
index 9baa8cd3b..647b59a1b 100644
--- a/liblwgeom/lwgeodetic_tree.c
+++ b/liblwgeom/lwgeodetic_tree.c
@@ -873,27 +873,27 @@ void circ_tree_print(const CIRC_NODE* node, int depth)
 
 	if (circ_node_is_leaf(node))
 	{
-		printf("%*s[%d] C(%.5g %.5g) R(%.5g) ((%.5g %.5g),(%.5g,%.5g))",
+		printf("%*s[%d] C(%.8g %.8g) R(%.8g) ((%.8g %.8g),(%.8g,%.8g))",
 		  3*depth + 6, "NODE", node->edge_num,
 		  node->center.lon, node->center.lat,
 		  node->radius,
 		  node->p1->x, node->p1->y,
 		  node->p2->x, node->p2->y
 		);
-  		if ( node->geom_type )
-  		{
-  			printf(" %s", lwtype_name(node->geom_type));
-  		}
-  		if ( node->geom_type == POLYGONTYPE )
-  		{
-  			printf(" O(%.5g %.5g)", node->pt_outside.x, node->pt_outside.y);
-  		}
-  		printf("\n");
+		if ( node->geom_type )
+		{
+			printf(" %s", lwtype_name(node->geom_type));
+		}
+		if ( node->geom_type == POLYGONTYPE )
+		{
+			printf(" O(%.8g %.8g)", node->pt_outside.x, node->pt_outside.y);
+		}
+		printf("\n");
 
 	}
 	else
 	{
-		printf("%*s C(%.5g %.5g) R(%.5g)",
+		printf("%*s C(%.8g %.8g) R(%.8g)",
 		  3*depth + 6, "NODE",
 		  node->center.lon, node->center.lat,
 		  node->radius
@@ -902,10 +902,10 @@ void circ_tree_print(const CIRC_NODE* node, int depth)
 		{
 			printf(" %s", lwtype_name(node->geom_type));
 		}
-  		if ( node->geom_type == POLYGONTYPE )
-  		{
-  			printf(" O(%.15g %.15g)", node->pt_outside.x, node->pt_outside.y);
-  		}
+		if ( node->geom_type == POLYGONTYPE )
+		{
+			printf(" O(%.15g %.15g)", node->pt_outside.x, node->pt_outside.y);
+		}
 		printf("\n");
 	}
 	for ( i = 0; i < node->num_nodes; i++ )

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

Summary of changes:
 NEWS                        |  1 +
 liblwgeom/cunit/cu_tree.c   | 39 ++++++++++++++++++++++++++++-----------
 liblwgeom/lwgeodetic.c      |  9 ++++++++-
 liblwgeom/lwgeodetic_tree.c | 30 +++++++++++++++---------------
 4 files changed, 52 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list