[SCM] PostGIS branch stable-3.4 updated. 3.4.4-7-ga10ca1a92
git at osgeo.org
git at osgeo.org
Tue Apr 8 14:16: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.4 has been updated
via a10ca1a92d02c3334f4a0fc8a88de07a4c66c768 (commit)
from 5932f54a0bbcca89b805a75f45c4f4805ea734ac (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 a10ca1a92d02c3334f4a0fc8a88de07a4c66c768
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Apr 8 14:16:16 2025 -0700
Don't skip the last point in doing
linestring substring for geography,
references #5874
diff --git a/NEWS b/NEWS
index e46da072c..71e53f677 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Proj 6.1+ required.
- #5564, BRIN crash fix and support for parallel in PG17+
(Paul Ramsey, Regina Obe)
- #5876, Fix ST_AddPoint with empty point argument
+ - #5874, Line substring returns wrong answer (Paul Ramsey)
PostGIS 3.4.4
diff --git a/liblwgeom/cunit/cu_geodetic.c b/liblwgeom/cunit/cu_geodetic.c
index 98d598e67..ae72e18d6 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 = {
@@ -1616,6 +1663,10 @@ static void test_gbox_to_string_truncated(void)
lwfree(c);
}
+
+
+
+
/*
** Used by test harness to register the tests in this file.
*/
@@ -1646,4 +1697,5 @@ void geodetic_suite_setup(void)
PG_ADD_TEST(suite, test_ptarray_contains_point_sphere);
PG_ADD_TEST(suite, test_ptarray_contains_point_sphere_iowa);
PG_ADD_TEST(suite, test_gbox_to_string_truncated);
+ 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 | 1 +
liblwgeom/cunit/cu_geodetic.c | 52 +++++++++++++++++++++++++++++++++++++++++
liblwgeom/lwgeodetic_measures.c | 1 +
3 files changed, 54 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list