Skip to content

Commit

Permalink
OpenMapTiles implementation: Add missing attributes, use correct clas…
Browse files Browse the repository at this point in the history
…ses/subclasses (#543)

* Use different OSM tags as source for subclass in special cases

For tourism=information, amenity=place_of_worship and leisure=pitch,
class should contain information/place_of_worship/pitch and subclass
should contain the value of a special OSM tag
(information/religion/sport).

* Add attribute layer, level and indoor to poi layer
  • Loading branch information
Nakaner authored Oct 5, 2023
1 parent 439c6b1 commit 3c6197e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions resources/process-openmaptiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ poiClasses = { townhall="town_hall", public_building="town_hall", courthous
bag="clothing_store", clothes="clothing_store",
swimming_area="swimming", swimming="swimming",
castle="castle", ruins="castle" }
-- POI classes where class is the matching value and subclass is the value of a separate key
poiSubClasses = { information="information", place_of_worship="religion", pitch="sport" }
poiClassRanks = { hospital=1, railway=2, bus=3, attraction=4, harbor=5, college=6,
school=7, stadium=8, zoo=9, town_hall=10, campsite=11, cemetery=12,
park=13, library=14, police=15, post=16, golf=17, shop=18, grocery=19,
Expand Down Expand Up @@ -582,6 +584,15 @@ function WritePOI(obj,class,subclass,rank)
obj:AttributeNumeric("rank", rank)
obj:Attribute("class", class)
obj:Attribute("subclass", subclass)
-- layer defaults to 0
obj:AttributeNumeric("layer", tonumber(obj:Find("layer")) or 0)
-- indoor defaults to false
obj:AttributeBoolean("indoor", (obj:Find("indoor") == "yes"))
-- level has no default
local level = tonumber(obj:Find("level"))
if level then
obj:AttributeNumeric("level", level)
end
end

-- Set name attributes on any object
Expand Down Expand Up @@ -649,6 +660,11 @@ function GetPOIRank(obj)
v = obj:Find(k) -- k/v are the OSM tag pair
class = poiClasses[v] or k
rank = poiClassRanks[class] or 25
subclassKey = poiSubClasses[v]
if subclassKey then
class = v
v = obj:Find(subclassKey)
end
return rank, class, v
end
end
Expand Down

0 comments on commit 3c6197e

Please sign in to comment.