Skip to content

fix: relation_postscan_function erases tags of non-accepted child relations - #965

Open
dktue wants to merge 1 commit into
systemed:masterfrom
dktue:fix/postscan-untouched
Open

dktue wants to merge 1 commit into
systemed:masterfrom
dktue:fix/postscan-untouched

Conversation

@dktue

@dktue dktue commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Defining a relation_postscan_function changes the output even if the function does nothing. A multipolygon or boundary that is not accepted in relation_scan_function, but is a member of an accepted relation, loses all its tags and disappears from the tiles.

Cause: postScanRelations() loops over every relation that is a member of an accepted relation, accepted or not. For a non-accepted child, relation_tags(id) uses operator[] and inserts an empty tag map. From then on has_relation_tags() is true, so pbf_processor.cpp reads the relation with those empty tags instead of its real ones.

There's also relations_for_relation_with_parents(), which uses operator[] on relationsForRelations while postScanRelations() is iterating that map. Every top-level parent gets inserted, and then it's visited as well (with no parents). That's why postscan runs for some un-nested relations and not others, as reported in discussion #869.

Fix:

  • postScanRelations() skips relations with no stored tags, i.e. ones that weren't accepted.
  • relations_for_relation_with_parents() uses find() instead of operator[].
  • docs/RELATIONS.md says which relations the function is called for.

Tested with a synthetic file (master build vs. this PR, --threads 1): hiking route 100 inside superroute 200, an un-nested route 300, and a lake multipolygon 400 (not accepted) that is a member of 200.

master this PR
postscan called for 100, 200, 400 (400 with empty tags) 100
lake 400 in way_function no tags, not written (0 tiles) natural=water, written (5 tiles, same as without postscan)
route 100 name after SetTag from parent (documented example) Parent Parent

Makefile unit tests pass.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant