[postgis-tickets] [SCM] PostGIS branch stable-2.4 updated. 2.4.9-4-gce413e1
git at osgeo.org
git at osgeo.org
Fri Mar 5 04:16:55 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.4 has been updated
via ce413e1b8992fcaea5b32a394c4d8b1056479dad (commit)
from e4c7a1fa4181a271285a80385e585485354ce99f (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 ce413e1b8992fcaea5b32a394c4d8b1056479dad
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.
Closes #4871 in 2.4 branch (2.4.10dev)
diff --git a/NEWS b/NEWS
index e6b96b3..a77e530 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ YYYY/MM/DD
* Bug Fixes and Enhancements *
+ - #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)
diff --git a/topology/test/Makefile.in b/topology/test/Makefile.in
index 604f94a..5e8c15a 100644
--- a/topology/test/Makefile.in
+++ b/topology/test/Makefile.in
@@ -4,7 +4,7 @@ PSQL=psql
PERL=@PERL@
GEOS_NUMERIC_VERSION=@GEOS_NUMERIC_VERSION@
-all:
+all:
@echo "Use 'make check' to run all tests"
# TODO: make edit_topology.sql into a proper test
@@ -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 \
@@ -79,7 +80,7 @@ ifeq ($(shell expr $(GEOS_NUMERIC_VERSION) ">" 30308),1)
else
cp regress/topogeo_addlinestring_expected_oldsnap regress/topogeo_addlinestring_expected
endif
-
+
check: topo_predicates.sql load_topology.sql load_topology-4326.sql $(TESTS) $(TESTS_EXPECTED)
$(MAKE) -C ../../regress staged-install
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 5eb1148..161611a 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1238,13 +1238,14 @@ LANGUAGE 'plpgsql' STABLE STRICT;
-- Geometry(TopoGeometry)
--
-- Construct a Geometry from a TopoGeometry.
---
+--
-- }{
CREATE OR REPLACE FUNCTION topology.Geometry(topogeom topology.TopoGeometry)
RETURNS Geometry
AS $$
DECLARE
toponame varchar;
+ toposrid int;
geom geometry;
rec RECORD;
plyr RECORD;
@@ -1253,9 +1254,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;
@@ -1384,6 +1385,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 | 5 ++-
topology/test/regress/geometry_cast.sql | 55 ++++++++++++++++++++++++++++
topology/test/regress/geometry_cast_expected | 8 ++++
topology/topology.sql.in | 8 ++--
5 files changed, 73 insertions(+), 5 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