Skip to content

Commit

Permalink
look in relation for ISO3166 country code
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow committed Jan 6, 2024
1 parent 6b06eb5 commit 2f5ca20
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion resources/process-openmaptiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,17 @@ function node_function(node)
node:MinZoom(mz)
if rank then node:AttributeNumeric("rank", rank) end
if capital then node:AttributeNumeric("capital", capital) end
if place=="country" then node:Attribute("iso_a2", node:Find("ISO3166-1:alpha2")) end
if place=="country" then
local iso_a2 = node:Find("ISO3166-1:alpha2")
while iso_a2 == "" do
local rel, role = node:NextRelation()
if not rel then break end
if role == 'label' then
iso_a2 = node:FindInRelation("ISO3166-1:alpha2")
end
end
node:Attribute("iso_a2", iso_a2)
end
SetNameAttributes(node)
return
end
Expand Down

0 comments on commit 2f5ca20

Please sign in to comment.