]> granicus.if.org Git - postgis/commitdiff
topology.ST_AddEdgeNewFaces: do not needlessly replace face of holes found in a face...
authorSandro Santilli <strk@keybit.net>
Fri, 27 May 2011 09:34:18 +0000 (09:34 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 27 May 2011 09:34:18 +0000 (09:34 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7269 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql
topology/test/regress/st_addedgenewfaces.sql
topology/test/regress/st_addedgenewfaces_expected

index cb83709db8fd742b270357fc2770d00eb658b57a..a475a56136fcc94c47e7792256bf70b6ff8e4fd4 100644 (file)
@@ -2444,10 +2444,10 @@ BEGIN
     RETURN newedge.edge_id;
   END IF;
 
-  RAISE WARNING 'ST_AddEdgeNewFaces: edge % splitted face %',
+  RAISE NOTICE 'ST_AddEdgeNewFaces: edge % splitted face %',
       newedge.edge_id, newedge.left_face;
 
-  IF newedge.left_face != 0 THEN
+  IF newedge.left_face != 0 THEN -- {
 
     -- Set old face edges to zero to let AddFace do something with them
     EXECUTE 'UPDATE ' || quote_ident(atopology)
@@ -2463,6 +2463,12 @@ BEGIN
     FOR rec IN SELECT geom FROM ST_Dump(fan.post)
       ORDER BY ST_XMin(geom), ST_YMin(geom)
     LOOP -- {
+      -- skip the polygons whose boundary does not contain
+      -- the newly added edge
+      IF NOT ST_Contains(ST_Boundary(rec.geom), acurve) THEN
+        CONTINUE;
+      END IF;
+
       RAISE DEBUG 'Adding face %', ST_AsText(rec.geom);
       sql :=
         'SELECT topology.AddFace(' || quote_literal(atopology)
@@ -2503,7 +2509,7 @@ BEGIN
       || '.face WHERE face_id = ' || newedge.left_face;
     EXECUTE sql;
 
-  ELSE
+  ELSE -- }{
 
     FOR rec IN SELECT (ST_Dump(fan.post)).geom
     LOOP -- {
@@ -2523,7 +2529,7 @@ BEGIN
 
     RAISE DEBUG 'Added faces: %', newfaces;
 
-  END IF;
+  END IF; -- }
 
   RETURN newedge.edge_id;
 END
index 9270eeaf835ac47fb67b59437cdfa907b7b8d0d5..8b621dc1ec614fc757f72ff3da05426c0358d347 100644 (file)
@@ -340,6 +340,18 @@ SELECT 'T21', 'E'||edge_id, next_left_edge, next_right_edge,
     UNION VALUES (36),(16) )
   ORDER BY edge_id;
 
+--
+-- Split a face containing an hole 
+--
+INSERT INTO newedge SELECT 22, topology.st_addedgenewfaces('city_data',
+  3, 3,  'LINESTRING(25 35, 27 35, 26 34, 25 35)');
+SELECT 'T22', 'E'||edge_id, next_left_edge, next_right_edge,
+  left_face, right_face FROM
+  city_data.edge WHERE edge_id IN ( 
+    SELECT edge_id FROM newedge WHERE id IN (22, 16)
+    UNION VALUES (2),(3) )
+  ORDER BY edge_id;
+
 
 ---------------------------------------------------------------------
 -- Check new relations and faces status
index f27d54c9d6a915cd9ea175ae2ed26b26ac84f9eb..2e952b1822d9d5d1882447b44b62b347aa91c136 100644 (file)
@@ -97,6 +97,10 @@ T21|E16|29|-47|14|0
 T21|E36|-13|-36|0|27
 T21|E46|-14|47|35|36
 T21|E47|-46|36|36|0
+T22|E2|3|39|37|0
+T22|E3|48|2|37|37
+T22|E42|42|-42|37|32
+T22|E48|-3|-48|37|38
 F3,F4|{3:10,3:11,3:23,3:24,3:25}
 F5,N4|{1:4,3:12,3:13}
 F0|
@@ -121,10 +125,11 @@ F27|POLYGON((32 0,32 6,38 6,38 0,32 0))
 F28|POLYGON((3 11,3 17,9 17,9 11,3 11))
 F29|POLYGON((5 27,5 30,11 30,11 27,5 27))
 F30|POLYGON((22 27,22 30,28 30,28 27,22 27))
-F31|POLYGON((17 30,17 40,31 40,31 30,17 30))
 F32|POLYGON((20 34,20 37,23 37,23 34,20 34))
 F33|POLYGON((35 25,35 45,63 45,63 25,35 25))
 F34|POLYGON((9 0,9 6,21 6,21 0,9 0))
 F35|POLYGON((35 0,35 6,47 6,47 0,35 0))
 F36|POLYGON((35 -4,35 6,47 6,47 -4,35 -4))
+F37|POLYGON((17 30,17 40,31 40,31 30,17 30))
+F38|POLYGON((25 34,25 35,27 35,27 34,25 34))
 Topology 'city_data' dropped