]> granicus.if.org Git - postgis/commitdiff
Simplify face registration by the end of ST_AddEdgeNewFaces [RT-SIGTA]
authorSandro Santilli <strk@keybit.net>
Fri, 27 May 2011 10:18:38 +0000 (10:18 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 27 May 2011 10:18:38 +0000 (10:18 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7271 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql

index a475a56136fcc94c47e7792256bf70b6ff8e4fd4..b63fd33d9d26c8a161fd41efe57610e1de758080 100644 (file)
@@ -2440,44 +2440,35 @@ BEGIN
     INTO STRICT fan.post;
 
   IF ST_NumGeometries(fan.pre) = ST_NumGeometries(fan.post) THEN
-    -- all done, I hope
+    -- No splits, all done
     RETURN newedge.edge_id;
   END IF;
 
   RAISE NOTICE 'ST_AddEdgeNewFaces: edge % splitted face %',
       newedge.edge_id, newedge.left_face;
 
-  IF newedge.left_face != 0 THEN -- {
-
-    -- Set old face edges to zero to let AddFace do something with them
-    EXECUTE 'UPDATE ' || quote_ident(atopology)
-      || '.edge_data SET left_face = 0 WHERE left_face = '
-      || newedge.left_face;
-    EXECUTE 'UPDATE ' || quote_ident(atopology)
-      || '.edge_data SET right_face = 0 WHERE right_face = '
-      || newedge.left_face;
-    -- Now we call topology.AddFace for each of the two new
-    -- faces. These are the ones that do contain the new edge
-    -- The ORDER serves predictability of which face is added first
-    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)
-        || ', ' || quote_literal(rec.geom::text) || ')';
-      EXECUTE sql INTO newface;
-      newfaces := array_append(newfaces, newface);
-    END LOOP; --}
+  -- Call topology.AddFace for every face containing the new edge
+  -- The ORDER serves predictability of which face is added first
+  FOR rec IN SELECT geom FROM ST_Dump(fan.post)
+             WHERE ST_Contains(
+                ST_Boundary(geom),
+                  ST_MakeLine(
+                    ST_StartPoint(newedge.cleangeom),
+                    ST_PointN(newedge.cleangeom, 2)
+                  )
+                )
+             ORDER BY ST_XMin(geom), ST_YMin(geom)
+  LOOP -- {
+    RAISE DEBUG 'Adding face %', ST_AsText(rec.geom);
+    sql :=
+      'SELECT topology.AddFace(' || quote_literal(atopology)
+      || ', ' || quote_literal(rec.geom::text) || ', true)';
+    EXECUTE sql INTO newface;
+    newfaces := array_append(newfaces, newface);
+  END LOOP; --}
+  RAISE DEBUG 'Added faces: %', newfaces;
 
-    RAISE DEBUG 'Added faces: %', newfaces;
+  IF newedge.left_face != 0 THEN -- {
 
     -- NOT IN THE SPECS:
     -- update TopoGeometry compositions to substitute oldface with newfaces
@@ -2509,26 +2500,6 @@ BEGIN
       || '.face WHERE face_id = ' || newedge.left_face;
     EXECUTE sql;
 
-  ELSE -- }{
-
-    FOR rec IN SELECT (ST_Dump(fan.post)).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)
-        || ', ' || quote_literal(rec.geom::text) || ')';
-      EXECUTE sql INTO newface;
-      newfaces := array_append(newfaces, newface);
-    END LOOP; --}
-
-    RAISE DEBUG 'Added faces: %', newfaces;
-
   END IF; -- }
 
   RETURN newedge.edge_id;