]> granicus.if.org Git - postgis/commitdiff
Fix toTopoGeom loss of low-id primitives from TopoGeometry definition
authorSandro Santilli <strk@keybit.net>
Sat, 7 Nov 2015 10:39:19 +0000 (10:39 +0000)
committerSandro Santilli <strk@keybit.net>
Sat, 7 Nov 2015 10:39:19 +0000 (10:39 +0000)
Affects toTopoGeom on including edge with id=2 and face with id=3
Includes tests.
Fixes #3359

git-svn-id: http://svn.osgeo.org/postgis/trunk@14375 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/topogeometry/totopogeom.sql.in
topology/test/regress/totopogeom.sql
topology/test/regress/totopogeom_expected

index 3b7d33ee86cdc75f97f8d0064e8f9906aec0745f..1056a9d01387bd2f602c1f20a29adb4b20cf92f1 100644 (file)
@@ -10,6 +10,8 @@
 --
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+/* #define POSTGIS_TOPOLOGY_DEBUG 1 */
+
 -- {
 --  Convert a simple geometry to a topologically-defined one
 --
@@ -23,12 +25,7 @@ $$
 DECLARE
   layer_info RECORD;
   topology_info RECORD;
-  rec RECORD;
-  rec2 RECORD;
   tg topology.TopoGeometry;
-  elems INT[][];
-  elem INT[];
-  sql TEXT;
   typ TEXT;
 BEGIN
 
@@ -135,8 +132,8 @@ DECLARE
   topology_info RECORD;
   rec RECORD;
   rec2 RECORD;
-  elem INT[];
-  elems INT[][];
+  elem TEXT;
+  elems TEXT[];
   sql TEXT;
   typ TEXT;
   tolerance FLOAT8;
@@ -251,10 +248,11 @@ BEGIN
          topology.topogeo_addPolygon(atopology, rec.geom, tolerance)
        END as primitive
     LOOP
-      elem := ARRAY[rec.dims+1, rec2.primitive];
+      elem := ARRAY[rec.dims+1, rec2.primitive]::text;
       IF elems @> ARRAY[elem] THEN
 #ifdef POSTGIS_TOPOLOGY_DEBUG
 RAISE DEBUG 'Elem % already in %', elem, elems;
+RAISE DEBUG '% @> ARRAY[%] returned true', elems, elem;
 #endif
       ELSE
 #ifdef POSTGIS_TOPOLOGY_DEBUG
index 63be65ede508bb68d7213cf84675d59d0a07b35d..993bc6e887376d82367c532407a235cada9c7a3c 100644 (file)
@@ -200,6 +200,26 @@ SELECT 'tgup1.3', id(t.g), st_area(t.g), count(r.*)
   WHERE t.id = -1 AND r.layer_id = 4 AND r.topogeo_id = id(t.g)
   GROUP BY id(t.g), st_area(t.g);
 
+-- http://trac.osgeo.org/postgis/ticket/3359
+-- NOTE: requires identifier of the second edge to be 2
+TRUNCATE tt.relation CASCADE;
+TRUNCATE tt.edge_data CASCADE;
+TRUNCATE tt.node CASCADE;
+DELETE FROM tt.face WHERE face_id > 0;
+SELECT '#3359.setval',
+       setval('tt.edge_data_edge_id_seq', 1, false),
+       -- face_id is intentionally set to 2
+       setval('tt.face_face_id_seq', 2, false),
+       setval('tt.node_node_id_seq', 1, false);
+SELECT '#3359.line.1', ST_Length(toTopoGeom('LINESTRING (0 0,1 0)'
+::geometry, 'tt', 3));
+SELECT '#3359.line.2', ST_Length(toTopoGeom('LINESTRING (0 0,1 0,1 1)'
+::geometry, 'tt', 3));
+SELECT '#3359.area.1', ST_Area(toTopoGeom('POLYGON ((0 0,1 0,1 1,0 1,0 0))'
+::geometry, 'tt', 4));
+SELECT '#3359.area.2', ST_Area(toTopoGeom('POLYGON ((0 0,1 0,1 2,0 2,0 0))'
+::geometry, 'tt', 4));
+
 DROP TABLE tt.f_coll;
 DROP TABLE tt.f_areal;
 DROP TABLE tt.f_lineal;
index 6d9999187e22bc92df2ae107f5c5b916f8d9e224..7f222f82d5642dc6d432abae289b5af061283bb3 100644 (file)
@@ -44,4 +44,9 @@ custom_search_path|0
 tgup1.1|5|100|1
 tgup1.2|5|200|2
 tgup1.3|5|200|4
+#3359.setval|1|2|1
+#3359.line.1|1
+#3359.line.2|2
+#3359.area.1|1
+#3359.area.2|2
 Topology 'tt' dropped