[postgis-tickets] [SCM] PostGIS branch stable-2.5 updated. 2.5.5-9-g586f636
git at osgeo.org
git at osgeo.org
Fri Mar 5 04:16:38 PST 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, stable-2.5 has been updated
via 586f6367ee850c7963f2c492769d68b7e8596ae0 (commit)
from e9b9d34339515882ae4927ead8e44539438950e6 (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 586f6367ee850c7963f2c492769d68b7e8596ae0
Author: Sandro Santilli <strk at kbt.io>
Date: Fri Mar 5 12:04:39 2021 +0100
Fix SRID in Geometry(TopoGeometry) for empty TopoGeometry objects
Includes testcase.
References #4871 in 2.6 branch (2.5.6dev)
diff --git a/NEWS b/NEWS
index 18ddb5f..b5a0fc3 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ YYYY/MM/DD
* Bug fixes *
+ - #4871, TopoGeometry::geometry cast returns NULL for empty
+ TopoGeometry objects (Sandro Santilli)
- #4757, Handle line collapse due to snap-to-existing node (Sandro Santilli)
- #4769, Fix segfault in st_addband (Raúl Marín)
- #4863, Update bboxes after affine/scale operations (Paul Ramsey)
diff --git a/topology/test/Makefile.in b/topology/test/Makefile.in
index b62c063..4ce2077 100644
--- a/topology/test/Makefile.in
+++ b/topology/test/Makefile.in
@@ -63,6 +63,7 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \
regress/createtopogeom.sql \
regress/createtopology.sql \
regress/gml.sql \
+ regress/geometry_cast.sql \
regress/getnodebypoint.sql \
regress/getedgebypoint.sql \
regress/getfacebypoint.sql \
diff --git a/topology/test/regress/geometry_cast.sql b/topology/test/regress/geometry_cast.sql
new file mode 100644
index 0000000..7e576ce
--- /dev/null
+++ b/topology/test/regress/geometry_cast.sql
@@ -0,0 +1,55 @@
+\set VERBOSITY terse
+set client_min_messages to WARNING;
+
+INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text )
+VALUES ( 'EPSG', 990000, 990000, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
+
+select NULL FROM createtopology('tt', 990000);
+
+-- layer 1 is PUNTUAL
+CREATE TABLE tt.f_point(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_point', 'g', 'POINT');
+
+-- layer 2 is LINEAL
+CREATE TABLE tt.f_line(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_line', 'g', 'LINE');
+
+-- layer 3 is AREAL
+CREATE TABLE tt.f_area(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_area', 'g', 'POLYGON');
+
+-- layer 4 is MIXED
+CREATE TABLE tt.f_coll(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_coll', 'g', 'COLLECTION');
+
+-- layer 5 is HIERARCHICAL PUNTUAL
+CREATE TABLE tt.f_hier_point(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_hier_point', 'g', 'POINT', 1);
+
+-- layer 6 is HIERARCHICAL LINEAL
+CREATE TABLE tt.f_hier_line(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_hier_line', 'g', 'LINE', 2);
+
+-- layer 7 is HIERARCHICAL AREAL
+CREATE TABLE tt.f_hier_area(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_hier_area', 'g', 'POLYGON', 3);
+
+-- layer 8 is HIERARCHICAL MIXED
+CREATE TABLE tt.f_hier_coll(id serial);
+SELECT NULL FROM AddTopoGeometryColumn('tt', 'tt', 'f_hier_coll', 'g', 'COLLECTION', 4);
+
+
+-- Cast empties
+SELECT 'empty', 'puntal', ST_AsEWKT(CreateTopoGeom('tt', 1, 1)::geometry);
+SELECT 'empty', 'lineal', ST_AsEWKT(CreateTopoGeom('tt', 2, 2)::geometry);
+SELECT 'empty', 'areal', ST_AsEWKT(CreateTopoGeom('tt', 3, 3)::geometry);
+SELECT 'empty', 'mixed', ST_AsEWKT(CreateTopoGeom('tt', 4, 4)::geometry);
+
+SELECT 'empty', 'hier', 'puntal', ST_AsEWKT(CreateTopoGeom('tt', 1, 5)::geometry);
+SELECT 'empty', 'hier', 'lineal', ST_AsEWKT(CreateTopoGeom('tt', 2, 6)::geometry);
+SELECT 'empty', 'hier', 'areal', ST_AsEWKT(CreateTopoGeom('tt', 3, 7)::geometry);
+SELECT 'empty', 'hier', 'mixed', ST_AsEWKT(CreateTopoGeom('tt', 4, 8)::geometry);
+
+-- Cleanup
+SELECT NULL FROM DropTopology('tt');
+DELETE FROM spatial_ref_sys where srid = 990000;
diff --git a/topology/test/regress/geometry_cast_expected b/topology/test/regress/geometry_cast_expected
new file mode 100644
index 0000000..53b0db8
--- /dev/null
+++ b/topology/test/regress/geometry_cast_expected
@@ -0,0 +1,8 @@
+empty|puntal|SRID=990000;MULTIPOINT EMPTY
+empty|lineal|SRID=990000;MULTILINESTRING EMPTY
+empty|areal|SRID=990000;MULTIPOLYGON EMPTY
+empty|mixed|SRID=990000;GEOMETRYCOLLECTION EMPTY
+empty|hier|puntal|SRID=990000;MULTIPOINT EMPTY
+empty|hier|lineal|SRID=990000;MULTILINESTRING EMPTY
+empty|hier|areal|SRID=990000;MULTIPOLYGON EMPTY
+empty|hier|mixed|SRID=990000;GEOMETRYCOLLECTION EMPTY
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 839bd90..4b57afd 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1233,6 +1233,7 @@ CREATE OR REPLACE FUNCTION topology.Geometry(topogeom topology.TopoGeometry)
AS $$
DECLARE
toponame varchar;
+ toposrid int;
geom geometry;
rec RECORD;
plyr RECORD;
@@ -1241,9 +1242,9 @@ DECLARE
BEGIN
-- Get topology name
- SELECT name FROM topology.topology
+ SELECT name, srid FROM topology.topology
WHERE id = topogeom.topology_id
- INTO toponame;
+ INTO toponame, toposrid;
IF toponame IS NULL THEN
RAISE EXCEPTION 'Invalid TopoGeometry (unexistent topology id %)', topogeom.topology_id;
END IF;
@@ -1372,6 +1373,7 @@ BEGIN
ELSE
geom := 'GEOMETRYCOLLECTION EMPTY';
END IF;
+ geom := ST_SetSRID(geom, toposrid);
END IF;
RETURN geom;
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 +
topology/test/Makefile.in | 1 +
topology/test/regress/geometry_cast.sql | 55 ++++++++++++++++++++++++++++
topology/test/regress/geometry_cast_expected | 8 ++++
topology/topology.sql.in | 6 ++-
5 files changed, 70 insertions(+), 2 deletions(-)
create mode 100644 topology/test/regress/geometry_cast.sql
create mode 100644 topology/test/regress/geometry_cast_expected
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list