[SCM] PostGIS branch stable-3.5 updated. 3.5.3-51-gfdcbc2e0e

git at osgeo.org git at osgeo.org
Tue Sep 9 08:46:16 PDT 2025


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.5 has been updated
       via  fdcbc2e0ea8865874840697b360491a64843dd5c (commit)
       via  6974c35e12d92eded39652638b3e2ca0d0c20352 (commit)
      from  dc7cf169b3d1bb6d018d99cd0322be2b10f5098b (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 fdcbc2e0ea8865874840697b360491a64843dd5c
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Sep 9 08:46:10 2025 -0700

    News item for #5082

diff --git a/NEWS b/NEWS
index 210fceaa8..ee50dd212 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
 - #5902, ST_PointFromText cannot create geometries with M (Paul Ramsey)
 - #5943, Memory leak in handling GEOS GeometryFactory (Megan Ma)
 - #5407, Use memset in place of bzero (Paul Ramsey)
+- #5082, LRS proportions clamped to [0,1] (Pawel Ostrowski)
 
 
 PostGIS 3.5.3

commit 6974c35e12d92eded39652638b3e2ca0d0c20352
Author: postrowski <pawel.ostrowski at softelnet.pl>
Date:   Tue Sep 9 08:43:24 2025 -0700

    clamp [0,1] when float arithmetic is used in locate_point functions (!265)
    
    Fix ticket #5082
    
    There are functions that promise to return values from range [0, 1], but due to floating point arithmetic, the return value sometimes may jump outside that range.
    This is problematic in SQL when many functions are composed and the return value exceed 1.
    Adding simple `if` conditions solves the problem.
    
    Reviewed-on: https://gitea.osgeo.org/postgis/postgis/pulls/265
    Reviewed-by: Laurențiu Nicola <lnicola at dend.ro>
    Co-authored-by: postrowski <pawel.ostrowski at softelnet.pl>
    Co-committed-by: postrowski <pawel.ostrowski at softelnet.pl>

diff --git a/liblwgeom/lwgeodetic_measures.c b/liblwgeom/lwgeodetic_measures.c
index 8c2bca596..27f57ecdb 100644
--- a/liblwgeom/lwgeodetic_measures.c
+++ b/liblwgeom/lwgeodetic_measures.c
@@ -548,7 +548,14 @@ ptarray_locate_point_spheroid(
 	if ( (seg >= (pa->npoints-2)) && p2d_same(&proj, p) )
 		return 1.0;
 
-	return partlength / totlength;
+	/* Floating point arithmetic is not reliable, make sure we return values [0,1] */
+	double result = partlength / totlength;
+	if ( result < 0.0 ) {
+		result = 0.0;
+	} else if ( result > 1.0 ) {
+		result = 1.0;
+	}
+	return result;
 }
 
 /*****************************************************************************/
diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c
index 7d17775cf..905083da0 100644
--- a/liblwgeom/ptarray.c
+++ b/liblwgeom/ptarray.c
@@ -1486,7 +1486,14 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou
 
 	LWDEBUGF(3, "plen %g, tlen %g", plen, tlen);
 
-	return plen/tlen;
+	/* Floating point arithmetic is not reliable, make sure we return values [0,1] */
+	double result = plen / tlen;
+	if ( result < 0.0 ) {
+		result = 0.0;
+	} else if ( result > 1.0 ) {
+		result = 1.0;
+	}
+	return result;
 }
 
 /**
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index da041a517..db5741fee 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1562,6 +1562,14 @@ SELECT '#5876', ST_AsText(ST_AddPoint(
 		'LINESTRING (1 1, 2 2)'::geometry,
 		'POINT EMPTY'::geometry), 2);
 
+
+-- https://trac.osgeo.org/postgis/ticket/5082 st_linelocatepoint returns value over 1
+select '#5082', ST_LineLocatePoint(
+	'LINESTRING (614506.766313283 390577.5124384557, 614494.089082674 390574.5586551775, 614494.8569439995 390562.1301508558, 614493.5246928157 390549.7664042029, 614486.5713433414 390544.32637928444, 614487.6296766759 390492.9548792321, 614487.6296766759 390492.9548792321)'::geometry,
+	'POINT (614487.6296766759 390492.9548792321)'::geometry
+	) <= 1.0;
+
+
 -- -------------------------------------------------------------------------------------
 -- #5978, geometry_columns not showing right SRID and Type
 -- #5829, SELECT geometry_columns returns unexpected error
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index 15065d870..bfebd9a86 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -482,6 +482,7 @@ ERROR:  Geometry contains invalid coordinates
 #5686|0
 #5747|0
 #5876|LINESTRING(1 1,2 2)
+#5082|t
 public.test5978.shape SRID:4326 TYPE:POINT DIMS:2 
 public.test5978.geometry SRID:4326 TYPE:POINT DIMS:2 
 public|test5829|geom|2|4326|GEOMETRY

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

Summary of changes:
 NEWS                            | 1 +
 liblwgeom/lwgeodetic_measures.c | 9 ++++++++-
 liblwgeom/ptarray.c             | 9 ++++++++-
 regress/core/tickets.sql        | 8 ++++++++
 regress/core/tickets_expected   | 1 +
 5 files changed, 26 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list