Skip to content

Make POI tag key processing deterministic - #942

Open
TimSC wants to merge 1 commit into
systemed:masterfrom
TimSC:poiorder
Open

TimSC wants to merge 1 commit into
systemed:masterfrom
TimSC:poiorder

Conversation

@TimSC

@TimSC TimSC commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

GetPOIRank() picked a POI's class by looping over poiTags with pairs() and returning at the first key the object has. Lua doesn't define the order pairs() visits keys, and from Lua 5.2.1 onwards it varies from run to run because string hashing is seeded per Lua state. tilemaker creates a Lua state per thread, so the order can differ between threads within a single run.

Objects that match more than one key, such as amenity=cafe + shop=bakery or leisure=sports_centre + sport=swimming, could therefore get a different class, rank and subclass between runs. The same input could render differently, and tileset comparisons weren't reproducible.

Change

  • Build poiTagOrder at load time by sorting the keys of poiTags.
  • Loop over it with ipairs() in GetPOIRank().

The first matching key in alphabetical order now always wins. New keys added to poiTags are picked up automatically. This is applied to both process-openmaptiles.lua and process-debug.lua.

Effect

Some objects with several matching keys will get a different class than in some earlier runs. From now on, output for them is the same on every run.

@TimSC

TimSC commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

This is a different approach to #889 I don't know which is preferable.

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