Repository navigation
how to keep all tags? #1017
|
I’m trying to generate tiles that retain all the OSM tags, using a simplistic Lua script like this one: But I always get this error Can you explain to me what is happening? |
Replies: 1 comment 9 replies
|
The 512 limit is not per node, it's for the whole run. tilemaker keeps one key table for every attribute key it writes across all objects and layers, and the key index is stored in 9 bits, so it can only hold 511 distinct keys (index 0 is a sentinel). See // This is very unlikely. We expect more like 50-100 keys.
if (newIndex >= 512)
throw std::out_of_range("more than 512 unique keys");and So your biggest node having 42 tags doesn't matter. Across all the amenity nodes in your extract there are more than 511 different keys ( There's no setting to raise it, so you have to cap the number of keys you write. One way is to keep the keys you actually style or query as real attributes and pack the rest into a single string attribute: node_keys = { "amenity" }
local keep = { amenity=true, name=true, cuisine=true, opening_hours=true, website=true }
function node_function()
Layer("amenity")
local rest = {}
for key, value in pairs(AllTags()) do
if keep[key] then
Attribute(key, value)
else
rest[#rest+1] = key .. "=" .. value
end
end
if #rest > 0 then
table.sort(rest)
Attribute("other_tags", table.concat(rest, ";"))
end
endThat writes at most 6 keys no matter what's in the data, and you can still split |
For a local build, no problem as far as I can see. The 9 bits only live in the
AttributePairbitfield. Everywhere else (key2index,getKey, the Lua attribute calls, the rank table) carries the key index as auint16_t, so the rest of the code already handles up to 65,535.Three spots to change for 12 bits:
include/attribute_store.h:unsigned short keyIndex : 12;src/attribute_store.cpp, inAttributeKeyStore::key2index:if (newIndex >= 512)becomesif (newIndex >= 4096), plus the message.test/attribute_store.test.cpparound line 120 expects the throw at the 512th key, so update that test or it fails.The cost is memory.
AttributePairis under#pragma pack(push, 1), and the three bitfields…