Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 53 additions & 20 deletions resources/process-openmaptiles.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Data processing based on openmaptiles.org schema
-- Data processing based on openmaptiles.org schema v3.15 (July 2024)
-- https://openmaptiles.org/schema/
-- Copyright (c) 2016, KlokanTech.com & OpenMapTiles contributors.
-- Used under CC-BY 4.0
Expand Down Expand Up @@ -233,28 +233,36 @@ unpavedValues = Set { "unpaved", "compacted", "dirt", "earth", "fine_gravel",
railwayClasses = { rail="rail", narrow_gauge="rail", preserved="rail", funicular="rail", subway="transit", light_rail="transit", monorail="transit", tram="transit" }

aerowayBuildings= Set { "terminal", "gate", "tower" }
landuseKeys = Set { "school", "university", "kindergarten", "college", "library", "hospital",
"railway", "cemetery", "military", "residential", "commercial", "industrial",
"retail", "stadium", "pitch", "playground", "theme_park", "bus_station", "zoo" }
-- landuse "class" values : based on OMT v3.15 https://github.com/openmaptiles/openmaptiles/blob/master/layers/landuse/mapping.yaml
landuseKeys = Set { "railway", "cemetery", "military", "quarry", "residential", "commercial", "industrial", "garages", "retail", -- from landuse tag
"bus_station", "school", "university", "kindergarten", "college", "library", "hospital", "grave_yard", -- from amenity tag
"stadium", "pitch", "playground", "track", --from leisure tag
"theme_park", "zoo", --from tourism tag
"suburb", "quarter", "neighbourhood", --from place tag
"dam" --from waterway tag
}
-- landcover "class" values : based on OMT v3.15 https://github.com/openmaptiles/openmaptiles/blob/master/layers/landcover/landcover.yaml
-- (wetland subclasses are not listed here but are managed below, in "Set 'landcover'" part)
landcoverKeys = { wood="wood", forest="wood",
wetland="wetland",
beach="sand", sand="sand", dune="sand",
farmland="farmland", farm="farmland", orchard="farmland", vineyard="farmland", plant_nursery="farmland",
glacier="ice", ice_shelf="ice",
bare_rock="rock", scree="rock",
fell="grass", grassland="grass", grass="grass", heath="grass", meadow="grass", allotments="grass", park="grass", village_green="grass", recreation_ground="grass", scrub="grass", shrubbery="grass", tundra="grass", garden="grass", golf_course="grass", park="grass" }
fell="grass", flowerbed="grass", grassland="grass", heath="grass", scrub="grass", shrubbery="grass", tundra="grass", grass="grass", meadow="grass", allotments="grass", park="grass", village_green="grass", recreation_ground="grass", garden="grass", golf_course="grass" }

-- POI key/value pairs: based on https://github.com/openmaptiles/openmaptiles/blob/master/layers/poi/mapping.yaml
poiTags = { aerialway = Set { "station" },
amenity = Set { "arts_centre", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten", "bus_station", "cafe", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors", "embassy", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital", "ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home", "parking", "pharmacy", "place_of_worship", "police", "post_box", "post_office", "prison", "pub", "public_building", "recycling", "restaurant", "school", "shelter", "swimming_pool", "taxi", "telephone", "theatre", "toilets", "townhall", "university", "veterinary", "waste_basket" },
amenity = Set { "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten", "bus_station", "cafe", "charging_station", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors", "drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital", "ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home", "parking", "pharmacy", "place_of_worship", "police", "parcel_locker", "post_box", "post_office", "prison", "pub", "public_building", "recycling", "restaurant", "school", "shelter", "swimming_pool", "taxi", "telephone", "theatre", "toilets", "townhall", "university", "veterinary", "waste_basket" },
barrier = Set { "bollard", "border_control", "cycle_barrier", "gate", "lift_gate", "sally_port", "stile", "toll_booth" },
building = Set { "dormitory" },
highway = Set { "bus_stop" },
historic = Set { "monument", "castle", "ruins" },
landuse = Set { "basin", "brownfield", "cemetery", "reservoir", "winter_sports" },
leisure = Set { "dog_park", "escape_game", "garden", "golf_course", "ice_rink", "hackerspace", "marina", "miniature_golf", "park", "pitch", "playground", "sports_centre", "stadium", "swimming_area", "swimming_pool", "water_park" },
office = Set { "accountant", "advertising_agency", "architect", "association", "bail_bond_agent", "charity", "company", "construction_company", "consulting", "cooperative", "courier", "coworking", "diplomatic", "educational_institution", "employment_agency", "energy_supplier", "engineer", "estate_agent", "financial", "financial_advisor", "forestry", "foundation", "geodesist", "government", "graphic_design", "guide", "harbour_master", "health_insurance", "insurance", "interior_design", "it", "lawyer", "logistics", "marketing", "moving_company", "newspaper", "ngo", "notary", "physician", "political_party", "private_investigator", "property_management", "publisher", "quango", "religion", "research", "security", "surveyor", "tax_advisor", "taxi", "telecommunication", "therapist", "translator", "travel_agent", "tutoring", "union", "university", "water_utility", "web_design", "wedding_planner" },
railway = Set { "halt", "station", "subway_entrance", "train_station_entrance", "tram_stop" },
shop = Set { "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages", "bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "carpet", "charity", "chemist", "chocolate", "clothes", "coffee", "computer", "confectionery", "convenience", "copyshop", "cosmetics", "deli", "delicatessen", "department_store", "doityourself", "dry_cleaning", "electronics", "erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer", "hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk", "lamps", "laundry", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument", "newsagent", "optician", "outdoor", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes", "sports", "stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency", "video", "video_games", "watches", "weapons", "wholesale", "wine" },
shop = Set { "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages", "bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "car_parts", "carpet", "charity", "chemist", "chocolate", "clothes", "coffee", "computer", "confectionery", "convenience", "copyshop", "cosmetics", "deli", "delicatessen", "department_store", "doityourself", "dry_cleaning", "electronics", "erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer", "hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk", "lamps", "laundry", "locksmith", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument", "newsagent", "optician", "outdoor", "paint", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes", "sports", "stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency", "video", "video_games", "watches", "weapons", "wholesale", "wine" },
sport = Set { "american_football", "archery", "athletics", "australian_football", "badminton", "baseball", "basketball", "beachvolleyball", "billiards", "bmx", "boules", "bowls", "boxing", "canadian_football", "canoe", "chess", "climbing", "climbing_adventure", "cricket", "cricket_nets", "croquet", "curling", "cycling", "disc_golf", "diving", "dog_racing", "equestrian", "fatsal", "field_hockey", "free_flying", "gaelic_games", "golf", "gymnastics", "handball", "hockey", "horse_racing", "horseshoes", "ice_hockey", "ice_stock", "judo", "karting", "korfball", "long_jump", "model_aerodrome", "motocross", "motor", "multi", "netball", "orienteering", "paddle_tennis", "paintball", "paragliding", "pelota", "racquet", "rc_car", "rowing", "rugby", "rugby_league", "rugby_union", "running", "sailing", "scuba_diving", "shooting", "shooting_range", "skateboard", "skating", "skiing", "soccer", "surfing", "swimming", "table_soccer", "table_tennis", "team_handball", "tennis", "toboggan", "volleyball", "water_ski", "yoga" },
tourism = Set { "alpine_hut", "aquarium", "artwork", "attraction", "bed_and_breakfast", "camp_site", "caravan_site", "chalet", "gallery", "guest_house", "hostel", "hotel", "information", "motel", "museum", "picnic_site", "theme_park", "viewpoint", "zoo" },
waterway = Set { "dock" } }
Expand All @@ -272,14 +280,14 @@ poiClasses = { townhall="town_hall", public_building="town_hall", courthous
books="library", library="library",
university="college", college="college",
hotel="lodging", motel="lodging", bed_and_breakfast="lodging", guest_house="lodging", hostel="lodging", chalet="lodging", alpine_hut="lodging", dormitory="lodging",
chocolate="ice_cream", confectionery="ice_cream",
post_box="post", post_office="post",
ice_cream="ice_cream",
post_box="post", post_office="post", parcel_locker="post",
cafe="cafe",
school="school", kindergarten="school",
alcohol="alcohol_shop", beverages="alcohol_shop", wine="alcohol_shop",
bar="bar", nightclub="bar",
marina="harbor", dock="harbor",
car="car", car_repair="car", taxi="car",
car="car", car_repair="car", car_parts="car", taxi="car",
hospital="hospital", nursing_home="hospital", clinic="hospital",
grave_yard="cemetery", cemetery="cemetery",
attraction="attraction", viewpoint="attraction",
Expand All @@ -289,14 +297,16 @@ poiClasses = { townhall="town_hall", public_building="town_hall", courthous
art="art_gallery", artwork="art_gallery", gallery="art_gallery", arts_centre="art_gallery",
bag="clothing_store", clothes="clothing_store",
swimming_area="swimming", swimming="swimming",
castle="castle", ruins="castle" }
castle="castle", ruins="castle",
atm="atm",
fuel="fuel", charging_station="fuel"}
-- 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,
fast_food=20, clothing_store=21, bar=22 }
waterClasses = Set { "river", "riverbank", "stream", "canal", "drain", "ditch", "dock" }
fast_food=20, clothing_store=21, office=22, bar=23 }
waterClasses = Set { "river", "stream", "canal", "ditch", "drain", "pond", "basin", "wastewater" }
waterwayClasses = Set { "stream", "river", "canal", "drain", "ditch" }

-- Scan relations for use in ways
Expand Down Expand Up @@ -583,7 +593,7 @@ function way_function()
end

-- 'Ferry'
if route=="ferry" then
if route=="ferry" or highway=="shipway" then
write_to_transportation_layer(9, "ferry", nil, false, nil, false, false, is_closed)

if HasNames() then
Expand Down Expand Up @@ -657,9 +667,15 @@ function way_function()
end

-- Set 'water'
if natural=="water" or leisure=="swimming_pool" or landuse=="reservoir" or landuse=="basin" or waterClasses[waterway] then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I think there was a typo with waterClasses[waterway] instead of waterClasses[water], right ?

-- water mapping : based on OMT v3.15 https://github.com/openmaptiles/openmaptiles/blob/master/layers/water/water.yaml
if natural=="water" or natural=="bay" or natural=="spring" or leisure=="swimming_pool" or landuse=="reservoir" or landuse=="basin" or landuse=="salt_pond" or waterway=="dock" or waterClasses[water] then
if Find("covered")=="yes" or not is_closed then return end
local class="lake"; if waterway~="" then class="river" end
local class="lake";
if waterway=="dock" then class="dock"
elseif leisure=="swimming_pool" then class="swimming_pool"
elseif landuse=="salt_pond" or water=="pond" or water=="basin" or water=="wastewater" then class="pond"
elseif waterClasses[water] then class="river" end --when water==river, stream, canal, ditch, drain

if class=="lake" and Find("wikidata")=="Q192770" then return end
Layer("water",true)
SetMinZoomByArea(way)
Expand All @@ -682,7 +698,7 @@ function way_function()
return -- in case we get any landuse processing
end

-- Set 'landcover' (from landuse, natural, leisure)
-- Set 'landcover' (from landuse, natural, leisure, wetland)
local l = landuse
if l=="" then l=natural end
if l=="" then l=leisure end
Expand All @@ -694,10 +710,12 @@ function way_function()
else Attribute("subclass", l) end
write_name = true

-- Set 'landuse'
-- Set 'landuse' (from landuse, amenity, leisure, tourism, place, waterway)
else
if l=="" then l=amenity end
if l=="" then l=tourism end
if l=="" then l=place end
if l=="" then l=waterway end
if landuseKeys[l] then
Layer("landuse", true)
Attribute("class", l)
Expand All @@ -711,8 +729,19 @@ function way_function()

-- Parks
-- **** name?
if boundary=="national_park" then Layer("park",true); Attribute("class",boundary); SetNameAttributes()
elseif leisure=="nature_reserve" then Layer("park",true); Attribute("class",leisure ); SetNameAttributes() end
if boundary=="national_park" or boundary=="protected_area" or leisure=="nature_reserve" then
Layer("park",true)
if leisure=="nature_reserve" then Attribute("class", leisure)
elseif boundary=="national_park" then Attribute("class", boundary)
elseif boundary=="protected_area" then
local protection_title = Find("protection_title")
if protection_title~="" then
class = protection_title:gsub(" ", "_"):lower()
Attribute("class", class)
end
end
SetNameAttributes()
end

-- POIs ('poi' and 'poi_detail')
local rank, class, subclass = GetPOIRank()
Expand Down Expand Up @@ -861,6 +890,10 @@ function GetPOIRank()
local shop = Find("shop")
if shop~="" then return poiClassRanks['shop'], "shop", shop end

-- Catch-all for offices
local office = Find("office")
if office~="" then return poiClassRanks['office'], "office", office end

-- Nothing found
return nil,nil,nil
end
Expand Down