[SCM] PostGIS branch master updated. 3.6.0rc2-510-g38faa8d51
git at osgeo.org
git at osgeo.org
Tue Jun 9 15:51:32 PDT 2026
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 38faa8d5146b32dbc71a99e64208fd23719999e8 (commit)
from bbbe84257be29b0101088e5da69677924f65cdd0 (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 38faa8d5146b32dbc71a99e64208fd23719999e8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 9 22:38:17 2026 +0000
Fix ST_LineFromEncodedPolyline dropping close points
Use int32_t accumulators instead of double.
Closes #5357
diff --git a/liblwgeom/cunit/cu_in_encoded_polyline.c b/liblwgeom/cunit/cu_in_encoded_polyline.c
index f76b726f9..6af16b9a2 100644
--- a/liblwgeom/cunit/cu_in_encoded_polyline.c
+++ b/liblwgeom/cunit/cu_in_encoded_polyline.c
@@ -53,6 +53,15 @@ static void in_encoded_polyline_test_precision(void)
"SRID=4326;LINESTRING(-0.250691 49.283048,-0.250633 49.283376,-0.250502 49.283972,-0.251245 49.284028,-0.251938 49.284232,-0.251938 49.2842)");
}
+static void in_encoded_polyline_test_close_points(void)
+{
+ /* #5357: two close points must not collapse to one */
+ do_encoded_polyline_test(
+ "__nphBgcoeiA?@",
+ 6,
+ "SRID=4326;LINESTRING(38.903876 55.336448,38.903875 55.336448)");
+}
+
/*
** Used by test harness to register the tests in this file.
*/
@@ -62,4 +71,5 @@ void in_encoded_polyline_suite_setup(void)
CU_pSuite suite = CU_add_suite("encoded_polyline_input", NULL, NULL);
PG_ADD_TEST(suite, in_encoded_polyline_test_geoms);
PG_ADD_TEST(suite, in_encoded_polyline_test_precision);
+ PG_ADD_TEST(suite, in_encoded_polyline_test_close_points);
}
diff --git a/liblwgeom/lwin_encoded_polyline.c b/liblwgeom/lwin_encoded_polyline.c
index 7212314a6..2bb9f7341 100644
--- a/liblwgeom/lwin_encoded_polyline.c
+++ b/liblwgeom/lwin_encoded_polyline.c
@@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include <math.h>
+#include <stdint.h>
#include "liblwgeom.h"
#include "../postgis_config.h"
@@ -39,8 +40,8 @@ lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
int idx = 0;
double scale = pow(10,precision);
- float latitude = 0.0f;
- float longitude = 0.0f;
+ int32_t latitude = 0;
+ int32_t longitude = 0;
pa = ptarray_construct_empty(LW_FALSE, LW_FALSE, 1);
@@ -55,7 +56,7 @@ lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
res |= (byte & 0x1F) << shift;
shift += 5;
} while (byte >= 0x20);
- float deltaLat = ((res & 1) ? ~(res >> 1) : (res >> 1));
+ int32_t deltaLat = ((res & 1) ? ~(res >> 1) : (res >> 1));
latitude += deltaLat;
shift = 0;
@@ -65,7 +66,7 @@ lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
res |= (byte & 0x1F) << shift;
shift += 5;
} while (byte >= 0x20);
- float deltaLon = ((res & 1) ? ~(res >> 1) : (res >> 1));
+ int32_t deltaLon = ((res & 1) ? ~(res >> 1) : (res >> 1));
longitude += deltaLon;
pt.x = longitude/scale;
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index 1dd8f2e98..7da7f4c1f 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1641,3 +1641,6 @@ INSERT INTO fault6028 (fid, geom)
SELECT * FROM fault6028;
DROP TABLE IF EXISTS fault6028;
+-- #5357
+SELECT '#5357', ST_AsText(ST_LineFromEncodedPolyline('__nphBgcoeiA?@', 6), 6);
+
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index c6185f24e..dcdffa995 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -498,3 +498,4 @@ public|test5978|shape|2|4326|POINT
#5938|1FF00F212|t
#5938|1FF00F212|t
1|01030000209713000000000000
+#5357|LINESTRING(38.903876 55.336448,38.903875 55.336448)
-----------------------------------------------------------------------
Summary of changes:
liblwgeom/cunit/cu_in_encoded_polyline.c | 10 ++++++++++
liblwgeom/lwin_encoded_polyline.c | 9 +++++----
regress/core/tickets.sql | 3 +++
regress/core/tickets_expected | 1 +
4 files changed, 19 insertions(+), 4 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list