[SCM] PostGIS branch master updated. 3.5.0alpha2-21-g4f33aa5bc
git at osgeo.org
git at osgeo.org
Tue Aug 6 13:38:50 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 4f33aa5bc0e53d72d4f7442dcf4e6bbbe2905ccc (commit)
from 94021d02fa8c247cdfd66d2889480069b4763ef9 (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 4f33aa5bc0e53d72d4f7442dcf4e6bbbe2905ccc
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 d5ab0dbf8..c4b716d0b 100644
--- a/liblwgeom/cunit/cu_tree.c
+++ b/liblwgeom/cunit/cu_tree.c
@@ -183,6 +183,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);
@@ -194,12 +222,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);
@@ -214,11 +236,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 85953c7bc..af3ae8a28 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:
liblwgeom/cunit/cu_tree.c | 39 ++++++++++++++++++++++++++++-----------
liblwgeom/lwgeodetic.c | 9 ++++++++-
liblwgeom/lwgeodetic_tree.c | 30 +++++++++++++++---------------
3 files changed, 51 insertions(+), 27 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list