[SCM] PostGIS branch master updated. 3.5.0-248-g0f5ece10b
git at osgeo.org
git at osgeo.org
Tue Apr 8 14:13:11 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, master has been updated
via 0f5ece10b2cd45da1ae8cd199ad94e9fdd062457 (commit)
from d917bc093916a5b38de525fb343b1f6573fb96ed (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 0f5ece10b2cd45da1ae8cd199ad94e9fdd062457
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Apr 8 14:12:26 2025 -0700
Don't skip the last point in doing
linestring substring for geography,
closes #5874
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:
liblwgeom/cunit/cu_geodetic.c | 48 +++++++++++++++++++++++++++++++++++++++++
liblwgeom/lwgeodetic_measures.c | 1 +
2 files changed, 49 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list