]> granicus.if.org Git - postgis/commitdiff
Only consider closest edges for snapping to newly added point (#3329)
authorSandro Santilli <strk@keybit.net>
Sun, 11 Oct 2015 20:31:30 +0000 (20:31 +0000)
committerSandro Santilli <strk@keybit.net>
Sun, 11 Oct 2015 20:31:30 +0000 (20:31 +0000)
This is a fix of r14155, which was the C version of the fix for #3280

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

liblwgeom/lwgeom_topo.c

index 0a7b813c75b72583c408a2b5506cb2d805a31d8f..7be02d45b617a2ea3d74876652369ceedfb06c8e 100644 (file)
@@ -5002,6 +5002,7 @@ lwt_AddPoint(LWT_TOPOLOGY* topo, LWPOINT* point, double tol)
   /* Order by distance if there are more than a single return */
   if ( num > 1 )
   {{
+    int j;
     sorted = lwalloc(sizeof(scored_pointer)*num);
     for (i=0; i<num; ++i)
     {
@@ -5012,10 +5013,18 @@ lwt_AddPoint(LWT_TOPOLOGY* topo, LWPOINT* point, double tol)
     }
     qsort(sorted, num, sizeof(scored_pointer), compare_scored_pointer);
     edges2 = lwalloc(sizeof(LWT_ISO_EDGE)*num);
-    for (i=0; i<num; ++i)
+    for (j=0, i=0; i<num; ++i)
     {
-      edges2[i] = *((LWT_ISO_EDGE*)sorted[i].ptr);
+      if ( sorted[i].score == sorted[0].score )
+      {
+        edges2[j++] = *((LWT_ISO_EDGE*)sorted[i].ptr);
+      }
+      else
+      {
+        lwline_free(((LWT_ISO_EDGE*)sorted[i].ptr)->geom);
+      }
     }
+    num = j;
     lwfree(sorted);
     lwfree(edges);
     edges = edges2;