]> granicus.if.org Git - postgis/commitdiff
Snap new lines over existing nodes (#1654)
authorSandro Santilli <strk@keybit.net>
Tue, 6 Mar 2012 16:16:34 +0000 (16:16 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 6 Mar 2012 16:16:34 +0000 (16:16 +0000)
Also add Salvatore to the list of testing heroes :)

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

NEWS
topology/sql/populate.sql.in.c
topology/test/regress/topogeo_addlinestring.sql
topology/test/regress/topogeo_addlinestring_expected

diff --git a/NEWS b/NEWS
index ecfadb3fd8838a3ee6732c1167464b9241824e39..e0b76da9abd9d95d80e9748d3647f3b5ef91e69d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ PostGIS 2.0.0beta1
    Andrea Peri - Lots of testing on topology, checking for correctness
    Andreas Forø Tollefsen - raster testing
    Chris English - topology stress testing loader functions
+   Salvatore Larosa - Lots of topology testing 
    Brian Hamlin - Benchmarking 
        (also experimental experimental branches 
                before they are folded into core)
index a036b0f71e93b19cc5822f25e477e94fcc4d9a51..4cdfb8b8f366fbbc794f648f324d9f61cd1fb719 100644 (file)
@@ -838,7 +838,7 @@ BEGIN
 
     snapped := ST_Snap(noded, iedges, tol);
 #ifdef POSTGIS_TOPOLOGY_DEBUG
-    RAISE DEBUG 'Snapped: %', ST_AsText(snapped);
+    RAISE DEBUG 'Snapped to edges: %', ST_AsText(snapped);
 #endif
 
     noded := ST_Difference(snapped, iedges);
@@ -864,28 +864,44 @@ BEGIN
   END IF;
 
   -- 2.1. Node with existing nodes within tol
+  -- TODO: check if we should be only considering _isolated_ nodes!
   sql := 'WITH nearby AS ( SELECT n.geom FROM '
     || quote_ident(atopology) 
     || '.node n WHERE ST_DWithin(n.geom, '
     || quote_literal(noded::text)
     || '::geometry, '
-    || tol || ') ) SELECT (st_dump(st_unaryunion(st_collect(geom)))).geom FROM nearby;';
+    || tol || ') ) SELECT st_collect(geom) FROM nearby;';
 #ifdef POSTGIS_TOPOLOGY_DEBUG
   RAISE DEBUG '%', sql;
 #endif
-  FOR rec IN EXECUTE sql
-  LOOP
-      -- Use the node to split edges
-      SELECT ST_Collect(geom) 
-      FROM ST_Dump(ST_Split(noded, rec.geom))
-      INTO STRICT noded;
+  EXECUTE sql INTO inodes;
+
+  IF inodes IS NOT NULL THEN -- {
 #ifdef POSTGIS_TOPOLOGY_DEBUG
-      RAISE DEBUG 'Split by %: %', ST_AsText(rec.geom), ST_AsText(noded);
+    RAISE DEBUG 'Intersecting nodes: %', ST_AsText(inodes);
 #endif
-  END LOOP;
+
+    -- TODO: consider snapping once against all elements
+    ---      (rather than once with edges and once with nodes)
+    noded := ST_Snap(noded, inodes, tol);
+#ifdef POSTGIS_TOPOLOGY_DEBUG
+    RAISE DEBUG 'Snapped to nodes: %', ST_AsText(noded);
+#endif
+
+    FOR rec IN SELECT (ST_Dump(inodes)).*
+    LOOP
+        -- Use the node to split edges
+        SELECT ST_Collect(geom) 
+        FROM ST_Dump(ST_Split(noded, rec.geom))
+        INTO STRICT noded;
+#ifdef POSTGIS_TOPOLOGY_DEBUG
+        RAISE DEBUG 'Split by %: %', ST_AsText(rec.geom), ST_AsText(noded);
+#endif
+    END LOOP;
 #ifdef POSTGIS_TOPOLOGY_DEBUG
-  RAISE DEBUG 'Split: %', ST_AsText(noded);
+    RAISE DEBUG 'Split: %', ST_AsText(noded);
 #endif
+  END IF; -- }
 
   -- 3. For each (now-noded) segment, insert an edge
   FOR rec IN SELECT (ST_Dump(noded)).geom LOOP
index ebdfd9cc703c73a8d1d5179722651afd6f00d052..cad4f1794224919448d8922238a3e01b21545b46 100644 (file)
@@ -189,6 +189,19 @@ SELECT '#1650.3', TopoGeo_addLineString('city_data',
 , 2) ORDER BY 2;
 SELECT check_changes();
 
+-- Test snapping of line over a node( http://trac.osgeo.org/postgis/ticket/??? )
+
+DELETE FROM city_data.edge_data; DELETE FROM city_data.node; 
+DELETE FROM city_data.face where face_id > 0; 
+
+SELECT '#1654.1', 'N', ST_AddIsoNode('city_data', 0, 'POINT(0 0)');
+SELECT check_changes();
+SELECT '#1654.2', TopoGeo_addLineString('city_data',
+  'LINESTRING(-10 1, 10 1)'
+, 2);
+SELECT check_changes();
+
+
 -- Cleanups
 DROP FUNCTION check_changes();
 SELECT DropTopology('city_data');
index 4d21f9b2d90b2c44b0329791582b112e51241e02..1dae3b809d6709e4702d919ccd2ae81e9f40e86e 100644 (file)
@@ -149,4 +149,12 @@ N|65|0|POINT(0 0)
 #1650.3|66
 N|66||POINT(10 0)
 E|66|sn65|en66
+#1654.1|N|67
+N|67|0|POINT(0 0)
+#1654.2|67
+#1654.2|68
+N|68||POINT(-10 1)
+N|69||POINT(10 1)
+E|67|sn68|en67
+E|68|sn67|en69
 Topology 'city_data' dropped