[SCM] PostGIS branch stable-3.4 updated. 3.4.2-51-g07b12098d

git at osgeo.org git at osgeo.org
Tue Aug 6 13:40: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.4 has been updated
       via  07b12098db027acfd36b2cb2d17aa4a230b97e8a (commit)
       via  b556bc0bd56a7a1fe80e26032285d26e1508ce73 (commit)
      from  c1b8e12c3fb15fceb23f2e7949bfbd87c5da3b10 (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 07b12098db027acfd36b2cb2d17aa4a230b97e8a
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Aug 6 13:40:34 2024 -0700

    entry for #5765

diff --git a/NEWS b/NEWS
index b61d82cf8..55dd37412 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ To take advantage of all SFCGAL featurs, SFCGAL 1.4.1+ is needed.
  - #5734, Estimate geography extent more correctly (Paul Ramsey)
  - #5752, ST_ClosestPoint(geography) error (Paul Ramsey)
  - #5740, ST_DistanceSpheroid(geometry) incorrectly handles polygons (Paul Ramsey)
+ - #5765, Handle nearly co-linear edges with slightly less slop (Paul Ramsey)
 
 PostGIS 3.4.2
 2024/02/08

commit b556bc0bd56a7a1fe80e26032285d26e1508ce73
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 c60e4e72d..acf4b4798 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 8afffa8e2..8e6f75e05 100644
--- a/liblwgeom/lwgeodetic.c
+++ b/liblwgeom/lwgeodetic.c
@@ -3400,7 +3400,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 cbede3750..6e7909741 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