[SCM] PostGIS branch stable-3.5 updated. 3.5.2-15-gb5f353eb2
git at osgeo.org
git at osgeo.org
Tue Apr 8 14:14:35 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 b5f353eb264a11cf9eb63af5eed63ac47c2b4774 (commit)
from 9024a3732d942893e92f85e4986f05da8773fda5 (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 b5f353eb264a11cf9eb63af5eed63ac47c2b4774
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Apr 8 14:14:15 2025 -0700
Don't skip the last point in doing
linestring substring for geography,
References #5874
diff --git a/NEWS b/NEWS
index a8c35ebe8..9a0f46525 100644
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
- #5819, Support longer names in estimated extent (Paul Ramsey)
- Fix misassignment of result in _lwt_HealEdges (Maxim Korotkov)
- #5876, ST_AddPoint with empty argument adds garbage (Paul Ramsey)
-
+- #5874, Line substring returns wrong answer (Paul Ramsey)
PostGIS 3.5.2
diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c
index 4d5656b17..99651aa52 100644
--- a/liblwgeom/cunit/cu_geodetic.c
+++ b/liblwgeom/cunit/cu_geodetic.c
@@ -1594,6 +1594,53 @@ static void test_lwgeom_area_sphere(void)
}
+static void test_geography_substring(void)
+{
+ LWGEOM *lwg;
+ LWGEOM *result;
+ double length;
+ SPHEROID s;
+
+ /* Init to Sphere */
+ spheroid_init(&s, WGS84_RADIUS, WGS84_RADIUS);
+ s.a = s.b = s.radius;
+
+ /*
+ * geography_substring(
+ * const LWLINE *lwline,
+ * const SPHEROID *s,
+ * double from, double to, double tolerance
+ */
+
+ lwg = lwgeom_from_wkt("LINESTRING(2 48, 2 49, 2 50)", LW_PARSER_CHECK_NONE);
+ length = lwgeom_length(lwg);
+ CU_ASSERT_DOUBLE_EQUAL(length, 2.0, 0.001);
+ result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
+ length = lwgeom_length(result);
+ CU_ASSERT_DOUBLE_EQUAL(length, 2.0, 0.001);
+ lwgeom_free(lwg);
+ lwgeom_free(result);
+
+ lwg = lwgeom_from_wkt("LINESTRING(2 48, 2 49)", LW_PARSER_CHECK_NONE);
+ length = lwgeom_length(lwg);
+ CU_ASSERT_DOUBLE_EQUAL(length, 1.0, 0.001);
+ result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
+ length = lwgeom_length(result);
+ CU_ASSERT_DOUBLE_EQUAL(length, 1.0, 0.001);
+ lwgeom_free(lwg);
+ lwgeom_free(result);
+
+ lwg = lwgeom_from_wkt("LINESTRING(2 48)", LW_PARSER_CHECK_NONE);
+ length = lwgeom_length(lwg);
+ CU_ASSERT_DOUBLE_EQUAL(length, 0.0, 0.001);
+ result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
+ length = lwgeom_length(result);
+ CU_ASSERT_DOUBLE_EQUAL(length, 0.0, 0.001);
+ lwgeom_free(lwg);
+ lwgeom_free(result);
+}
+
+
static void test_gbox_to_string_truncated(void)
{
GBOX g = {
@@ -1682,4 +1729,5 @@ void geodetic_suite_setup(void)
PG_ADD_TEST(suite, test_ptarray_contains_point_sphere_iowa);
PG_ADD_TEST(suite, test_gbox_to_string_truncated);
PG_ADD_TEST(suite, test_gbox_geocentric_get_gbox_cartesian);
+ PG_ADD_TEST(suite, test_geography_substring);
}
diff --git a/liblwgeom/lwgeodetic_measures.c b/liblwgeom/lwgeodetic_measures.c
index 1bca0a795..8c2bca596 100644
--- a/liblwgeom/lwgeodetic_measures.c
+++ b/liblwgeom/lwgeodetic_measures.c
@@ -232,6 +232,7 @@ geography_substring(
END:
tlength += slength;
memcpy(&p1, &p2, sizeof(POINT4D));
+ geographic_point_init(p1.x, p1.y, &g1);
}
if (dpa->npoints <= 1) {
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 +-
liblwgeom/cunit/cu_geodetic.c | 48 +++++++++++++++++++++++++++++++++++++++++
liblwgeom/lwgeodetic_measures.c | 1 +
3 files changed, 50 insertions(+), 1 deletion(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list