[SCM] PostGIS branch master updated. 3.4.0rc1-995-g6a6d7dadd

git at osgeo.org git at osgeo.org
Fri Mar 8 01:46:05 PST 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  6a6d7dadd98e79daa4abec3ae2d8dfc3f58618f9 (commit)
      from  865bfe8c67f877bd2a442804ebb9fd10dc4ae4dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6a6d7dadd98e79daa4abec3ae2d8dfc3f58618f9
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Mar 4 19:13:47 2024 +0100

    Use GEOS-3.7+ GEOSDistanceIndexed to find existing edges
    
    Closes #3587 in master branch (3.5.0dev)

diff --git a/NEWS b/NEWS
index ef44b147a..4a9b8e8b0 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,7 @@ To take advantage of all SFCGAL featurs, SFCGAL 1.5.0+ is needed.
 
 * Enhancements *
 
+  - #3587, faster load of big lines in topologies (Sandro Santilli)
   - #5670, faster ST_CreateTopoGeo (Sandro Santilli)
   - #5531, documentation format upgraded to DocBook 5 (Sandro Santilli)
   - #5543, allow building without documentation (Sandro Santilli)
diff --git a/liblwgeom/topo/lwgeom_topo.c b/liblwgeom/topo/lwgeom_topo.c
index 630cace9f..b84f7ed63 100644
--- a/liblwgeom/topo/lwgeom_topo.c
+++ b/liblwgeom/topo/lwgeom_topo.c
@@ -5669,21 +5669,32 @@ _lwt_AddLine(LWT_TOPOLOGY* topo, LWLINE* line, double tol, int* nedges,
     line->points->npoints, numedges);
   if ( numedges )
   {{
+    /* TODO: compute earlier for reuse later ? */
+    GEOSGeometry *noded_g = LWGEOM2GEOS(noded, 0);
     /* collect those whose distance from us is < tol */
     nearbycount += numedges;
     nearby = lwalloc(numedges * sizeof(LWGEOM *));
     for (i=0; i<numedges; ++i)
-    {
+    {{
       LW_ON_INTERRUPT(return NULL);
       LWT_ISO_EDGE *e = &(edges[i]);
       LWGEOM *g = lwline_as_lwgeom(e->geom);
-      LWDEBUGF(2, "Computing distance from edge %d having %d points", i, e->geom->points->npoints);
-      double dist = lwgeom_mindistance2d(g, noded);
-      /* must be closer than tolerated, unless distance is zero */
+      GEOSGeometry *edge_g = LWGEOM2GEOS(g, 0);
+      LWDEBUGF(2, "Computing distance from edge %d with %d points", i, e->geom->points->npoints);
+      double dist;
+      if ( 0 == GEOSDistanceIndexed(edge_g, noded_g, &dist) ) {
+        GEOSGeom_destroy(edge_g);
+        GEOSGeom_destroy(noded_g);
+        lwgeom_free(noded);
+        lwerror("GEOSDistanceIndexed error: %s", lwgeom_geos_errmsg);
+        return NULL;
+      }
       if ( dist && dist >= tol ) continue;
       nearby[nearbyindex++] = g;
-    }
+      GEOSGeom_destroy(edge_g);
+    }}
     LWDEBUGF(1, "Found %d edges closer than tolerance (%g)", nearbyindex, tol);
+    GEOSGeom_destroy(noded_g);
   }}
   int nearbyedgecount = nearbyindex;
 

-----------------------------------------------------------------------

Summary of changes:
 NEWS                         |  1 +
 liblwgeom/topo/lwgeom_topo.c | 21 ++++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list