From 2019adf50bc4e0b1a765eea0f732a7cc81e402a0 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Mon, 5 Feb 2024 13:35:01 +0100 Subject: [PATCH 01/16] Add missing features classes to landcover layer. They are already documented but have been missing in the implementation. --- resources/process-openmaptiles.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 5e7f05d8..b98d3a45 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -227,10 +227,11 @@ landuseKeys = Set { "school", "university", "kindergarten", "college", "libr "retail", "stadium", "pitch", "playground", "theme_park", "bus_station", "zoo" } landcoverKeys = { wood="wood", forest="wood", wetland="wetland", - beach="sand", sand="sand", + beach="sand", sand="sand", dune="sand", farmland="farmland", farm="farmland", orchard="farmland", vineyard="farmland", plant_nursery="farmland", glacier="ice", ice_shelf="ice", - grassland="grass", grass="grass", meadow="grass", allotments="grass", park="grass", village_green="grass", recreation_ground="grass", garden="grass", golf_course="grass" } + 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" } -- POI key/value pairs: based on https://github.com/openmaptiles/openmaptiles/blob/master/layers/poi/mapping.yaml poiTags = { aerialway = Set { "station" }, From f9cfe93479b3b628aa9358c972b97a67aa39e56b Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 16 Feb 2024 14:30:48 +0100 Subject: [PATCH 02/16] Add missing place values, add islands mapped as polygons --- resources/process-openmaptiles.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index b98d3a45..3830d208 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -156,15 +156,20 @@ function node_function() elseif pop>20000000 then rank=2; mz=2 else rank=3; mz=3 end elseif place == "state" then mz=4 + elseif place == "province" then mz=5 elseif place == "city" then mz=5 elseif place == "town" and pop>8000 then mz=7 elseif place == "town" then mz=8 elseif place == "village" and pop>2000 then mz=9 elseif place == "village" then mz=10 + elseif place == "borough" then mz=10 elseif place == "suburb" then mz=11 + elseif place == "quarter" then mz=12 elseif place == "hamlet" then mz=12 elseif place == "neighbourhood" then mz=13 + elseif place == "isolated_dwelling" then mz=13 elseif place == "locality" then mz=13 + elseif place == "island" then mz=12 end Layer("place", false) @@ -353,6 +358,7 @@ function way_function() local tourism = Find("tourism") local man_made = Find("man_made") local boundary = Find("boundary") + local place = Find("place") local isClosed = IsClosed() local housenumber = Find("addr:housenumber") local write_name = false @@ -366,6 +372,17 @@ function way_function() if landuse == "field" then landuse = "farmland" end if landuse == "meadow" and Find("meadow")=="agricultural" then landuse="farmland" end + if place == "island" then + LayerAsCentroid("place") + Attribute("class", place) + MinZoom(10) + local pop = tonumber(Find("population")) or 0 + local capital = capitalLevel(Find("capital")) + local rank = calcRank(place, pop, nil) + if rank then AttributeNumeric("rank", rank) end + SetNameAttributes() + end + -- Boundaries within relations -- note that we process administrative boundaries as properties on ways, rather than as single relation geometries, -- because otherwise we get multiple renderings where boundaries are coterminous From 769387f36394aa5b5ec254698790dad5e34eca7c Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 16 Feb 2024 15:53:43 +0100 Subject: [PATCH 03/16] Hand over variables to the function instead of relying on global access --- resources/process-openmaptiles.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 3830d208..29bd20da 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -301,7 +301,7 @@ function relation_scan_function() end end -function write_to_transportation_layer(minzoom, highway_class) +function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service) Layer("transportation", false) MinZoom(minzoom) SetZOrder() @@ -467,7 +467,7 @@ function way_function() -- Write to layer if minzoom <= 14 then - write_to_transportation_layer(minzoom, h) + write_to_transportation_layer(minzoom, h, subclass, ramp, service) -- Write names if minzoom < 8 then From ed61ac98aae7f3840c4378078b61884dcfe82c5b Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 21 Feb 2024 18:19:00 +0100 Subject: [PATCH 04/16] Set correct minzoom for railway features, add railway subclass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minzoom for railway features depends on railway=*, service=* and usage=*. Only railway features with specific railway=* values are added to the vector tiles. This means, railway=construction/disused/… and railway=fancy_value are ignored. The OpenMapTiles schema defines a subclass field for railways as well. This commit adds this field. --- resources/process-openmaptiles.lua | 73 ++++++++++++++++++------------ 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 29bd20da..476b6539 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -225,6 +225,7 @@ linkValues = Set { "motorway_link", "trunk_link", "primary_link", "secondar constructionValues = Set { "primary", "secondary", "tertiary", "motorway", "service", "trunk", "track" } pavedValues = Set { "paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal", "paving_stones", "sett", "unhewn_cobblestone", "wood" } unpavedValues = Set { "unpaved", "compacted", "dirt", "earth", "fine_gravel", "grass", "grass_paver", "gravel", "gravel_turf", "ground", "ice", "mud", "pebblestone", "salt", "sand", "snow", "woodchips" } +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", @@ -301,7 +302,7 @@ function relation_scan_function() end end -function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service) +function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service, is_rail) Layer("transportation", false) MinZoom(minzoom) SetZOrder() @@ -310,7 +311,7 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if ramp then AttributeNumeric("ramp",1) end -- Service - if highway == "service" and service ~="" then Attribute("service", service) end + if (is_rail or highway == "service") and service ~="" then Attribute("service", service) end local oneway = Find("oneway") if oneway == "yes" or oneway == "1" then @@ -319,22 +320,26 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if oneway == "-1" then -- **** TODO end - local surface = Find("surface") - local surfaceMinzoom = 12 - if pavedValues[surface] then - Attribute("surface", "paved", surfaceMinzoom) - elseif unpavedValues[surface] then - Attribute("surface", "unpaved", surfaceMinzoom) + if not is_rail then + local surface = Find("surface") + local surfaceMinzoom = 12 + if pavedValues[surface] then + Attribute("surface", "paved", surfaceMinzoom) + elseif unpavedValues[surface] then + Attribute("surface", "unpaved", surfaceMinzoom) + end end local accessMinzoom = 9 - if Holds("access") then Attribute("access", Find("access"), accessMinzoom) end - if Holds("bicycle") then Attribute("bicycle", Find("bicycle"), accessMinzoom) end - if Holds("foot") then Attribute("foot", Find("foot"), accessMinzoom) end - if Holds("horse") then Attribute("horse", Find("horse"), accessMinzoom) end - AttributeBoolean("toll", Find("toll") == "yes", accessMinzoom) + if not is_rail then + if Holds("access") then Attribute("access", Find("access"), accessMinzoom) end + if Holds("bicycle") then Attribute("bicycle", Find("bicycle"), accessMinzoom) end + if Holds("foot") then Attribute("foot", Find("foot"), accessMinzoom) end + if Holds("horse") then Attribute("horse", Find("horse"), accessMinzoom) end + AttributeBoolean("toll", Find("toll") == "yes", accessMinzoom) + AttributeBoolean("expressway", Find("expressway"), 7) + Attribute("mtb_scale", Find("mtb:scale"), 10) + end AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) - AttributeBoolean("expressway", Find("expressway"), 7) - Attribute("mtb_scale", Find("mtb:scale"), 10) end -- Process way tags @@ -467,7 +472,7 @@ function way_function() -- Write to layer if minzoom <= 14 then - write_to_transportation_layer(minzoom, h, subclass, ramp, service) + write_to_transportation_layer(minzoom, h, subclass, ramp, service, false) -- Write names if minzoom < 8 then @@ -497,21 +502,29 @@ function way_function() -- Railways ('transportation' and 'transportation_name', plus 'transportation_name_detail') if railway~="" then - Layer("transportation", false) - Attribute("class", railway) - SetZOrder() - SetBrunnelAttributes() - if service~="" then - Attribute("service", service) - MinZoom(12) - else - MinZoom(9) - end + local class = railwayClasses[railway] + if class then + local minzoom = 14 + Layer("transportation", false) + local usage = Find("usage") + if railway == "rail" and service == "" then + if usage == "main" then + minzoom = 8 + else + minzoom = 10 + end + elseif railway == "narrow_gauge" and service == "" then + minzoom = 10 + elseif railway == "light_rail" and service == "" then + minzoom = 11 + end + write_to_transportation_layer(minzoom, class, railway, false, service, true) - Layer("transportation_name", false) - SetNameAttributes() - MinZoom(14) - Attribute("class", "rail") + Layer("transportation_name", false) + SetNameAttributes() + MinZoom(14) + Attribute("class", "rail") + end end -- Pier From 053f2b7386bf3af1c32d4a80a93304428aa6439c Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 21 Feb 2024 18:39:43 +0100 Subject: [PATCH 05/16] Drop railway features without names from transportation_name It makes vector tiles smaller if we do not add railway features without names to the vector tiles. --- resources/process-openmaptiles.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 476b6539..82b12d9b 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -520,10 +520,12 @@ function way_function() end write_to_transportation_layer(minzoom, class, railway, false, service, true) - Layer("transportation_name", false) - SetNameAttributes() - MinZoom(14) - Attribute("class", "rail") + if HasNames() then + Layer("transportation_name", false) + SetNameAttributes() + MinZoom(14) + Attribute("class", class) + end end end @@ -720,6 +722,19 @@ function WritePOI(class,subclass,rank) end end +-- Check if there are name tags on the object +function HasNames() + if Holds("name") then return true end + local iname + local main_written = name + if preferred_language and Holds("name:"..preferred_language) then return true end + -- then set any additional languages + for i,lang in ipairs(additional_languages) do + if Holds("name:"..lang) then return true end + end + return false +end + -- Set name attributes on any object function SetNameAttributes() local name = Find("name"), iname From ec5d13ec2b4ed2a1d17c870e03c027228856f567 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 21 Feb 2024 18:49:48 +0100 Subject: [PATCH 06/16] Cleanup transportation_name, drop roads without name or ref from it * Drop layers transportation_name_mid and transportation_name_detail, use MinZoom() instead. * Do not write roads without names or ref into the vector tiles. --- resources/config-openmaptiles.json | 2 -- resources/process-openmaptiles.lua | 43 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/resources/config-openmaptiles.json b/resources/config-openmaptiles.json index 99aa4d77..01d23bfd 100644 --- a/resources/config-openmaptiles.json +++ b/resources/config-openmaptiles.json @@ -13,8 +13,6 @@ "transportation": { "minzoom": 4, "maxzoom": 14, "simplify_below": 13, "simplify_level": 0.0003 }, "transportation_name": { "minzoom": 8, "maxzoom": 14 }, - "transportation_name_mid": { "minzoom": 12, "maxzoom": 14, "write_to": "transportation_name" }, - "transportation_name_detail": { "minzoom": 14, "maxzoom": 14, "write_to": "transportation_name" }, "building": { "minzoom": 13, "maxzoom": 14 }, diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 82b12d9b..51b33570 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -428,7 +428,7 @@ function way_function() end end - -- Roads ('transportation' and 'transportation_name', plus 'transportation_name_detail') + -- Roads ('transportation' and 'transportation_name') if highway~="" then local access = Find("access") local surface = Find("surface") @@ -475,32 +475,33 @@ function way_function() write_to_transportation_layer(minzoom, h, subclass, ramp, service, false) -- Write names - if minzoom < 8 then - minzoom = 8 - end - if highway == "motorway" or highway == "trunk" then + if HasNames() or Holds("ref") then + if minzoom < 8 then + minzoom = 8 + end + if highway == "motorway" or highway == "trunk" then + minzoom = math.max(8, minzoom) + elseif h == "minor" or h == "track" or h == "path" or h == "service" then + minzoom = 14 + else + minzoom = math.max(12, minzoom) + end Layer("transportation_name", false) MinZoom(minzoom) - elseif h == "minor" or h == "track" or h == "path" or h == "service" then - Layer("transportation_name_detail", false) - MinZoom(minzoom) - else - Layer("transportation_name_mid", false) - MinZoom(minzoom) - end - SetNameAttributes() - Attribute("class",h) - Attribute("network","road") -- **** could also be us-interstate, us-highway, us-state - if h~=highway then Attribute("subclass",highway) end - local ref = Find("ref") - if ref~="" then - Attribute("ref",ref) - AttributeNumeric("ref_length",ref:len()) + SetNameAttributes() + Attribute("class",h) + Attribute("network","road") -- **** could also be us-interstate, us-highway, us-state + if h~=highway then Attribute("subclass",highway) end + local ref = Find("ref") + if ref~="" then + Attribute("ref",ref) + AttributeNumeric("ref_length",ref:len()) + end end end end - -- Railways ('transportation' and 'transportation_name', plus 'transportation_name_detail') + -- Railways ('transportation' and 'transportation_name') if railway~="" then local class = railwayClasses[railway] if class then From 8c39dc578956a7b9e47cb9e4f4c68f6051d37fc1 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 21 Feb 2024 18:54:55 +0100 Subject: [PATCH 07/16] Use write_to_transportation_layer function for ferries --- resources/process-openmaptiles.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 51b33570..87e941e1 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -540,11 +540,7 @@ function way_function() -- 'Ferry' if route=="ferry" then - Layer("transportation", false) - Attribute("class", "ferry") - SetZOrder() - MinZoom(9) - SetBrunnelAttributes() + write_to_transportation_layer(9, "ferry", nil, false, nil, false) Layer("transportation_name", false) SetNameAttributes() From eb8acbcfa53d7c92e7bc7a996ef4663e3a72956b Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Wed, 21 Feb 2024 18:56:24 +0100 Subject: [PATCH 08/16] Do not write ferries without names to the vector tiles --- resources/process-openmaptiles.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 87e941e1..d197bbb5 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -542,10 +542,12 @@ function way_function() if route=="ferry" then write_to_transportation_layer(9, "ferry", nil, false, nil, false) - Layer("transportation_name", false) - SetNameAttributes() - MinZoom(12) - Attribute("class", "ferry") + if HasNames() then + Layer("transportation_name", false) + SetNameAttributes() + MinZoom(12) + Attribute("class", "ferry") + end end -- 'Aeroway' From c3d45328a8950fed5d34f2844eef6d733d3dac33 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 22 Feb 2024 14:26:51 +0100 Subject: [PATCH 09/16] transportation* layers: minzoom, construction, raceway * Set correct minzoom values for all roads in the transportation and transportation_name layer. * Add highway=raceway * Align handling of roads under construction to OpenMapTiles. --- resources/process-openmaptiles.lua | 80 ++++++++++++++++-------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index d197bbb5..1ba53770 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -216,13 +216,15 @@ end -- Process way tags majorRoadValues = Set { "motorway", "trunk", "primary" } -mainRoadValues = Set { "secondary", "motorway_link", "trunk_link", "primary_link", "secondary_link" } -midRoadValues = Set { "tertiary", "tertiary_link" } -minorRoadValues = Set { "unclassified", "residential", "road", "living_street" } -trackValues = Set { "track" } +z9RoadValues = Set { "secondary", "motorway_link", "trunk_link" } +z10RoadValues = Set { "primary_link", "secondary_link" } +z11RoadValues = Set { "tertiary", "tertiary_link", "busway", "bus_guideway" } +-- On zoom 12, various road classes are merged into "minor" +z12MinorRoadValues = Set { "unclassified", "residential", "road", "living_street" } +z12OtherRoadValues = Set { "raceway" } +z13RoadValues = Set { "track", "service" } pathValues = Set { "footway", "cycleway", "bridleway", "path", "steps", "pedestrian" } linkValues = Set { "motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link" } -constructionValues = Set { "primary", "secondary", "tertiary", "motorway", "service", "trunk", "track" } pavedValues = Set { "paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal", "paving_stones", "sett", "unhewn_cobblestone", "wood" } unpavedValues = Set { "unpaved", "compacted", "dirt", "earth", "fine_gravel", "grass", "grass_paver", "gravel", "gravel_turf", "ground", "ice", "mud", "pebblestone", "salt", "sand", "snow", "woodchips" } railwayClasses = { rail="rail", narrow_gauge="rail", preserved="rail", funicular="rail", subway="transit", light_rail="transit", monorail="transit", tram="transit" } @@ -434,40 +436,41 @@ function way_function() local surface = Find("surface") local h = highway + local subclass = nil + local under_construction = false + if highway == "construction" and construction ~= "" then + h = construction + under_construction = true + end local minzoom = 99 - local layer = "transportation" - if majorRoadValues[highway] then minzoom = 4 end - if highway == "trunk" then minzoom = 5 - elseif highway == "primary" then minzoom = 7 end - if mainRoadValues[highway] then minzoom = 9 end - if midRoadValues[highway] then minzoom = 11 end - if minorRoadValues[highway] then h = "minor"; minzoom = 12 end - if trackValues[highway] then h = "track"; minzoom = 14 end - if pathValues[highway] then h = "path" ; minzoom = 14 end - if h=="service" then minzoom = 12 end + if majorRoadValues[h] then minzoom = 4 + elseif h == "trunk" then minzoom = 5 + elseif highway == "primary" then minzoom = 7 + elseif z9RoadValues[h] then minzoom = 9 + elseif z11RoadValues[h] then minzoom = 11 + elseif z12MinorRoadValues[h] then + minzoom = 12 + subclass = h + h = "minor" + elseif z12OtherRoadValues[h] then minzoom = 12 + elseif z13RoadValues[h] then minzoom = 13 + elseif pathValues[h] then + minzoom = 14 + subclass = h + h = "path" + end -- Links (ramp) local ramp=false - if linkValues[highway] then + if linkValues[h] then splitHighway = split(highway, "_") highway = splitHighway[1]; h = highway ramp = true - minzoom = 11 end -- Construction - if highway == "construction" then - if constructionValues[construction] then - h = construction .. "_construction" - if construction ~= "service" and construction ~= "track" then - minzoom = 11 - else - minzoom = 12 - end - else - h = "minor_construction" - minzoom = 14 - end + if under_construction then + h = h .. "_construction" end -- Write to layer @@ -476,22 +479,25 @@ function way_function() -- Write names if HasNames() or Holds("ref") then - if minzoom < 8 then + if h == "motorway" then + minzoom = 7 + elseif h == "trunk" then minzoom = 8 - end - if highway == "motorway" or highway == "trunk" then - minzoom = math.max(8, minzoom) - elseif h == "minor" or h == "track" or h == "path" or h == "service" then - minzoom = 14 + elseif h == "primary" then + minzoom = 10 + elseif h == "secondary" then + minzoom = 11 + elseif h == "minor" or h == "track" or h == "tertiary" then + minzoom = 13 else - minzoom = math.max(12, minzoom) + minzoom = 14 end Layer("transportation_name", false) MinZoom(minzoom) SetNameAttributes() Attribute("class",h) Attribute("network","road") -- **** could also be us-interstate, us-highway, us-state - if h~=highway then Attribute("subclass",highway) end + if subclass then Attribute("subclass", highway) end local ref = Find("ref") if ref~="" then Attribute("ref",ref) From 1627c5dfb4c055a91197203ecefe84412291cbc0 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 22 Feb 2024 14:32:29 +0100 Subject: [PATCH 10/16] Do not set mtb_scale if the tag is not present --- resources/process-openmaptiles.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 1ba53770..459846c8 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -339,7 +339,7 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if Holds("horse") then Attribute("horse", Find("horse"), accessMinzoom) end AttributeBoolean("toll", Find("toll") == "yes", accessMinzoom) AttributeBoolean("expressway", Find("expressway"), 7) - Attribute("mtb_scale", Find("mtb:scale"), 10) + if Holds("mtb_scale") then Attribute("mtb_scale", Find("mtb:scale"), 10) end end AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) end From 436687fa54f03362f69fbb3d5e3ca2240ea81178 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 22 Feb 2024 14:59:52 +0100 Subject: [PATCH 11/16] Add aerialways --- resources/process-openmaptiles.lua | 43 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 459846c8..cc1a404d 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -304,7 +304,7 @@ function relation_scan_function() end end -function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service, is_rail) +function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service, is_rail, is_road) Layer("transportation", false) MinZoom(minzoom) SetZOrder() @@ -313,16 +313,17 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if ramp then AttributeNumeric("ramp",1) end -- Service - if (is_rail or highway == "service") and service ~="" then Attribute("service", service) end + if (is_rail or highway_class == "service") and service ~="" then Attribute("service", service) end - local oneway = Find("oneway") - if oneway == "yes" or oneway == "1" then - AttributeNumeric("oneway",1) - end - if oneway == "-1" then - -- **** TODO - end - if not is_rail then + local accessMinzoom = 9 + if is_road then + local oneway = Find("oneway") + if oneway == "yes" or oneway == "1" then + AttributeNumeric("oneway",1) + end + if oneway == "-1" then + -- **** TODO + end local surface = Find("surface") local surfaceMinzoom = 12 if pavedValues[surface] then @@ -330,9 +331,6 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s elseif unpavedValues[surface] then Attribute("surface", "unpaved", surfaceMinzoom) end - end - local accessMinzoom = 9 - if not is_rail then if Holds("access") then Attribute("access", Find("access"), accessMinzoom) end if Holds("bicycle") then Attribute("bicycle", Find("bicycle"), accessMinzoom) end if Holds("foot") then Attribute("foot", Find("foot"), accessMinzoom) end @@ -365,6 +363,7 @@ function way_function() local tourism = Find("tourism") local man_made = Find("man_made") local boundary = Find("boundary") + local aerialway = Find("aerialway") local place = Find("place") local isClosed = IsClosed() local housenumber = Find("addr:housenumber") @@ -430,6 +429,18 @@ function way_function() end end + -- Aerialways ('transportation' and 'transportation_name') + if aerialway ~= "" then + write_to_transportation_layer(12, "aerialway", aerialway, false, nil, false, false) + if HasNames() then + Layer("transportation_name", false) + MinZoom(12) + SetNameAttributes() + Attribute("class", "aerialway") + Attribute("subclass", aerialway) + end + end + -- Roads ('transportation' and 'transportation_name') if highway~="" then local access = Find("access") @@ -475,7 +486,7 @@ function way_function() -- Write to layer if minzoom <= 14 then - write_to_transportation_layer(minzoom, h, subclass, ramp, service, false) + write_to_transportation_layer(minzoom, h, subclass, ramp, service, false, true) -- Write names if HasNames() or Holds("ref") then @@ -525,7 +536,7 @@ function way_function() elseif railway == "light_rail" and service == "" then minzoom = 11 end - write_to_transportation_layer(minzoom, class, railway, false, service, true) + write_to_transportation_layer(minzoom, class, railway, false, service, true, false) if HasNames() then Layer("transportation_name", false) @@ -546,7 +557,7 @@ function way_function() -- 'Ferry' if route=="ferry" then - write_to_transportation_layer(9, "ferry", nil, false, nil, false) + write_to_transportation_layer(9, "ferry", nil, false, nil, false, false) if HasNames() then Layer("transportation_name", false) From d328219b9cf445d0d1b020258887f419dae14595 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Thu, 22 Feb 2024 15:03:41 +0100 Subject: [PATCH 12/16] Do not set expressway if the tag is missing --- resources/process-openmaptiles.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index cc1a404d..388a459b 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -336,7 +336,7 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if Holds("foot") then Attribute("foot", Find("foot"), accessMinzoom) end if Holds("horse") then Attribute("horse", Find("horse"), accessMinzoom) end AttributeBoolean("toll", Find("toll") == "yes", accessMinzoom) - AttributeBoolean("expressway", Find("expressway"), 7) + if Find("expressway") == "yes" then AttributeBoolean("expressway", true, 7) end if Holds("mtb_scale") then Attribute("mtb_scale", Find("mtb:scale"), 10) end end AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) From f50a5950ac62fdd0ab0d36241f0dec30ead631d2 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 23 Feb 2024 13:59:50 +0100 Subject: [PATCH 13/16] Add areas for pedestrians, add platforms --- resources/process-openmaptiles.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 388a459b..0adc224d 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -42,6 +42,8 @@ ZRES13 = 19.1 -- The height of one floor, in meters BUILDING_FLOOR_HEIGHT = 3.66 +-- Used to express that a feature should not end up the vector tiles +INVALID_ZOOM = 99 -- Process node/way tags aerodromeValues = Set { "international", "public", "regional", "military", "private" } @@ -223,7 +225,7 @@ z11RoadValues = Set { "tertiary", "tertiary_link", "busway", "bus_guideway" } z12MinorRoadValues = Set { "unclassified", "residential", "road", "living_street" } z12OtherRoadValues = Set { "raceway" } z13RoadValues = Set { "track", "service" } -pathValues = Set { "footway", "cycleway", "bridleway", "path", "steps", "pedestrian" } +pathValues = Set { "footway", "cycleway", "bridleway", "path", "steps", "pedestrian", "platform" } linkValues = Set { "motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link" } pavedValues = Set { "paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal", "paving_stones", "sett", "unhewn_cobblestone", "wood" } unpavedValues = Set { "unpaved", "compacted", "dirt", "earth", "fine_gravel", "grass", "grass_paver", "gravel", "gravel_turf", "ground", "ice", "mud", "pebblestone", "salt", "sand", "snow", "woodchips" } @@ -305,7 +307,7 @@ function relation_scan_function() end function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service, is_rail, is_road) - Layer("transportation", false) + Layer("transportation", IsClosed()) MinZoom(minzoom) SetZOrder() Attribute("class", highway_class) @@ -364,6 +366,7 @@ function way_function() local man_made = Find("man_made") local boundary = Find("boundary") local aerialway = Find("aerialway") + local public_transport = Find("public_transport") local place = Find("place") local isClosed = IsClosed() local housenumber = Find("addr:housenumber") @@ -442,18 +445,23 @@ function way_function() end -- Roads ('transportation' and 'transportation_name') - if highway~="" then + if highway ~= "" or public_transport == "platform" then local access = Find("access") local surface = Find("surface") local h = highway + local is_road = true + if h == "" then + h = public_transport + is_road = false + end local subclass = nil local under_construction = false if highway == "construction" and construction ~= "" then h = construction under_construction = true end - local minzoom = 99 + local minzoom = INVALID_ZOOM if majorRoadValues[h] then minzoom = 4 elseif h == "trunk" then minzoom = 5 elseif highway == "primary" then minzoom = 7 @@ -484,9 +492,16 @@ function way_function() h = h .. "_construction" end + -- Drop underground platforms + local layer = Find("layer") + local layerNumeric = tonumber(layer) + if not is_road and layerNumeric ~= nil and layerNumeric < 0 then + minzoom = INVALID_ZOOM + end + -- Write to layer if minzoom <= 14 then - write_to_transportation_layer(minzoom, h, subclass, ramp, service, false, true) + write_to_transportation_layer(minzoom, h, subclass, ramp, service, false, is_road) -- Write names if HasNames() or Holds("ref") then From d60369751a1d0b4e7c24f4335cec1707ac842441 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 23 Feb 2024 14:13:13 +0100 Subject: [PATCH 14/16] Add missing subclass attribute to transportation layer --- resources/process-openmaptiles.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 0adc224d..0a413f47 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -311,6 +311,9 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s MinZoom(minzoom) SetZOrder() Attribute("class", highway_class) + if subclass and subclass ~= "" then + Attribute("subclass", subclass) + end SetBrunnelAttributes() if ramp then AttributeNumeric("ramp",1) end From 75a19c76f269a673103d9eb8818104aa8663a69a Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 23 Feb 2024 15:39:03 +0100 Subject: [PATCH 15/16] Improve handling of polygons on transporation layer * Do not write polygons other than infrastructure for pedestrians and piers. * Set minzoom according to area size and absolute minzoom. --- resources/process-openmaptiles.lua | 44 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index 0a413f47..a92851b7 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -308,17 +308,23 @@ end function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, service, is_rail, is_road) Layer("transportation", IsClosed()) - MinZoom(minzoom) SetZOrder() Attribute("class", highway_class) if subclass and subclass ~= "" then Attribute("subclass", subclass) end + AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) + -- We do not write any other attributes for areas. + if IsClosed() then + SetMinZoomByAreaWithLimit(minzoom) + return + end + MinZoom(minzoom) SetBrunnelAttributes() if ramp then AttributeNumeric("ramp",1) end -- Service - if (is_rail or highway_class == "service") and service ~="" then Attribute("service", service) end + if (is_rail or highway_class == "service") and (service and service ~="") then Attribute("service", service) end local accessMinzoom = 9 if is_road then @@ -344,7 +350,6 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s if Find("expressway") == "yes" then AttributeBoolean("expressway", true, 7) end if Holds("mtb_scale") then Attribute("mtb_scale", Find("mtb:scale"), 10) end end - AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) end -- Process way tags @@ -502,12 +507,17 @@ function way_function() minzoom = INVALID_ZOOM end + -- Drop all areas except infrastructure for pedestrians handled above + if isClosed and h ~= "path" then + minzoom = INVALID_ZOOM + end + -- Write to layer if minzoom <= 14 then write_to_transportation_layer(minzoom, h, subclass, ramp, service, false, is_road) -- Write names - if HasNames() or Holds("ref") then + if not isClosed and (HasNames() or Holds("ref")) then if h == "motorway" then minzoom = 7 elseif h == "trunk" then @@ -567,10 +577,7 @@ function way_function() -- Pier if man_made=="pier" then - Layer("transportation", isClosed) - SetZOrder() - Attribute("class", "pier") - SetMinZoomByArea() + write_to_transportation_layer(13, "pier", nil, false, nil, false, false) end -- 'Ferry' @@ -811,15 +818,20 @@ end -- Set minimum zoom level by area function SetMinZoomByArea() + SetMinZoomByAreaWithLimit(0) +end + +-- Set minimum zoom level by area but not below given minzoom +function SetMinZoomByAreaWithLimit(minzoom) local area=Area() - if area>ZRES5^2 then MinZoom(6) - elseif area>ZRES6^2 then MinZoom(7) - elseif area>ZRES7^2 then MinZoom(8) - elseif area>ZRES8^2 then MinZoom(9) - elseif area>ZRES9^2 then MinZoom(10) - elseif area>ZRES10^2 then MinZoom(11) - elseif area>ZRES11^2 then MinZoom(12) - elseif area>ZRES12^2 then MinZoom(13) + if minzoom <= 6 and area>ZRES5^2 then MinZoom(6) + elseif minzoom <= 7 and area>ZRES6^2 then MinZoom(7) + elseif minzoom <= 8 and area>ZRES7^2 then MinZoom(8) + elseif minzoom <= 9 and area>ZRES8^2 then MinZoom(9) + elseif minzoom <= 10 and area>ZRES9^2 then MinZoom(10) + elseif minzoom <= 11 and area>ZRES10^2 then MinZoom(11) + elseif minzoom <= 12 and area>ZRES11^2 then MinZoom(12) + elseif minzoom <= 13 and area>ZRES12^2 then MinZoom(13) else MinZoom(14) end end From 44dc85196c8a6237061f99c45d5a3e78dacbe5ea Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 23 Feb 2024 16:39:39 +0100 Subject: [PATCH 16/16] Add man_made=bridge, add brunnel attribute for polygons * Add man_made=bridge to layer transportation. * Set brunnel attribute for all polygon features on that layer. --- resources/process-openmaptiles.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/process-openmaptiles.lua b/resources/process-openmaptiles.lua index a92851b7..60dcbd0c 100644 --- a/resources/process-openmaptiles.lua +++ b/resources/process-openmaptiles.lua @@ -225,6 +225,7 @@ z11RoadValues = Set { "tertiary", "tertiary_link", "busway", "bus_guideway" } z12MinorRoadValues = Set { "unclassified", "residential", "road", "living_street" } z12OtherRoadValues = Set { "raceway" } z13RoadValues = Set { "track", "service" } +manMadRoadValues = Set { "pier", "bridge" } pathValues = Set { "footway", "cycleway", "bridleway", "path", "steps", "pedestrian", "platform" } linkValues = Set { "motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link" } pavedValues = Set { "paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal", "paving_stones", "sett", "unhewn_cobblestone", "wood" } @@ -314,13 +315,13 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s Attribute("subclass", subclass) end AttributeNumeric("layer", tonumber(Find("layer")) or 0, accessMinzoom) + SetBrunnelAttributes() -- We do not write any other attributes for areas. if IsClosed() then SetMinZoomByAreaWithLimit(minzoom) return end MinZoom(minzoom) - SetBrunnelAttributes() if ramp then AttributeNumeric("ramp",1) end -- Service @@ -576,8 +577,8 @@ function way_function() end -- Pier - if man_made=="pier" then - write_to_transportation_layer(13, "pier", nil, false, nil, false, false) + if manMadRoadValues[man_made] then + write_to_transportation_layer(13, man_made, nil, false, nil, false, false) end -- 'Ferry' @@ -810,7 +811,7 @@ function SetEleAttributes() end function SetBrunnelAttributes() - if Find("bridge") == "yes" then Attribute("brunnel", "bridge") + if Find("bridge") == "yes" or Find("man_made") == "bridge" then Attribute("brunnel", "bridge") elseif Find("tunnel") == "yes" then Attribute("brunnel", "tunnel") elseif Find("ford") == "yes" then Attribute("brunnel", "ford") end