[SCM] PostGIS branch master updated. 3.4.0rc1-1041-g5e5afc046
git at osgeo.org
git at osgeo.org
Fri Mar 22 10:10:53 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 5e5afc046bb84c72b5c3831c455c86b2b5f53391 (commit)
from d37594dfafb21a71119252fe06bf05d9fc79b796 (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 5e5afc046bb84c72b5c3831c455c86b2b5f53391
Author: Sandro Santilli <strk at kbt.io>
Date: Fri Mar 22 17:11:23 2024 +0100
Fix lwline_split_by_point_to determination of boundary points
Replaces tolerance-based p4d_same usage with the stricter
P4D_SAME_STRICT macro, now exposed in liblwgeom_internal.h
References #5698 in master branch (3.5.0dev)
Includes unit test
diff --git a/liblwgeom/cunit/cu_split.c b/liblwgeom/cunit/cu_split.c
index edbf00aa4..223fcd071 100644
--- a/liblwgeom/cunit/cu_split.c
+++ b/liblwgeom/cunit/cu_split.c
@@ -271,6 +271,18 @@ static void test_lwgeom_split(void)
lwgeom_free(ret);
lwgeom_free(geom);
lwgeom_free(blade);
+
+ /* See #5698 -- robustness issue */
+ geom = lwgeom_from_wkt("LINESTRING(15.796760167740288 69.05714853429149,15.796760167739626 69.05714853429157,15.795906966300288 69.05725770093837)", LW_PARSER_CHECK_NONE);
+ CU_ASSERT_FATAL(geom != NULL);
+ blade = lwpoint_as_lwgeom(lwline_get_lwpoint(lwgeom_as_lwline(geom), 1));
+ CU_ASSERT(blade != NULL);
+ ret = lwgeom_split(geom, blade);
+ CU_ASSERT_FATAL(ret != NULL);
+ ASSERT_INT_EQUAL( lwgeom_as_lwcollection(ret)->ngeoms, 2 );
+ lwgeom_free(ret);
+ lwgeom_free(geom);
+ lwgeom_free(blade);
}
static int
diff --git a/liblwgeom/liblwgeom_internal.h b/liblwgeom/liblwgeom_internal.h
index 5428d1f24..f1e28eac0 100644
--- a/liblwgeom/liblwgeom_internal.h
+++ b/liblwgeom/liblwgeom_internal.h
@@ -247,13 +247,22 @@ lwvarlena_t *geohash_point(double longitude, double latitude, int precision);
void decode_geohash_bbox(char *geohash, double *lat, double *lon, int precision);
/*
-* Point comparisons
+* Point comparisons (FP tolerance based)
*/
int p4d_same(const POINT4D *p1, const POINT4D *p2);
int p3d_same(const POINT3D *p1, const POINT3D *p2);
int p3dz_same(const POINT3DZ *p1, const POINT3DZ *p2);
int p2d_same(const POINT2D *p1, const POINT2D *p2);
+/*
+ * Non-tolerance based equality for points
+ * whereas the p#d_same function are tolerance based
+ */
+#define P2D_SAME_STRICT(a,b) ((a)->x == (b)->x && (a)->y == (b)->y)
+#define P3DZ_SAME_STRICT(a,b) ((a)->x == (b)->x && (a)->y == (b)->y && (a)->z == (b)->z )
+#define P3DM_SAME_STRICT(a,b) ((a)->x == (b)->x && (a)->y == (b)->y && (a)->m == (b)->m )
+#define P4D_SAME_STRICT(a,b) ((a)->x == (b)->x && (a)->y == (b)->y && (a)->z == (b)->z && (a)->m == (b)->m )
+
/*
* Projections
*/
diff --git a/liblwgeom/lwgeom_geos_split.c b/liblwgeom/lwgeom_geos_split.c
index 901a1ac14..724ff7754 100644
--- a/liblwgeom/lwgeom_geos_split.c
+++ b/liblwgeom/lwgeom_geos_split.c
@@ -240,7 +240,7 @@ lwline_split_by_point_to(const LWLINE* lwline_in, const LWPOINT* blade_in,
{
getPoint4d_p(ipa, i+1, &p2);
double dist_sqr = distance2d_sqr_pt_seg((POINT2D *)&pt, (POINT2D *)&p1, (POINT2D *)&p2);
- LWDEBUGF(4, "Distance (squared) of point %g %g to segment %g %g, %g %g: %g",
+ LWDEBUGF(4, "Distance (squared) of point %.15g %.15g to segment %.15g %.15g, %.15g %.15g: %.15g",
pt.x, pt.y,
p1.x, p1.y,
p2.x, p2.y,
@@ -256,7 +256,7 @@ lwline_split_by_point_to(const LWLINE* lwline_in, const LWPOINT* blade_in,
}
LWDEBUGF(3, "Closest segment: %d", seg);
- LWDEBUGF(3, "mindist: %g", mindist_sqr);
+ LWDEBUGF(3, "mindist: %.15g", mindist_sqr);
/* No intersection */
if (mindist_sqr > 0)
@@ -280,11 +280,11 @@ lwline_split_by_point_to(const LWLINE* lwline_in, const LWPOINT* blade_in,
pt_projected.x = pt.x;
pt_projected.y = pt.y;
- LWDEBUGF(3, "Projected point:(%g %g), seg:%d, p1:(%g %g), p2:(%g %g)", pt_projected.x, pt_projected.y, seg, p1.x, p1.y, p2.x, p2.y);
+ LWDEBUGF(3, "Projected point:(%.15g %.15g), seg:%d, p1:(%.15g %.15g), p2:(%.15g %.15g)", pt_projected.x, pt_projected.y, seg, p1.x, p1.y, p2.x, p2.y);
/* When closest point == an endpoint, this is a boundary intersection */
- if ( ( (seg == nsegs-1) && p4d_same(&pt_projected, &p2) ) ||
- ( (seg == 0) && p4d_same(&pt_projected, &p1) ) )
+ if ( ( (seg == nsegs-1) && P4D_SAME_STRICT(&pt_projected, &p2) ) ||
+ ( (seg == 0) && P4D_SAME_STRICT(&pt_projected, &p1) ) )
{
return 1;
}
diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index c00fa027c..73a539235 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -33,12 +33,6 @@
#include "liblwgeom_topo_internal.h"
#include "lwgeom_geos.h"
-/* This is a non-tolerance based 2d equality for points
- * whereas the p2d_same function is tolerance based
- * TODO: move in higher headers ?
- */
-#define P2D_SAME_STRICT(a,b) ((a)->x == (b)->x && (a)->y == (b)->y)
-
/*********************************************************************
*
* Backend iface
-----------------------------------------------------------------------
Summary of changes:
liblwgeom/cunit/cu_split.c | 12 ++++++++++++
liblwgeom/liblwgeom_internal.h | 11 ++++++++++-
liblwgeom/lwgeom_geos_split.c | 10 +++++-----
liblwgeom/topo/lwgeom_topo.c | 6 ------
4 files changed, 27 insertions(+), 12 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list