# Below the comment from the original mkgmap style file
# (svn revision 2009)
# Some changes were applied to the default.

# -------------------------------------------------------------------
# This is the default mkgmap style file for converting OSM ways
# into Garmin lines.
# Any line prefaced with # is a comment and will not be applied.
# Each line is a rule, of the generalised format:
#  OSM_tag(s)_to_match  [Garmin_type_code resolution]
# See http://wiki.openstreetmap.org/wiki/Mkgmap/help/style_rules
# and http://wiki.openstreetmap.org/wiki/Mkgmap/help/Custom_styles
# for more information.

# first set the country code
mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' }
mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' }
mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }

# country specific rules first

# Netherlands = NLD
mkgmap:country=NLD & mkgmap:region!=* & mkgmap:admin_level4=* { set mkgmap:region='${mkgmap:admin_level4}' }
mkgmap:country=NLD & mkgmap:city!=* & mkgmap:admin_level10=* { set mkgmap:city='${mkgmap:admin_level10}' } 
mkgmap:country=NLD & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' } 

# Germany = DEU cities
mkgmap:country=DEU & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' } 
mkgmap:country=DEU & mkgmap:city!=* & mkgmap:admin_level7=* { set mkgmap:city='${mkgmap:admin_level7}' } 
mkgmap:country=DEU & mkgmap:city!=* & mkgmap:admin_level6=* { set mkgmap:city='${mkgmap:admin_level6}' } 
mkgmap:country=DEU & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' } 
mkgmap:country=DEU & mkgmap:city!=* & mkgmap:admin_level10=* { set mkgmap:city='${mkgmap:admin_level10}' } 


# other european countries
mkgmap:country=AUT & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=BEL & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=CZE & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=CZE & mkgmap:city!=* & mkgmap:admin_level7=* { set mkgmap:city='${mkgmap:admin_level7}' }
mkgmap:country=DNK & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=DNK & mkgmap:city!=* & mkgmap:admin_level7=* { set mkgmap:city='${mkgmap:admin_level7}' }
mkgmap:country=FIN & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' }
mkgmap:country=FIN & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=FRA & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' }
mkgmap:country=FRA & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=ISL & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=ITA & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=LUX & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=NOR & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' }
mkgmap:country=POL & mkgmap:city!=* & mkgmap:admin_level10=* { set mkgmap:city='${mkgmap:admin_level10}' }
mkgmap:country=POL & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=PRT & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' }
mkgmap:country=PRT & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=SVN & mkgmap:city!=* & mkgmap:admin_level10=* { set mkgmap:city='${mkgmap:admin_level10}' }
mkgmap:country=ESP & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
mkgmap:country=SWE & mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' }
mkgmap:country=SWE & mkgmap:city!=* & mkgmap:admin_level7=* { set mkgmap:city='${mkgmap:admin_level7}' }
mkgmap:country=CHE & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
 
# Canda
mkgmap:country=CAN & mkgmap:region!=* & mkgmap:admin_level4=* { set mkgmap:region='${mkgmap:admin_level4}' }
mkgmap:country=CAN & mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' }
  
# common rules for all the rest of countries
mkgmap:region!=* & mkgmap:admin_level6=* { set mkgmap:region='${mkgmap:admin_level6}' } 
mkgmap:region!=* & mkgmap:admin_level5=* { set mkgmap:region='${mkgmap:admin_level5}' } 
mkgmap:region!=* & mkgmap:admin_level4=* { set mkgmap:region='${mkgmap:admin_level4}' } 
mkgmap:region!=* & mkgmap:admin_level3=* { set mkgmap:region='${mkgmap:admin_level3}' } 
mkgmap:region!=* & is_in:county=* { set mkgmap:region='${is_in:county}' } 

mkgmap:city!=* & mkgmap:admin_level8=* { set mkgmap:city='${mkgmap:admin_level8}' } 
mkgmap:city!=* & mkgmap:admin_level7=* { set mkgmap:city='${mkgmap:admin_level7}' } 
mkgmap:city!=* & mkgmap:admin_level9=* { set mkgmap:city='${mkgmap:admin_level9}' } 
mkgmap:city!=* & mkgmap:admin_level10=* { set mkgmap:city='${mkgmap:admin_level10}' } 
mkgmap:city!=* & is_in:city=* { set mkgmap:city='${is_in:city}' }
mkgmap:city!=* & addr:city=* { set mkgmap:city='${addr:city}' }

mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 

mkgmap:street!=* & addr:street=* { set mkgmap:street='${addr:street}' }
mkgmap:street!=* & addr:housename=* { set mkgmap:street='${addr:housename}' }

mkgmap:housenumber!=* & addr:housenumber=* { set mkgmap:housenumber='${addr:housenumber}' }

mkgmap:phone!=* & phone=* { set mkgmap:phone='${phone}' }
mkgmap:phone!=* & contact:phone=* { add mkgmap:phone='${contact:phone}' }

mkgmap:is_in!=* & is_in=* { set mkgmap:is_in='${is_in}' }
aeroway=runway [0x27 resolution 20]
aeroway=taxiway [0x27 resolution 24]

# Remove access=yes from highways.
highway=* & access=yes { delete access }
# Translate motor_vehicle and vehicle access rules.
highway=* & motor_vehicle=* { add motorcar='${motor_vehicle}' }
highway=* & vehicle=* { add motorcar='${vehicle}'; add bicycle='${vehicle}' }

# By default, ways are accessible by the highest allowed mode of
# transportation, and thus access=yes should be redundant.
# However, sometimes cycleways may be tagged access=destination or similar,
# to allow cars and motorcycles. In mkgmap, 'access' specifies the
# generic access rule, and it can be overridden by more specific tags:
# foot, bicycle, motorcar, motorcycle.

# Hide unaccessible tunnels
highway=* & tunnel=yes & (access=private|access=no)
& foot!=* & bicycle!=* {delete highway;delete junction}
# Disable dead-end-checks for unaccessible oneways
highway=* & oneway=yes & (access=private|access=no)
{add mkgmap:dead-end-check=false}
# Validation-like checks (uncomment to enable)
#highway=motorway_link & oneway!=yes & oneway!=no { echo "motorway_link lacks oneway" }

# Set highway names to include the reference if there is one
highway=motorway {name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}' }
highway=trunk {name '${ref|highway-symbol:hbox} ${name}' | '${ref|highway-symbol:hbox}' | '${name}'; add display_name = '${name} (${ref})' }
highway=primary {name '${ref|highway-symbol:box} ${name}' | '${ref|highway-symbol:box}' | '${name}'; add display_name = '${name} (${ref})' }
bbbike:render=highway_primary {name '${ref|highway-symbol:box} ${name}' | '${ref|highway-symbol:box}' | '${name}'; add display_name = '${name} (${ref})' }
highway=secondary | highway=tertiary {name '${ref|highway-symbol:oval} ${name}' | '${ref|highway-symbol:oval}' | '${name}'; add display_name = '${name} (${ref})' }
bbbike:render=highway_secondary {name '${ref|highway-symbol:oval} ${name}' | '${ref|highway-symbol:oval}' | '${name}'; add display_name = '${name} (${ref})' }
highway=* {name '${name}' | '${ref}' }

# Flag unpaved roads.
highway=*
& (surface=cobblestone | surface=compacted | surface=dirt |
   surface=earth | surface=grass | surface=grass_paver |
   surface=gravel | surface=grit | surface=ground | surface=mud |
   surface=pebblestone | surface=sand | surface=unpaved |
   mtb:scale=* |
   tracktype ~ 'grade[2-6]' |
   smoothness ~ '.*(bad|horrible|impassable)' |
   sac_scale ~ '.*(mountain|alpine)_hiking' |
   sport=via_ferrata)
{ add mkgmap:unpaved=1 }
(highway=bridleway | highway=path | highway=track | highway=unsurfaced)
& surface!=* & tracktype!=* & smoothness!=* & sac_scale!=*
{ add mkgmap:unpaved=1 }

# Convert generic path to most specific
highway=footway & snowplowing!=no
& (bicycle=yes|bicycle=designated|bicycle=permissive|bicycle=official)
{set highway=cycleway; set bicycle=yes}
highway=path & snowplowing!=no
& (bicycle=designated|bicycle=permissive|bicycle=official)
{set highway=cycleway; set bicycle=yes}
highway=path & (horse=designated|horse=permissive|horse=official)
{set highway=bridleway; set horse=yes}
highway=path
{set highway=footway}

leisure=track & area!=yes
{add highway=footway; name '${name} (${sport})' | '${name}'}
(man_made=pier | man_made=piste:halfpipe) & area!=yes
{add highway=footway; name '${ref} ${name}' | '${ref}' | '${name}' }

# Roundabouts
junction=roundabout & highway=trunk [0x0c road_class=3 road_speed=2 resolution 18]
junction=roundabout & highway=primary [0x0c road_class=3 road_speed=2 resolution 19]
junction=roundabout & highway=secondary [0x0c road_class=2 road_speed=2 resolution 20]
junction=roundabout & highway=tertiary [0x0c road_class=1 road_speed=1 resolution 21]
junction=roundabout & highway=unclassified [0x0c road_class=1 road_speed=1 resolution 21]
junction=roundabout [0x0c road_class=0 road_speed=1 resolution 22]

######################################################################
# SRT: additional block
cycleway=* {name '${name}' }
psv=* {name '${name}' }

cycleway=track & bbbike:cycleway_type=dualdir {add access = no; add bicycle = yes; add foot = yes} [0x3b resolution 23]

cycleway=track & bbbike:usage=mandatory {add access = no; add bicycle = yes; add foot = yes} [0x2f resolution 23]
cycleway=track & bbbike:usage=optional {add access = no; add bicycle = yes; add foot = yes} [0x30 resolution 23]
cycleway=track & bbbike:usage=unknown {add access = no; add bicycle = yes; add foot = yes} [0x31 resolution 23]

cycleway=lane & bbbike:usage=mandatory {add access = no; add bicycle = yes; add foot = yes} [0x34 resolution 23]
cycleway=lane & bbbike:usage=optional {add access = no; add bicycle = yes; add foot = yes} [0x35 resolution 23]
cycleway=lane & bbbike:usage=unknown {add access = no; add bicycle = yes; add foot = yes} [0x36 resolution 23]

psv=yes & bbbike:times=unknown [0x33 resolution 23]
psv=yes & bbbike:times=always [0x32 resolution 23]
psv=yes [0x3a resolution 23]

bbbike:quality=Q1 [0x39 resolution 23]
bbbike:quality=Q2 [0x38 resolution 23]
bbbike:quality=Q3 [0x37 resolution 23]

bbbike:mountclass=light_mount [0x10400 resolution 23]
bbbike:mountclass=medium_mount [0x10401 resolution 23]
bbbike:mountclass=strong_mount [0x10402 resolution 23]
bbbike:mountclass=unspecified_mount [0x10403 resolution 23]
bbbike:mountclass=light_slope [0x10404 resolution 23]
bbbike:mountclass=medium_slope [0x10405 resolution 23]
bbbike:mountclass=strong_slope [0x10406 resolution 23]
bbbike:mountclass=unspecified_slope [0x10407 resolution 23]

# XXX Reusing the path symbol is currently a hack ---
# XXX consider to even use an "invisible" line, just
# XXX for the highway plates/names
route=bicycle [0x16 resolution 20]
route=bicycle {name '${ref|highway-symbol:oval} ${name}' | '${ref|highway-symbol:oval}' }

# SRT addition ends here
######################################################################

# Ways that may or may not be useable

# Treat ways under construction almost as highway=path
highway=construction { add mkgmap:dead-end-check = false; }
[0x16 road_class=0 road_speed=0 resolution 23]

# Lower the road speed of ways under some construction.
highway=* & construction=* { add mkgmap:road-speed = '-1' }
# Lower the road speed of disused ways.
highway=* & disused=yes { add mkgmap:road-speed = '-2' }

# Ways sorted roughly by descending order of class
highway=motorway {add oneway = yes; add bicycle = no; add foot = no } [0x01 road_class=4 road_speed=7 resolution 16]
highway=motorway_link {add oneway = yes; add bicycle = no; add foot = no } [0x09 road_class=3 road_speed=2 resolution 20]
highway=* & motorroad=yes {add bicycle = no; add foot = no}
highway=trunk [0x02 road_class=4 road_speed=5 resolution 18]
highway=trunk_link [0x09 road_class=3 road_speed=2 resolution 20]
highway=* & highway!=proposed & motorroad=yes [0x02 road_class=4 road_speed=4 resolution 18]
# SRT: addition for bicycle=no support
highway=primary & bicycle=no [0x123 road_class=3 road_speed=4 resolution 19]
# SRT: addition for oneway support
highway=primary & oneway=yes [0x103 road_class=3 road_speed=4 resolution 19]
highway=primary [0x03 road_class=3 road_speed=4 resolution 19]
# SRT: addition
bbbike:render=highway_primary [0x03 road_class=1 road_speed=3 resolution 19]
highway=primary_link [0x08 road_class=3 road_speed=1 resolution 21]
# SRT: addition for bicycle=no support
highway=secondary & bicycle=no [0x124 road_class=2 road_speed=3 resolution 20]
# SRT: addition for oneway support
highway=secondary & oneway=yes [0x104 road_class=2 road_speed=3 resolution 20]
highway=secondary [0x04 road_class=2 road_speed=3 resolution 20]
# SRT: addition
bbbike:render=highway_secondary [0x04 road_class=1 road_speed=3 resolution 20]
highway=secondary_link [0x08 road_class=2 road_speed=1 resolution 22]
# SRT: addition for bicycle=no support
highway=tertiary & bicycle=no [0x125 road_class=1 road_speed=3 resolution 20]
# SRT: addition for oneway support
highway=tertiary & oneway=yes [0x105 road_class=1 road_speed=3 resolution 20]
highway=tertiary [0x05 road_class=1 road_speed=3 resolution 20]
highway=tertiary_link [0x08 road_class=1 road_speed=1 resolution 22]
highway=minor [0x06 road_class=1 road_speed=3 resolution 21]
highway=unclassified [0x06 road_class=0 road_speed=3 resolution 21]

# Some countries allow, others disallow bicycling on pedestrian streets.
# To allow bicycling, add 'add bicycle=yes'
highway=pedestrian & area!=yes {add access = no; add foot = yes} [0x16 road_class=0 road_speed=0 resolution 22]
# SRT: addition for bicycle=no support
(highway=residential | highway=living_street) & bicycle=no [0x126 road_class=0 road_speed=2 resolution 21]
# SRT: addition for oneway support
(highway=residential | highway=living_street) & oneway=yes [0x106 road_class=0 road_speed=2 resolution 21]
highway=living_street [0x06 road_class=0 road_speed=1 resolution 22]
highway=residential [0x06 road_class=0 road_speed=2 resolution 22]
highway=bridleway {add access = no; add bicycle = yes; add foot = yes} [0x07 road_class=0 road_speed=0 resolution 23]
highway=byway [0x16 road_class=0 road_speed=0 resolution 23]

highway=service & service=parking_aisle
[0x07 road_class=0 road_speed=1 resolution 24]
highway=service & (service=alley|service=driveway)
[0x07 road_class=0 road_speed=0 resolution 23]
highway=service [0x07 road_class=0 road_speed=2 resolution 22]
# SRT: changed 0x16 -> 0x0f (major trail)
highway=cycleway {add access = no; add bicycle = yes; add foot = yes} [0x0f road_class=0 road_speed=1 resolution 21]
highway=footway {add access = no; add foot = yes} [0x16 road_class=0 road_speed=0 resolution 23]
highway=path {add access = no; add bicycle = yes; add foot = yes} [0x16 road_class=0 road_speed=1 resolution 23]
# SRT: changed 0x16 -> 0x13 (steep trail)
highway=steps {add access = no; add foot = yes} [0x13 road_class=0 road_speed=0 resolution 23]
highway=track [0x0a road_class=0 road_speed=1 resolution 22]
highway=unsurfaced [0x0a road_class=0 road_speed=1 resolution 22]
highway=road { add mkgmap:dead-end-check = false} [0x06 road_class=0 road_speed=1 resolution 22]

# Mop up any unrecognised highway types
highway=* & highway!=proposed & area!=yes [0x07]

natural=coastline [0x15 resolution 12]
power=line [0x29 resolution 21]

# SRT: change: rendering also for layer<0
railway=* & abandoned=yes [0x3e resolution 17]
railway=* & construction=yes [0x3e resolution 17]
# SRT: added railway=construction
railway=construction [0x3e resolution 17]
railway=abandoned [0x3e resolution 17]
#railway=abandoned [0x0a road_class=0 road_speed=1 resolution 21]
railway=light_rail [0x2d resolution 17]
# SRT: change: private definition (0x14 -> 0x3f)
railway=narrow_gauge [0x3f resolution 17]
# XXX resolution seems to be ignored here
railway=rail [0x14 resolution 17]
railway=subway [0x2e resolution 17]
# SRT: change: private definition (0x14 -> 0x115)
# SRT: changed back from 0x115 -> 0x14, mkgmap-r3333 does not work with this id
railway=tram [0x14 resolution 18]
railway=platform {add access = no; add foot = yes} [0x16 road_class=0 road_speed=0 resolution 23]

# note: using 0x1a instead of the default 0x1b (which seems to be wrong according to the typ file editor)
route=ferry {add mkgmap:ferry=1} [0x1a road_class=3 road_speed=0 resolution 18]

waterway=canal [0x1f resolution 21]
waterway=drain [0x1f resolution 22]
waterway=river [0x1f resolution 18]
waterway=rapids|waterway=waterfall [0x1f resolution 22]
waterway=stream [0x18 resolution 22]

man_made=cable|(man_made=* & man_made ~ '.*pipe.*')
{name '${name} (${operator})' | '${name}' | '${operator}' }
[0x28 resolution 23]

# The following boundary styles are after the highway rules because ways
# are frequently tagged with both and we want the highway to take priority.
boundary=administrative { name '${mkgmap:boundary_name}' }
boundary=administrative & admin_level<3 [0x1e resolution 16]
boundary=administrative & admin_level<5 [0x1d resolution 19]
boundary=administrative & admin_level<7 [0x1c resolution 21]
boundary=administrative & admin_level<9 [0x1c resolution 22]
boundary=administrative [0x1c resolution 22]
boundary=national [0x1e resolution 17]
boundary=political [0x1c resolution 19]

# SRT
FIXME=* {name '${FIXME}'} [0x2c resolution 17]

##XXX hmmm, does not work, why?
#bbbike:trafficlightmap=green [0x40 resolution 17]
#bbbike:tlm=green [0x40 resolution 17]

######################################################################
# from waters/lines

natural=coastline [0x15 resolution 12]

# SRT: using 0x1a instead of the default 0x1b (which seems to be wrong according to the typ file editor)
route=ferry {add mkgmap:ferry=1} [0x1a road_class=3 road_speed=0 resolution 19]

waterway=canal [0x1f resolution 21]
waterway=drain [0x1f resolution 22]
waterway=river [0x1f resolution 18]
waterway=rapids|waterway=waterfall [0x1f resolution 22]
waterway=stream [0x18 resolution 22]
