[postgis-tickets] r14374 - Fix toTopoGeom loss of low-id primitives from TopoGeometry definition

Sandro Santilli strk at keybit.net
Sat Nov 7 02:38:34 PST 2015


Author: strk
Date: 2015-11-07 02:38:34 -0800 (Sat, 07 Nov 2015)
New Revision: 14374

Modified:
   branches/2.2/NEWS
   branches/2.2/topology/sql/topogeometry/totopogeom.sql.in
   branches/2.2/topology/test/regress/totopogeom.sql
   branches/2.2/topology/test/regress/totopogeom_expected
Log:
Fix toTopoGeom loss of low-id primitives from TopoGeometry definition

Affects toTopoGeom on including edge with id=2 and face with id=3
Includes tests.
Fixes #3359

Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS	2015-11-07 10:28:22 UTC (rev 14373)
+++ branches/2.2/NEWS	2015-11-07 10:38:34 UTC (rev 14374)
@@ -10,6 +10,8 @@
   - #3321, Fix performance regression in topology loading
   - Fix memory leak in lwt_ChangeEdgeGeom [liblwgeom]
   - #3355 geography ST_Segmentize has geometry bbox 
+  - #3359, Fix toTopoGeom loss of low-id primitives from TopoGeometry
+           definition
   - #3360, _raster_constraint_info_scale invalid input syntax
 
 

Modified: branches/2.2/topology/sql/topogeometry/totopogeom.sql.in
===================================================================
--- branches/2.2/topology/sql/topogeometry/totopogeom.sql.in	2015-11-07 10:28:22 UTC (rev 14373)
+++ branches/2.2/topology/sql/topogeometry/totopogeom.sql.in	2015-11-07 10:38:34 UTC (rev 14374)
@@ -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 @@
   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 @@
          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

Modified: branches/2.2/topology/test/regress/totopogeom.sql
===================================================================
--- branches/2.2/topology/test/regress/totopogeom.sql	2015-11-07 10:28:22 UTC (rev 14373)
+++ branches/2.2/topology/test/regress/totopogeom.sql	2015-11-07 10:38:34 UTC (rev 14374)
@@ -200,6 +200,26 @@
   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;

Modified: branches/2.2/topology/test/regress/totopogeom_expected
===================================================================
--- branches/2.2/topology/test/regress/totopogeom_expected	2015-11-07 10:28:22 UTC (rev 14373)
+++ branches/2.2/topology/test/regress/totopogeom_expected	2015-11-07 10:38:34 UTC (rev 14374)
@@ -44,4 +44,9 @@
 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



More information about the postgis-tickets mailing list