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

Sandro Santilli strk at keybit.net
Wed Jan 6 21:47:17 PST 2016


Author: strk
Date: 2016-01-06 21:47:17 -0800 (Wed, 06 Jan 2016)
New Revision: 14582

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

Modified: trunk/liblwgeom/lwgeom_topo.c
===================================================================
--- trunk/liblwgeom/lwgeom_topo.c	2016-01-06 17:31:13 UTC (rev 14581)
+++ trunk/liblwgeom/lwgeom_topo.c	2016-01-07 05:47:17 UTC (rev 14582)
@@ -2698,8 +2698,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 );
@@ -2709,7 +2720,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