[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-420-gffd29fe

git at osgeo.org git at osgeo.org
Tue Aug 24 12:35:53 PDT 2021


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  ffd29fedecd3fa771443308e1a6d98c3a18f6f2b (commit)
       via  0571210d7f4526bedf97fdcff065073f6e1ab5ab (commit)
      from  7a4f76ddfc74e9f9af468a710103e1ce08a6cda9 (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 ffd29fedecd3fa771443308e1a6d98c3a18f6f2b
Author: Regina Obe <lr at pcorp.us>
Date:   Tue Aug 24 15:34:19 2021 -0400

    ST_StartPoint support any geometry  Closes #4981
    Closes https://github.com/postgis/postgis/pull/628

diff --git a/NEWS b/NEWS
index e9eafe3..0fc2364 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PostGIS 3.2.0
  * Breaking changes *
   - #4824, Removed `--without-wagyu` build option. Using Wagyu is now mandatory to build with MVT support.
   - #4933, topology.GetFaceByPoint will not work with topologies having invalid edge linking.
+  - #4981, ST_StartPoint support any geometry. No longer returns null for non-linestrings.
 
  * Enhancements *
   - #2592, Do not allow CreateTopology to define topologies with SRID < 0
@@ -44,6 +45,8 @@ PostGIS 3.2.0
   - #4974, Upgrade path for address_standardizer_data_us
     (Jan Katins of Aiven, Regina Obe)
   - #4975, PostGIS upgrade change to not use temp tables (Jan Katins of Aiven)
+  - #4981, ST_StartPoint support any geometry (Aliaksandr Kalenik)
+
 
  * New features*
   - #4923, topology.ValidateTopologyRelation (Sandro Santilli)
diff --git a/doc/reference_accessor.xml b/doc/reference_accessor.xml
index 8d23ce1..4838163 100644
--- a/doc/reference_accessor.xml
+++ b/doc/reference_accessor.xml
@@ -2749,11 +2749,15 @@ MULTIPOINT Z (30 10 4,10 30 5,40 40 6, 30 10 4)
 	  <para>&Z_support;</para>
 	  <para>&curve_support;</para>
 
-	  <note><para>Changed: 2.0.0 no longer works with single geometry MultiLineStrings.  In older
+	  <note>
+        <para>Enhanced: 3.2.0 returns a point for all geometries. Prior behavior returns NULLs if input was not a LineString.</para>
+      <para>Changed: 2.0.0 no longer works with single geometry MultiLineStrings.  In older
 	  versions of PostGIS a single-line MultiLineString would work happily with this
 	  function and return the start point.  In 2.0.0 it just returns NULL like any other MultiLineString.
 	  The old behavior was an undocumented feature, but people who assumed they had their data stored as LINESTRING
-	  may experience these returning NULL in 2.0.0.</para></note>
+	  may experience these returning NULL in 2.0.0.</para>
+
+      </note>
 
 	</refsection>
 

commit 0571210d7f4526bedf97fdcff065073f6e1ab5ab
Author: kalenikaliaksandr <kalenik.aliaksandr at gmail.com>
Date:   Mon Aug 23 15:46:24 2021 +0300

    ST_StartPoint support any geometry

diff --git a/liblwgeom/cunit/cu_misc.c b/liblwgeom/cunit/cu_misc.c
index 5518077..ccd0e4b 100644
--- a/liblwgeom/cunit/cu_misc.c
+++ b/liblwgeom/cunit/cu_misc.c
@@ -51,6 +51,36 @@ static void test_misc_simplify(void)
 	lwfree(wkt_out);
 }
 
+static void test_misc_startpoint(void)
+{
+	LWGEOM *geom;
+	POINT4D p = {0};
+
+	geom = lwgeom_from_wkt("POINT(1 2)", LW_PARSER_CHECK_NONE);
+	CU_ASSERT(lwgeom_startpoint(geom, &p) == LW_SUCCESS);
+	CU_ASSERT_EQUAL(p.x, 1);
+	CU_ASSERT_EQUAL(p.y, 2);
+	lwgeom_free(geom);
+
+	geom = lwgeom_from_wkt("LINESTRING(10 20, 30 40)", LW_PARSER_CHECK_NONE);
+	CU_ASSERT(lwgeom_startpoint(geom, &p) == LW_SUCCESS);
+	CU_ASSERT_EQUAL(p.x, 10);
+	CU_ASSERT_EQUAL(p.y, 20);
+	lwgeom_free(geom);
+
+	geom = lwgeom_from_wkt("POLYGON((1 2, 3 4, 5 6, 1 2))", LW_PARSER_CHECK_NONE);
+	CU_ASSERT(lwgeom_startpoint(geom, &p) == LW_SUCCESS);
+	CU_ASSERT_EQUAL(p.x, 1);
+	CU_ASSERT_EQUAL(p.y, 2);
+	lwgeom_free(geom);
+
+	geom = lwgeom_from_wkt("GEOMETRYCOLLECTION(LINESTRING(100 200, 300 400), POINT(10 20))", LW_PARSER_CHECK_NONE);
+	CU_ASSERT(lwgeom_startpoint(geom, &p) == LW_SUCCESS);
+	CU_ASSERT_EQUAL(p.x, 100);
+	CU_ASSERT_EQUAL(p.y, 200);
+	lwgeom_free(geom);
+}
+
 static void test_misc_count_vertices(void)
 {
 	LWGEOM *geom;
@@ -315,6 +345,7 @@ void misc_suite_setup(void)
 {
 	CU_pSuite suite = CU_add_suite("miscellaneous", NULL, NULL);
 	PG_ADD_TEST(suite, test_misc_simplify);
+	PG_ADD_TEST(suite, test_misc_startpoint);
 	PG_ADD_TEST(suite, test_misc_count_vertices);
 	PG_ADD_TEST(suite, test_misc_area);
 	PG_ADD_TEST(suite, test_misc_wkb);
diff --git a/postgis/lwgeom_ogc.c b/postgis/lwgeom_ogc.c
index e1745e2..5830345 100644
--- a/postgis/lwgeom_ogc.c
+++ b/postgis/lwgeom_ogc.c
@@ -681,33 +681,31 @@ Datum LWGEOM_m_point(PG_FUNCTION_ARGS)
 
 /**
 * ST_StartPoint(GEOMETRY)
-* @return the first point of a linestring.
-* 		Return NULL if there is no LINESTRING
+* @return the first point of a geometry.
 */
 PG_FUNCTION_INFO_V1(LWGEOM_startpoint_linestring);
 Datum LWGEOM_startpoint_linestring(PG_FUNCTION_ARGS)
 {
 	GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
+	GSERIALIZED *ret;
 	LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
-	LWPOINT *lwpoint = NULL;
-	int type = lwgeom->type;
+	LWGEOM *lwpoint = NULL;
+	POINT4D pt;
 
-	if ( type == LINETYPE || type == CIRCSTRINGTYPE )
-	{
-		lwpoint = lwline_get_lwpoint((LWLINE*)lwgeom, 0);
-	}
-	else if ( type == COMPOUNDTYPE )
+	if (lwgeom_startpoint(lwgeom, &pt) == LW_FAILURE)
 	{
-		lwpoint = lwcompound_get_startpoint((LWCOMPOUND*)lwgeom);
+		PG_RETURN_NULL();
 	}
 
-	lwgeom_free(lwgeom);
 	PG_FREE_IF_COPY(geom, 0);
 
-	if ( ! lwpoint )
-		PG_RETURN_NULL();
+	lwpoint = (LWGEOM *)lwpoint_make(lwgeom->srid, lwgeom_has_z(lwgeom), lwgeom_has_m(lwgeom), &pt);
+	ret = geometry_serialize(lwpoint);
 
-	PG_RETURN_POINTER(geometry_serialize(lwpoint_as_lwgeom(lwpoint)));
+	lwgeom_free(lwgeom);
+	lwgeom_free(lwpoint);
+
+	PG_RETURN_POINTER(ret);
 }
 
 /** EndPoint(GEOMETRY) -- find the first linestring in GEOMETRY,
diff --git a/regress/core/regress_ogc.sql b/regress/core/regress_ogc.sql
index 12f5e56..64c8374 100644
--- a/regress/core/regress_ogc.sql
+++ b/regress/core/regress_ogc.sql
@@ -209,3 +209,8 @@ select 'ST_StartPoint2',ST_AsText(ST_StartPoint('CIRCULARSTRING(2 2, 1 1, 1 0)':
 select 'ST_StartPoint3',ST_AsText(ST_StartPoint('COMPOUNDCURVE(CIRCULARSTRING(3 3, 1 1, 1 0),(1 0, 0 1))'::geometry));
 select 'ST_StartPoint4',ST_AsText(ST_StartPoint('CURVEPOLYGON(CIRCULARSTRING(5 5, 4 0, 4 4, 0 4, 5 5),(1 1, 3 3, 3 1, 1 1))'::geometry));
 select 'ST_StartPoint5',ST_AsText(ST_StartPoint('POLYGON((0 0, 1 1, 0 1, 0 0))'::geometry));
+select 'ST_StartPoint6',ST_AsText(ST_StartPoint('POINT(1 1)'::geometry));
+select 'ST_StartPoint7',ST_AsText(ST_StartPoint('MULTIPOINT(1 1, 2 2)'::geometry));
+select 'ST_StartPoint8',ST_AsText(ST_StartPoint('MULTIPOLYGON(((1 1, 2 2, 3 3, 1 1)))'::geometry));
+select 'ST_StartPoint9',ST_AsText(ST_StartPoint('MULTILINESTRING((1 1, 2 2), (3 3, 4 4))'::geometry));
+select 'ST_StartPoint10',ST_AsText(ST_StartPoint('GEOMETRYCOLLECTION(POINT(1 2), LINESTRING(3 4, 5 6))'::geometry));
diff --git a/regress/core/regress_ogc_expected b/regress/core/regress_ogc_expected
index c574735..71e4078 100644
--- a/regress/core/regress_ogc_expected
+++ b/regress/core/regress_ogc_expected
@@ -122,5 +122,10 @@ ST_Buffer(empty)|POLYGON EMPTY
 ST_StartPoint1|POINT(0 0)
 ST_StartPoint2|POINT(2 2)
 ST_StartPoint3|POINT(3 3)
-ST_StartPoint4|
-ST_StartPoint5|
+ST_StartPoint4|POINT(5 5)
+ST_StartPoint5|POINT(0 0)
+ST_StartPoint6|POINT(1 1)
+ST_StartPoint7|POINT(1 1)
+ST_StartPoint8|POINT(1 1)
+ST_StartPoint9|POINT(1 1)
+ST_StartPoint10|POINT(1 2)
diff --git a/regress/core/sql-mm-curvepoly.sql b/regress/core/sql-mm-curvepoly.sql
index 78ffac3..4e4bce6 100644
--- a/regress/core/sql-mm-curvepoly.sql
+++ b/regress/core/sql-mm-curvepoly.sql
@@ -245,10 +245,10 @@ SELECT 'envelope02', ST_AsText(ST_snapToGrid(ST_envelope(the_geom_3dm), 'POINT(0
 SELECT 'envelope03', ST_AsText(ST_snapToGrid(ST_envelope(the_geom_3dz), 'POINT(0 0 0 0)'::geometry, 1e-8, 1e-8, 1e-8, 1e-8)) FROM public.curvepolygon;
 SELECT 'envelope04', ST_AsText(ST_snapToGrid(ST_envelope(the_geom_4d), 'POINT(0 0 0 0)'::geometry, 1e-8, 1e-8, 1e-8, 1e-8)) FROM public.curvepolygon;
 
-SELECT 'startPoint01', (ST_startPoint(the_geom_2d) is null) FROM public.curvepolygon;
-SELECT 'startPoint02', (ST_startPoint(the_geom_3dm) is null) FROM public.curvepolygon;
-SELECT 'startPoint03', (ST_startPoint(the_geom_3dz) is null) FROM public.curvepolygon;
-SELECT 'startPoint04', (ST_startPoint(the_geom_4d) is null) FROM public.curvepolygon;
+SELECT 'startPoint01', ST_AsText(ST_startPoint(the_geom_2d)) FROM public.curvepolygon;
+SELECT 'startPoint02', ST_AsText(ST_startPoint(the_geom_3dm)) FROM public.curvepolygon;
+SELECT 'startPoint03', ST_AsText(ST_startPoint(the_geom_3dz)) FROM public.curvepolygon;
+SELECT 'startPoint04', ST_AsText(ST_startPoint(the_geom_4d)) FROM public.curvepolygon;
 
 SELECT 'endPoint01', (ST_endPoint(the_geom_2d) is null) FROM public.curvepolygon;
 SELECT 'endPoint02', (ST_endPoint(the_geom_3dm) is null) FROM public.curvepolygon;
diff --git a/regress/core/sql-mm-curvepoly_expected b/regress/core/sql-mm-curvepoly_expected
index 1adea83..cea550e 100644
--- a/regress/core/sql-mm-curvepoly_expected
+++ b/regress/core/sql-mm-curvepoly_expected
@@ -51,10 +51,10 @@ envelope01|POLYGON((-2 -1,-2 2,2 2,2 -1,-2 -1))
 envelope02|POLYGON((-2 -1,-2 2,2 2,2 -1,-2 -1))
 envelope03|POLYGON((-2 -1,-2 2,2 2,2 -1,-2 -1))
 envelope04|POLYGON((-2 -1,-2 2,2 2,2 -1,-2 -1))
-startPoint01|t
-startPoint02|t
-startPoint03|t
-startPoint04|t
+startPoint01|POINT(-2 0)
+startPoint02|POINT M (-2 0 0)
+startPoint03|POINT Z (-2 0 0)
+startPoint04|POINT ZM (-2 0 0 0)
 endPoint01|t
 endPoint02|t
 endPoint03|t

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

Summary of changes:
 NEWS                                   |  3 +++
 doc/reference_accessor.xml             |  8 ++++++--
 liblwgeom/cunit/cu_misc.c              | 31 +++++++++++++++++++++++++++++++
 postgis/lwgeom_ogc.c                   | 26 ++++++++++++--------------
 regress/core/regress_ogc.sql           |  5 +++++
 regress/core/regress_ogc_expected      |  9 +++++++--
 regress/core/sql-mm-curvepoly.sql      |  8 ++++----
 regress/core/sql-mm-curvepoly_expected |  8 ++++----
 8 files changed, 72 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list