Detect closed multipolygon ways#896
Open
Symmetricity wants to merge 1 commit into
Open
Conversation
The previous test compared begin() and end(), so it only treated empty way vectors as closed. Closed relation member rings then fell through the endpoint assembly path used for open fragments. That path is keyed by unordered endpoint containers, which can assemble otherwise complete rings in platform-dependent order before geometry correction and simplification. Checking the first and last coordinate keeps already-closed members in relation order and avoids unnecessary assembly work.
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.
This PR is AI generated.
Summary
This fixes closed-way detection when assembling multipolygon relation members.
The existing helper compared
way.begin()withway.end(). For a normalnon-empty closed ring those iterators are never equal, so the helper only
reported empty vectors as closed. Closed relation member ways therefore went
through the endpoint-joining path intended for open fragments.
The patch changes the helper to check the first and last coordinates:
return !way.empty() && way.front() == way.back();Background
OSMStore::mergeMultiPolygonWays()documents the intended behavior:The old predicate did not implement that documented behavior. A closed way has
front() == back(), notbegin() == end().That means already-closed relation member ways could be mixed into the open-way
assembly path. That path is useful for fragmented multipolygon members, but it
uses start/end maps and iterative joining. Closed rings do not need that work,
and treating them as open fragments can change the order and shape of the
assembled result before correction, simplification, and clipping.
The incorrect predicate was introduced with the parallel PBF loading work in
#243. Later node-store refactoring in #590 changed the helper's vector type, but
kept the same iterator comparison.
Implementation
The implementation is intentionally limited to the helper predicate in
src/osm_store.cpp.It keeps the existing behavior for empty vectors by returning false, and it
does not change the multipolygon assembly algorithm for actual open fragments.
Evidence
I retested this locally against the submitted-PR stack using the Liechtenstein
Geofabrik fixture and the OpenMapTiles profile.
Within each variant, repeated runs were stable:
Comparing submitted stack against submitted stack plus this fix:
waterandlandcoverThe affected semantic tiles were:
water,class=lakewater,class=lakelandcover, grass/meadow geometrylandcover, grass/meadow geometryThe z12 changed feature was identified with
include_idsas:landuse=meadow,type=multipolygonVisual checks against OpenStreetMap reference rendering showed negligible
visual impact. The main reason for this patch is correcting the predicate so
closed relation-member rings follow the code path that
mergeMultiPolygonWays()already says they should follow.Performance
A larger local Austria timing check was run for performance only, without
semantic verification.
Configuration:
resources/config-openmaptiles.jsonresources/process-openmaptiles.luaMeasured results:
This is effectively performance-neutral on that fixture. The small RSS
difference is within the range I would treat as noise from one local run, so I
would not claim a memory improvement from this patch.
Related Issues And PRs
in the same broad area of multipolygon assembly correctness, but I have not
verified that it fixes that specific issue.
I did not find an existing open pull request for this exact predicate fix.
Possible Regressions
This can change multipolygon geometry for relations that contain already-closed
member ways, because those rings are now kept as closed members instead of being
handled by the open-fragment endpoint assembly path.
That is the intended behavior change and matches the local comment above
mergeMultiPolygonWays(). Actual open fragments still use the existing joininglogic.
The local fixture comparison found only geometry changes, no feature-count
changes. Performance impact should be neutral or negligible because the change
removes unnecessary open-fragment assembly work for closed rings.
Testing
Local checks used for the draft:
Fixture comparison:
The fixture was generated for the submitted-PR stack and the submitted-PR stack
plus this patch, then compared by decoded MVT content.