@@ -30,6 +30,8 @@ function Set(list)
3030end 
3131
3232--  Meters per pixel if tile is 256x256
33+ ZRES3   =  19567.88 
34+ ZRES4   =  9783.94 
3335ZRES5   =  4891.97 
3436ZRES6   =  2445.98 
3537ZRES7   =  1222.99 
@@ -47,8 +49,8 @@ INVALID_ZOOM = 99
4749
4850--  Process node/way tags
4951aerodromeValues  =  Set  { " international" " public" " regional" " military" " private"  
50- pavedValues  =  Set  { " paved " " asphalt " " cobblestone " " concrete " " concrete:lanes " " concrete:plates " " metal " " paving_stones " " sett " " unhewn_cobblestone " " wood "  
51- unpavedValues  =  Set  { " unpaved " " compacted " " dirt " " earth " " fine_gravel " " grass " " grass_paver " " gravel " " gravel_turf " " ground " " ice " " mud " " pebblestone " " salt " " sand " " snow " " woodchips "  
52+ unpavedValues  =  Set  { " unpaved " " artificial_turf " " clay " " compacted " " crushed_limestone " " dirt " " dirt/sand " " earth " " fine_gravel " " grass " " grass_paver " ,  " gravel " ,  " gravel_turf " ,  " ground " ,  " ice " ,  " mud " ,  " pebblestone " ,  " rock " ,  " rocky " ,  " rocks " ,  " salt " ,  " sand " ,  " shells " ,  " snow " ,  " soil " ,  " stepping_stones " ,  " stone " ,  " woodchips "  
53+ pavedValues  =  Set  { " paved " " acrylic " " asphalt " " brick " " bricks " " cement " " chipseal " " cobblestone " " concrete " " concrete:lanes " " concrete:plates " " granite " " interlock " " metal " " metal_grid " " paving_stones " " plastic " ,  " rubber " ,  " sett " ,  " tartan " ,  " unhewn_cobblestone " ,  " wood " ,  " grade1 "  
5254
5355--  Process node tags
5456
@@ -64,7 +66,7 @@ function capitalLevel(capital)
6466	if  capital_al  ==  0  then 
6567		return  nil 
6668	end 
67-          return  capital_al 
69+ 	 return  capital_al 
6870end 
6971
7072--  Calculate rank for place nodes
@@ -96,7 +98,7 @@ function calcRank(place, population, capital_al)
9698	end 
9799	if  place  ~=  " city"  and  place  ~=  " town"  then 
98100		return  nil 
99-          end 
101+ 	 end 
100102	if  population  >  3  *  10 ^ 6  then 
101103		return  1 
102104	elseif  population  >  1  *  10 ^ 6  then 
217219
218220--  Process way tags
219221
220- majorRoadValues  =  Set  { " motorway" " trunk" " primary"  
222+ z4RoadValues  =  Set  { " motorway"  
223+ z5RoadValues  =  Set  { " trunk"  
224+ z7RoadValues  =  Set  { " primary"  
221225z9RoadValues   =  Set  { " secondary" " motorway_link" " trunk_link"  
222226z10RoadValues   =  Set  { " primary_link" " secondary_link"  
223227z11RoadValues    =  Set  { " tertiary" " tertiary_link" " busway" " bus_guideway"  
@@ -228,8 +232,6 @@ z13RoadValues     = Set { "track", "service" }
228232manMadeRoadValues  =  Set  { " pier" " bridge"  
229233pathValues       =  Set  { " footway" " cycleway" " bridleway" " path" " steps" " pedestrian" " platform"  
230234linkValues       =  Set  { " motorway_link" " trunk_link" " primary_link" " secondary_link" " tertiary_link"  
231- pavedValues      =  Set  { " paved" " asphalt" " cobblestone" " concrete" " concrete:lanes" " concrete:plates" " metal" " paving_stones" " sett" " unhewn_cobblestone" " wood"  
232- unpavedValues    =  Set  { " unpaved" " compacted" " dirt" " earth" " fine_gravel" " grass" " grass_paver" " gravel" " gravel_turf" " ground" " ice" " mud" " pebblestone" " salt" " sand" " snow" " woodchips"  
233235railwayClasses   =  { rail = " rail" narrow_gauge = " rail" preserved = " rail" funicular = " rail" subway = " transit" light_rail = " transit" monorail = " transit" tram = " transit"  
234236
235237aerowayBuildings =  Set  { " terminal" " gate" " tower"  
@@ -314,6 +316,7 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s
314316	if  subclass  and  subclass  ~=  " "  then 
315317		Attribute (" subclass" subclass )
316318	end 
319+ 	local  accessMinzoom  =  9 
317320	AttributeNumeric (" layer" tonumber (Find (" layer" or  0 , accessMinzoom )
318321	SetBrunnelAttributes ()
319322	--  We do not write any other attributes for areas.
@@ -327,7 +330,6 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s
327330	--  Service
328331	if  (is_rail  or  highway_class  ==  " service" and  (service  and  service  ~= " " then  Attribute (" service" service ) end 
329332
330- 	local  accessMinzoom  =  9 
331333	if  is_road  then 
332334		local  oneway  =  Find (" oneway" 
333335		if  oneway  ==  " yes"  or  oneway  ==  " 1"  then 
@@ -336,13 +338,9 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s
336338		if  oneway  ==  " -1"  then 
337339			--  **** TODO
338340		end 
339- 		local  surface  =  Find (" surface" 
340341		local  surfaceMinzoom  =  12 
341- 		if  pavedValues [surface ] then 
342- 			Attribute (" surface" " paved" surfaceMinzoom )
343- 		elseif  unpavedValues [surface ] then 
344- 			Attribute (" surface" " unpaved" surfaceMinzoom )
345- 		end 
342+ 		local  surface  =  GetSurface ()
343+ 		if  surface  ~=  " "  then  Attribute (" surface" surface , surfaceMinzoom ) end 
346344		if  Holds (" access" then  Attribute (" access" Find (" access" accessMinzoom ) end 
347345		if  Holds (" bicycle" then  Attribute (" bicycle" Find (" bicycle" accessMinzoom ) end 
348346		if  Holds (" foot" then  Attribute (" foot" Find (" foot" accessMinzoom ) end 
@@ -353,6 +351,18 @@ function write_to_transportation_layer(minzoom, highway_class, subclass, ramp, s
353351	end 
354352end 
355353
354+ function  GetSurface ()
355+ 	local  surface  =  split (Find (" surface" " ;" 
356+ 	--  prioritize unpaved
357+ 	for  _ , surfaceEntry  in  ipairs (surface ) do 
358+ 		if  unpavedValues [surfaceEntry ] then  return  " unpaved"  end 
359+ 	end 
360+ 	for  _ , surfaceEntry  in  ipairs (surface ) do 
361+ 		if  pavedValues [surfaceEntry ] then  return  " paved"  end 
362+ 	end 
363+ 	return  " " 
364+ end 
365+ 
356366--  Process way tags
357367
358368function  way_function ()
@@ -424,7 +434,7 @@ function way_function()
424434	--  https://openmaptiles.org/schema/#boundary
425435	if  isBoundary  and  not  (Find (" maritime" == " yes" then 
426436		local  mz  =  0 
427- 		if      admin_level >= 3  and  admin_level < 5  then  mz = 4 
437+ 		if      admin_level >= 3  and  admin_level < 5  then  mz = 3 
428438		elseif  admin_level >= 5  and  admin_level < 7  then  mz = 8 
429439		elseif  admin_level == 7  then  mz = 10 
430440		elseif  admin_level >= 8  then  mz = 12 
@@ -472,9 +482,9 @@ function way_function()
472482			under_construction  =  true 
473483		end 
474484		local  minzoom  =  INVALID_ZOOM 
475- 		if  majorRoadValues [h ]        then  minzoom  =  4 
476- 		elseif  h   ==   " trunk "           then  minzoom  =  5 
477- 		elseif  highway   ==   " primary "   then  minzoom  =  7 
485+ 		if  z4RoadValues [h ]            then  minzoom  =  4 
486+ 		elseif  z5RoadValues [ h ]        then  minzoom  =  5 
487+ 		elseif  z7RoadValues [ h ]        then  minzoom  =  7 
478488		elseif  z9RoadValues [h ]       then  minzoom  =  9 
479489		elseif  z10RoadValues [h ]      then  minzoom  =  10 
480490		elseif  z11RoadValues [h ]      then  minzoom  =  11 
@@ -604,16 +614,16 @@ function way_function()
604614
605615	--  'aerodrome_label'
606616	if  aeroway == " aerodrome"  then 
607- 	  	LayerAsCentroid (" aerodrome_label" 
608- 	  	SetNameAttributes ()
609- 	  	Attribute (" iata" Find (" iata" 
610-    		SetEleAttributes ()
611-  	  	Attribute (" icao" Find (" icao" 
617+ 		LayerAsCentroid (" aerodrome_label" 
618+ 		SetNameAttributes ()
619+ 		Attribute (" iata" Find (" iata" 
620+ 		SetEleAttributes ()
621+ 	 	Attribute (" icao" Find (" icao" 
612622
613-  	  	local  aerodrome  =  Find (aeroway )
614-  	  	local  class 
615-  	  	if  aerodromeValues [aerodrome ] then  class  =  aerodrome  else  class  =  " other"  end 
616-  	  	Attribute (" class" class )
623+ 	 	local  aerodrome  =  Find (aeroway )
624+ 	 	local  class 
625+ 	 	if  aerodromeValues [aerodrome ] then  class  =  aerodrome  else  class  =  " other"  end 
626+ 	 	Attribute (" class" class )
617627	end 
618628
619629	--  Set 'waterway' and associated
@@ -662,7 +672,7 @@ function way_function()
662672		local  class = " lake" if  waterway ~= " "  then  class = " river"  end 
663673		if  class == " lake"  and  Find (" wikidata" == " Q192770"  then  return  end 
664674		Layer (" water" true )
665- 		SetMinZoomByArea (way )
675+ 		SetMinZoomByArea ()
666676		Attribute (" class" class )
667677
668678		if  Find (" intermittent" == " yes"  then  Attribute (" intermittent" 1 ) end 
@@ -802,13 +812,13 @@ end
802812
803813--  Set ele and ele_ft on any object
804814function  SetEleAttributes ()
805-      local  ele  =  Find (" ele" 
815+ 	 local  ele  =  Find (" ele" 
806816	if  ele  ~=  " "  then 
807817		local  meter  =  math.floor (tonumber (ele ) or  0 )
808818		local  feet  =  math.floor (meter  *  3.2808399 )
809819		AttributeNumeric (" ele" meter )
810820		AttributeNumeric (" ele_ft" feet )
811-      end 
821+ 	 end 
812822end 
813823
814824function  SetBrunnelAttributes ()
826836--  Set minimum zoom level by area but not below given minzoom
827837function  SetMinZoomByAreaWithLimit (minzoom )
828838	local  area = Area ()
829- 	if      minzoom  <=  6  and  area > ZRES5 ^ 2   then  MinZoom (6 )
839+ 	if      minzoom  <=  4  and  area > ZRES3 ^ 2   then  MinZoom (4 )
840+ 	elseif  minzoom  <=  5  and  area > ZRES4 ^ 2   then  MinZoom (5 )
841+ 	elseif  minzoom  <=  6  and  area > ZRES5 ^ 2   then  MinZoom (6 )
830842	elseif  minzoom  <=  7  and  area > ZRES6 ^ 2   then  MinZoom (7 )
831843	elseif  minzoom  <=  8  and  area > ZRES7 ^ 2   then  MinZoom (8 )
832844	elseif  minzoom  <=  9  and  area > ZRES8 ^ 2   then  MinZoom (9 )
0 commit comments