[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 6a44fcb9885463754e60a05483099ab18d8bccfd
git at osgeo.org
git at osgeo.org
Thu Dec 12 08:02:06 PST 2019
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.0 has been updated
via 6a44fcb9885463754e60a05483099ab18d8bccfd (commit)
from f443a7cda1aa0bc4c8df71cb80784850704e1c86 (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 6a44fcb9885463754e60a05483099ab18d8bccfd
Author: Raúl Marín <git at rmr.ninja>
Date: Wed Dec 11 19:47:48 2019 +0100
LWGEOM_addpoint: Accept -1 as a valid position
References #4599
diff --git a/NEWS b/NEWS
index 0b9d466..f549ada 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ XXXX/XX/XX
- #4558, Fix oversimplification of polygon inner rings (Raúl Marín)
- #4588, Fix update when st_union(geometry) doesn't exist (Raúl Marín)
- #4590, Fix pg_upgrade issue with st_linecrossingdirection (Raúl Marín)
+ - #4599, ST_AddPoint: Accept -1 as a valid position (Raúl Marín)
PostGIS 3.0.0
diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c
index d3efd20..60363fb 100644
--- a/postgis/lwgeom_functions_basic.c
+++ b/postgis/lwgeom_functions_basic.c
@@ -2163,7 +2163,7 @@ Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
GSERIALIZED *pglwg1, *pglwg2, *result;
LWPOINT *point;
LWLINE *line, *linecopy;
- int32 where = -1;
+ uint32_t uwhere = 0;
POSTGIS_DEBUGF(2, "%s called.", __func__);
@@ -2184,26 +2184,29 @@ Datum LWGEOM_addpoint(PG_FUNCTION_ARGS)
line = lwgeom_as_lwline(lwgeom_from_gserialized(pglwg1));
- if (PG_NARGS() > 2)
+ if (PG_NARGS() <= 2)
{
- where = PG_GETARG_INT32(2);
+ uwhere = line->points->npoints;
}
else
{
- where = line->points->npoints;
- }
-
- if (where < 0 || where > (int32)line->points->npoints)
- {
- elog(ERROR, "Invalid offset");
- PG_RETURN_NULL();
+ int32 where = PG_GETARG_INT32(2);
+ if (where == -1)
+ {
+ uwhere = line->points->npoints;
+ }
+ else if (where < 0 || where > (int32)line->points->npoints)
+ {
+ elog(ERROR, "Invalid offset");
+ PG_RETURN_NULL();
+ }
}
point = lwgeom_as_lwpoint(lwgeom_from_gserialized(pglwg2));
linecopy = lwgeom_as_lwline(lwgeom_clone_deep(lwline_as_lwgeom(line)));
lwline_free(line);
- if (lwline_add_lwpoint(linecopy, point, (uint32_t)where) == LW_FAILURE)
+ if (lwline_add_lwpoint(linecopy, point, uwhere) == LW_FAILURE)
{
elog(ERROR, "Point insert failed");
PG_RETURN_NULL();
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index adb64fb..4e1b3e0 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1284,3 +1284,7 @@ union all
select '#4399', 'ST_GeoHash', ST_GeoHash(geom)::text from geom
union all
select '#4399', 'ST_AsGeoJSON', ST_AsGeoJSON(geom)::text from geom;
+
+SELECT '#4599-1', ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint(1, 2, 3)));
+SELECT '#4599-2', ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint(1, 2, 3), 0));
+SELECT '#4599-3', ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint(1, 2, 3), -1));
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index e821f1c..4b34ba7 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -424,3 +424,6 @@ ERROR: BOX2D_construct: args can not be empty points
#4399|ST_AsGeoJSON|{"type":"Polygon","coordinates":[[[0,0],[1,1],[0,1],[0,0]]]}
#4399|ST_AsGeoJSON|{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[0,0],[1,1],[0,1],[0,0]]]}]}
#4399|ST_AsGeoJSON|{"type":"Polygon","coordinates":[[]]}
+#4599-1|LINESTRING(0 0 1,1 1 1,1 2 3)
+#4599-2|LINESTRING(1 2 3,0 0 1,1 1 1)
+#4599-3|LINESTRING(0 0 1,1 1 1,1 2 3)
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
postgis/lwgeom_functions_basic.c | 25 ++++++++++++++-----------
regress/core/tickets.sql | 4 ++++
regress/core/tickets_expected | 3 +++
4 files changed, 22 insertions(+), 11 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list