[SCM] PostGIS branch stable-3.1 updated. 3.1.11-6-g0061ffe22
git at osgeo.org
git at osgeo.org
Tue Aug 6 13:43:15 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.1 has been updated
via 0061ffe223de3bfb2b1e3e78ab681a60230ae539 (commit)
via 32e42576b6f928bcbbd58574bf070ac790782875 (commit)
from 50abdc26dbecdcd4e0019c0100638b1c184ee3f1 (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 0061ffe223de3bfb2b1e3e78ab681a60230ae539
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Aug 6 13:43:10 2024 -0700
entry for #5765
diff --git a/NEWS b/NEWS
index 939c930f7..c948a5e10 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ xxxx/xx/xx
- #5589, ST_3DDistance error for shared first point (Paul Ramsey)
- #5686, ST_NumInteriorRings and Triangle crash (Paul Ramsey)
+ - #5765, Handle nearly co-linear edges with slightly less slop (Paul Ramsey)
PostGIS 3.1.11
commit 32e42576b6f928bcbbd58574bf070ac790782875
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 1903b8ede..6c4e04cdf 100644
--- a/liblwgeom/lwgeodetic.c
+++ b/liblwgeom/lwgeodetic.c
@@ -3542,7 +3542,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