Repository navigation
Conversation
dissolve_generate_rings scanned the whole traced ring for every new point to see whether it closes the ring, which is quadratic in the ring size. Keep a map from point to position instead; the closing test stays exact. Output identical (2,000 random self-intersecting polygons, old vs new header; Germany compare_area). Slowest planet relations: wood r20516020 43.9 -> 3.9 s (-91%), Lake Nasser 53.8 -> 3.2 s (-94%).
This was referenced Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gain: the two slowest planet relations 43.9 → 3.9 s (−91%) and 53.8 → 3.2 s (−94%); extract user CPU −20%. On the planet, measured together with the ring-assignment PR #975: relations phase 105 → 61 s (−42%), total wall 1659 → 1620 s (−2.4%). Output identical.
make_validrepairs self-intersecting rings withgeometry::correct()ininclude/geometry/correct.hpp.dissolve_generate_ringstraces each repaired ring point by point, and after every new pointis_closedscanned the whole ring traced so far for an earlier point equal to the new one. That is quadratic in the ring's size, and on a few huge planet relations it dominates.This PR keeps a hash map from each traced point to its position in the ring. A ring's points are distinct until it closes, so a point found in the map closes it, and the points before the earlier occurrence are dropped as before. The test was exact equality (
comparable_distance == 0) and stays exact;+ 0.0makes-0.0and0.0hash alike, as they compared equal before.Equivalence
The same test program, compiled once with the old and once with the new header, repaired 2,000 random self-intersecting polygons (continuous and grid coordinates, with and without holes; 1,999 non-empty results). The WKT output of both is byte-identical. Germany output (compare_area, per-tile area/length per layer and tag group) is identical too; only
poidiffers, as between identical runs.Speed, extract with the five slowest planet relations
User CPU of the extract run −20%. For the planet, see the ring-assignment PR #975, measured together: the relations phase drops from 105 s to 61 s.
🤖 Generated with Claude Code