Parse decimal building heights#891
Open
Symmetricity wants to merge 1 commit into
Open
Conversation
The OpenMapTiles profile parsed height and building level tags with an explicit base argument to tonumber. Newer Lua runtimes reject decimal strings in that mode, so valid values such as height=18.5 and building:levels=3.5 fell back to the default one-floor render height while LuaJIT accepted them. Parse these fields without an explicit base so decimal OSM values are handled consistently across Lua runtimes without changing integer handling or fallback behavior.
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.
Parse decimal building heights
The OpenMapTiles profile parses
height,min_height,building:levels, andbuilding:min_levelwithtonumber(value, 10).That works for integer tags, but newer Lua versions reject decimal strings when
an explicit base is supplied. Valid OSM values such as
height=18.5andbuilding:levels=3.5therefore parse asniland fall back to the defaultone-floor render height. LuaJIT accepts the same values with the base argument,
so the same input can produce different
render_heightvalues depending on theLua runtime used to build tilemaker.
Parse these four fields with plain
tonumber(value)instead. That keepsinteger handling unchanged, accepts decimal OSM values, and makes the profile
consistent across Lua runtimes.
The change is intentionally scoped to the OpenMapTiles building height helper.
It does not alter layer selection, building feature counts, minzoom handling, or
the existing fallback height for buildings with no usable height/level tags.
Examples
The examples below are from Liechtenstein CI artifacts generated from the same
input.
Decimal
heightSource object:
OSM link:
Pre-fix output on a newer Lua runtime:
Pre-fix output on LuaJIT:
Post-fix output:
Decimal
building:levelsSource object:
OSM link:
Pre-fix output on a newer Lua runtime:
Pre-fix output on LuaJIT:
Post-fix output:
These examples show both parts of the bug: decimal tags were being ignored on
some Lua runtimes, and generated tile content could differ across CI runners
for the same input.
Reproduce
With a newer Lua runtime:
Before this change, the first expression returns
nil, soSetBuildingHeightAttributes()falls back toBUILDING_FLOOR_HEIGHT.After this change, decimal height and level values parse as numbers and the
rendered building attributes use the source tag values.
Testing
git diff --check origin/master..HEADluac -p resources/process-openmaptiles.luatonumber("18.5", 10)is rejected by the local newerLua runtime while
tonumber("18.5")is acceptedheightand decimalbuilding:levelsexamplesRelated Issues And PRs
Related upstream context:
tonumber.render_heightandrender_min_heightattributesfor 3D building rendering.
building:parthandling,but it does not directly address this Lua-runtime decimal parsing issue.
I did not find an existing upstream issue, PR, or discussion that directly
reports decimal building heights being ignored on newer Lua runtimes.