From 3c6197e17efd4ef1f9f010a2cee733ede631a937 Mon Sep 17 00:00:00 2001 From: Nakaner Date: Thu, 5 Oct 2023 11:58:05 +0200 Subject: [PATCH] OpenMapTiles implementation: Add missing attributes, use correct classes/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 --- resources/process-openmaptiles.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index c121eb52..6c0cac4c 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -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, @@ -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 @@ -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