[Tile-serving] [osm2pgsql-dev/osm2pgsql] Add grouped-linemerge generalization (PR #2482)

leijurv notifications at github.com
Fri Jun 5 18:40:10 UTC 2026


@leijurv commented on this pull request.



> +    // endpoint equality, not ST_Intersects, to avoid deleting unrelated
+    // same-group lines that cross a component. A second pass over the changed
+    // region cleans up outputs of components that disappeared entirely (all
+    // their lines deleted), which leave no reached nodes behind; that pass is
+    // self-correcting because anything it removes either vanished or has a
+    // surviving line in the region and is regenerated below.
+    timer(m_timer_delete).start();
+    auto deleted = dbexec(R"(
+DELETE FROM {dest} d
+ USING _glm_nodes n
+ WHERE {group_join_dn}
+   AND ( (ST_X(ST_StartPoint(d."{geom_column}")) = n.x
+      AND ST_Y(ST_StartPoint(d."{geom_column}")) = n.y)
+     OR (ST_X(ST_EndPoint(d."{geom_column}")) = n.x
+      AND ST_Y(ST_EndPoint(d."{geom_column}")) = n.y) )
+)");

Yes because the recursive CTE scan, that we insert in Step 5, includes fragments that are entirely outside the current tile.

Consider the following four ways, that will LineMerge from A,B,C,D to AB,C,D
```
   |          /
   |         C
   |        /
--A--•--B--•
   |        \
   |         D
   |          \
   ^ tile boundary
```

The line 335 delete will only delete the AB geometry. The line 325 delete is what deletes C, D, which is necessary, because Step 5 will reinsert all AB,C,D.

And conversely, the reason why 335 is needed as well as 325, is much easier to justify: when you delete a way that is entirely within this tile, line 335 deletes it from the linemerged table too.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2482#discussion_r3364667804
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/pull/2482/review/4438743283 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20260605/ac106050/attachment-0001.htm>


More information about the Tile-serving mailing list