Set endpoints isolation in lwt_RemIsoEdge (ST_RemoveIsoEdge)
authorSandro Santilli <strk@keybit.net>
Thu, 29 Oct 2015 08:56:03 +0000 (08:56 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 29 Oct 2015 08:56:03 +0000 (08:56 +0000)
See #3351

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

NEWS
liblwgeom/lwgeom_topo.c
topology/test/regress/sqlmm.sql
topology/test/regress/sqlmm_expected

diff --git a/NEWS b/NEWS
index da3623c823289b043d15131c4dfcdefa824ee466..8dcc3e2debd35337eae84334fcf7c50293ed1ef6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,7 +5,6 @@ PostGIS 2.3.0
  * Deprecated signatures *
  * New Features *
 
-
 PostGIS 2.2.0
 2015/10/07
 
index ea8f24b8528b35f5346355b45c409add173fcd84..9bcbb174eedf9ea7e3f58767b87e205f187cba2c 100644 (file)
@@ -3691,6 +3691,8 @@ lwt_RemIsoEdge(LWT_TOPOLOGY* topo, LWT_ELEMID id)
   LWT_ISO_EDGE deledge;
   LWT_ISO_EDGE *edge;
   LWT_ELEMID nid[2];
+  LWT_ISO_NODE upd_node[2];
+  LWT_ELEMID containing_face;
   int n = 1;
   int i;
 
@@ -3722,6 +3724,7 @@ lwt_RemIsoEdge(LWT_TOPOLOGY* topo, LWT_ELEMID id)
     lwerror("SQL/MM Spatial exception - not isolated edge");
     return -1;
   }
+  containing_face = edge[0].face_left;
 
   nid[0] = edge[0].start_node;
   nid[1] = edge[0].end_node;
@@ -3756,6 +3759,22 @@ lwt_RemIsoEdge(LWT_TOPOLOGY* topo, LWT_ELEMID id)
     return -1;
   }
 
+  upd_node[0].node_id = nid[0];
+  upd_node[0].containing_face = containing_face;
+  n = 1;
+  if ( nid[1] != nid[0] ) {
+    upd_node[1].node_id = nid[1];
+    upd_node[1].containing_face = containing_face;
+    ++n;
+  }
+  n = lwt_be_updateNodesById(topo, upd_node, n,
+                               LWT_COL_NODE_CONTAINING_FACE);
+  if ( n == -1 )
+  {
+    lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
+    return -1;
+  }
+
   /* TODO: notify to caller about edge being removed ?
    * See https://trac.osgeo.org/postgis/ticket/3248
    */
index 6b8199fd24db5d4c8d55c38028241e87ae524877..c1aebace8c8cbc88809bf0820c09dcaaca91c482 100644 (file)
@@ -135,7 +135,26 @@ SELECT topology.ST_MoveIsoNode('sqlmm_topology', 8, 'POINT(7 10)');
 -------------------------------------------------------------
 SELECT '-- ST_RemoveIsoEdge ---------------------';
 
+CREATE TEMP TABLE edge1_endnodes AS
+  WITH edge AS (
+    SELECT start_node,end_node
+    FROM sqlmm_topology.edge_data
+    WHERE edge_id = 1
+  )
+  SELECT start_node id FROM edge UNION
+  SELECT end_node FROM edge;
+SELECT '#3351.1', node_id, containing_face
+ FROM sqlmm_topology.node where node_id in (
+    SELECT id FROM edge1_endnodes
+  )
+ ORDER BY node_id;
 SELECT topology.ST_RemoveIsoEdge('sqlmm_topology', 1);
+SELECT '#3351.2', node_id, containing_face
+ FROM sqlmm_topology.node where node_id in (
+    SELECT id FROM edge1_endnodes
+  )
+ ORDER BY node_id;
+DROP TABLE edge1_endnodes;
 
 -------------------------------------------------------------
 -- ST_NewEdgesSplit
index 24df34bf2ce8b29a3f0d5c682ad72b9c65495382..ea665fe86ca84765cc2f78f0e6cb969fe35859cb 100644 (file)
@@ -47,7 +47,11 @@ ERROR:  SQL/MM Spatial exception - invalid point
 Isolated Node 8 moved to location 7,11
 Isolated Node 8 moved to location 7,10
 -- ST_RemoveIsoEdge ---------------------
+#3351.1|4|
+#3351.1|5|
 Isolated edge 1 removed
+#3351.2|4|0
+#3351.2|5|0
 -- ST_NewEdgesSplit  ---------------------
 9
 Topology 'sqlmm_topology' dropped