Make POI tag ranking deterministic#889
Conversation
GetPOIRank returned the first matching POI tag group, but it iterated poiTags with pairs(). Lua does not specify table traversal order, so objects matching multiple POI groups could receive different class and rank values across runs or platforms. Iterate an explicit POI key list with ipairs() so the profile priority order is stable, and keep the subclass temporary local to the ranking function.
|
I added visual checks for the determinism issue. For this comparison I generated two local upstream outputs from the same binary, I also generated the PR output twice for the same objects; the selected POI tags The screenshots use a local Sportsplatz RheinwieseSource tags include
Schwimmbad MühleholzSource tags include
Tennishalle SchaanSource tags include
|



This PR is AI generated.
Make POI tag ranking deterministic
GetPOIRank()returns the first matching POI tag group. It currently iteratespoiTagswithpairs(), but Lua does not specify table traversal order fornon-array tables. That means an object with more than one matching POI tag can
receive different
class,subclass, and rank values depending on Lua tableiteration order.
Use an explicit
poiTagKeysarray and iterate it withipairs()so the POIpriority order matches the order already written in the profile. Apply the same
change to both OpenMapTiles profiles,
process-openmaptiles.luaandprocess-debug.lua.For example, an object with both of these tags has two valid POI matches:
Before this change, whichever key
pairs(poiTags)returned first determinedthe output. That could classify the same object as either:
or:
After this change,
amenityis checked beforetourism, matching the writtenprofile order, so the result is stable:
This is better because the profile already has a meaningful priority order, and
the rendered POI class/rank should not depend on Lua hash table traversal. Rank
affects POI prominence, while class and subclass affect downstream styling and
search semantics.
The change is intentionally small: it only changes the key iteration order used
by
GetPOIRank(). It does not alter the POI tag sets, rank tables, outputlayers, or tilemaker core code.
Reproduce
Load the OpenMapTiles process file and evaluate a POI that has multiple
matching tag groups, for example both
amenity=schoolandtourism=attraction:Before this change, the selected POI group depends on the unspecified order of
pairs(poiTags), so the object can be classified from a different matching taggroup on another Lua version, platform, or table layout.
After this change, the result follows the explicit profile order and is stable:
The same issue and fix apply to
resources/process-debug.lua.Testing
git diff --check origin/master..HEADluac -p resources/process-openmaptiles.lua resources/process-debug.luaGetPOIRank()in both process files using a POI withamenity=schoolandtourism=attraction; both returned7:school:schoolRelated Issues And PRs
I did not find an existing upstream issue, PR, or discussion that directly
reports this
pairs(poiTags)ordering issue.Related POI context:
process-openmaptiles.luato match newerOpenMapTiles POI schema coverage. This PR does not change the schema mapping;
it only makes the current mapping order deterministic.