]> granicus.if.org Git - postgis/commitdiff
Fix ST_Simplify(TopoGeometry) for hierarchical topogeoms (#2547)
authorSandro Santilli <strk@keybit.net>
Thu, 21 Nov 2013 17:19:11 +0000 (17:19 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 21 Nov 2013 17:19:11 +0000 (17:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12137 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/topogeometry/simplify.sql.in
topology/test/regress/st_simplify.sql
topology/test/regress/st_simplify_expected

index 9604310452f91b48185b944d6f24cbafc339f1a5..11529fd99b29edbebef0ddffd5433fc361659340 100644 (file)
@@ -63,7 +63,7 @@ BEGIN
 
     sql := 'SELECT st_multi(st_union(topology.ST_Simplify('
       || quote_ident(child_layer_info.feature_column)
-      || '))) as geom FROM '
+      || ',' || tolerance || '))) as geom FROM '
       || quote_ident(child_layer_info.schema_name) || '.'
       || quote_ident(child_layer_info.table_name)
       || ', ' || quote_ident(topology_info.name) || '.relation pr'
index 0497b59664570b0b7bc920aef4846cdca61d5481..f13a62709373a9dce37f4c274d33f2d99aa67f8b 100644 (file)
@@ -1,10 +1,12 @@
 set client_min_messages to WARNING;
 
-SELECT CreateTopology('tt') > 1;
+SELECT CreateTopology('tt') > 0;
 CREATE TABLE tt.areas(id serial, g geometry);
 INSERT INTO tt.areas(g) VALUES ('POLYGON((0 0,1 1,1 3,0 4,-2 3,-1 1,0 0))'),
                                ('POLYGON((0 0,1 1,1 3,2 3,2 0,0 0))');
-SELECT 'L' || AddTopoGeometryColumn('tt', 'tt', 'areas', 'tg', 'polygon');
+CREATE TEMP TABLE _test_layers AS SELECT 1 as id,
+  AddTopoGeometryColumn('tt', 'tt', 'areas', 'tg', 'polygon') as layer_id;
+SELECT 'L' || layer_id FROM _test_layers WHERE id = 1;
 UPDATE tt.areas SET tg = toTopoGeom(g, 'tt', 1);
 
 -- ensures this point won't be removed
@@ -20,4 +22,30 @@ SELECT 'S2',
   ST_Equals(ST_Simplify(tg, 1), 'POLYGON((0 0,1 3,2 0,0 0))')
 FROM tt.areas WHERE id = 2;
 
+-- Test hierarchical -- see http://trac.osgeo.org/postgis/ticket/2547
+
+CREATE TABLE tt.bigareas(id serial, g geometry);
+INSERT INTO _test_layers SELECT 2,
+  AddTopoGeometryColumn('tt', 'tt', 'bigareas', 'tg', 'polygon', layer_id)
+  FROM _test_layers WHERE id = 1;
+SELECT 'L' || layer_id FROM _test_layers WHERE id = 2;
+INSERT INTO tt.bigareas (tg) SELECT
+  topology.CreateTopoGeom( 'tt', 3,
+    (select layer_id from _test_layers where id = 2),
+    TopoElementArray_agg(ARRAY[r.topogeo_id, r.layer_id]))
+  FROM tt.relation r, _test_layers l1
+  WHERE r.layer_id = l1.layer_id AND l1.id = 1
+  GROUP BY r.topogeo_id;
+UPDATE tt.bigareas SET g = tg;
+
+SELECT 'HS1',
+  -- Point 1 3 is removed when simplifying the simple (unconstrained) geometry
+  ST_Equals(ST_Simplify( g, 1), 'POLYGON((0 0,1 3,-2 3,0 0))'),
+  ST_Equals(ST_Simplify(tg, 1), 'POLYGON((0 0,1 3,-2 3,0 0))')
+FROM tt.bigareas WHERE id = 1;
+SELECT 'HS2',
+  ST_Equals(ST_Simplify( g, 1), 'POLYGON((0 0,1 3,2 0,0 0))'),
+  ST_Equals(ST_Simplify(tg, 1), 'POLYGON((0 0,1 3,2 0,0 0))')
+FROM tt.bigareas WHERE id = 2;
+
 SELECT DropTopology('tt') IS NULL;
index 75152ce965daf6c07d1ffca5cd27de233707ea24..21776817c68b5f241aa51fb59f9db1dfae84f8e7 100644 (file)
@@ -3,4 +3,7 @@ L1
 N2
 S1|f|t
 S2|f|t
+L2
+HS1|f|t
+HS2|f|t
 f