[postgis-tickets] r14583 - ST_AddEdge*: avoid db access for edges known to be dangling

Sandro Santilli strk at keybit.net
Wed Jan 6 22:36:50 PST 2016


Author: strk
Date: 2016-01-06 22:36:50 -0800 (Wed, 06 Jan 2016)
New Revision: 14583

Modified:
   branches/2.2/liblwgeom/lwgeom_topo.c
Log:
ST_AddEdge*: avoid db access for edges known to be dangling

Modified: branches/2.2/liblwgeom/lwgeom_topo.c
===================================================================
--- branches/2.2/liblwgeom/lwgeom_topo.c	2016-01-07 05:47:17 UTC (rev 14582)
+++ branches/2.2/liblwgeom/lwgeom_topo.c	2016-01-07 06:36:50 UTC (rev 14583)
@@ -2690,8 +2690,19 @@
     }
   }
 
+  /* Check face splitting */
+
+  if ( ! isclosed && ( epan.was_isolated || span.was_isolated ) )
+  {
+    LWDEBUG(1, "New edge is dangling, so it cannot split any face");
+    return newedge.edge_id; /* no split */
+  }
+
   int newface1 = -1;
 
+  /* IDEA: avoid building edge ring if input is closed, which means we
+   *       know in advance it splits a face */
+
   if ( ! modFace )
   {
     newface1 = _lwt_AddFaceSplit( topo, -newedge.edge_id, newedge.face_left, 0 );
@@ -2701,7 +2712,6 @@
     }
   }
 
-  /* Check face splitting */
   int newface = _lwt_AddFaceSplit( topo, newedge.edge_id,
                                    newedge.face_left, 0 );
   if ( modFace )



More information about the postgis-tickets mailing list