cferrero.net      

Mapping la vida loca

 

 Home

 Photos

 Videos

 Maps

 About

Guide to mkgmap styles

General concept

mkgmap takes ways, nodes and relations from OSM data and turns them into the relevant elements for a Garmin img file. Style files control:
  • Which OSM data elements are used
  • How those OSM data elements will look in the Garmin unit (or in Mapsource).
  • What names are assigned to those OSM data elements
  • What routing attributes (access, speed etc) are assigned to roads
By changing the style file, you can adjust what elements your map contains, and how they appear.

Location of style files

Inside the mkgmap folder tree, you will find a folder called styles and inside that, three sub-folders named default, noname and test. The default folder contains a copy of the style that is used by default when you run mkgmap. Note! The default style is compiled into the mkgmap jar. mkgmap does not read the contents of the default folder by default (as it were), so changes you make to this folder will not have any effect on mkgmap or the the map it creates unless you specifically tell mkgmap to read the style files in the default folder (using the --style-file switch).

The style actally consists of a number of different files (see more description here). These are just text files which you can edit as you see fit. There are only a few files which you are likely to want to edit: the points file which controls POIs, the lines file which controls ways/roads and the polygons file which controls...polygons.

style file syntax

Most of this is already covered on the relevant mkgmap wiki pages:

In brief, the syntax is of the form:
OSM_key_to_match [Garmin_type_code resolution]

Let's take an actual example from the default points style file:
amenity=cinema [0x2d03 resolution 20]
This tells mkgmap "find any node with the key/tag pair amenity=cinema and create a Garmin POI of type 0x2d03, appearing only once you've zoomed in to resolution 20 or higher". To find out what these hexadecimal codes are, read the FAQ.

Some worked examples

To follow these worked examples, copy the default style folder and rename it to something else (I'll assume you've called it mystyle).

1. Make traffic lights appear on map as a red diamond in a red square

  1. Determine the OSM tag used for traffic lights. It's highway=traffic_signals
  2. Edit the points style file inside the mystyle directory: add a new line that reads as follows:
    highway=traffic_signals [0x0001c resolution 20]
    • highway=traffic_signals tells mkgmap to apply this rule to any node in the OSM data which has this key
    • 0x0001c tells mkgmap to use the specific Garmin type 0x0001c for these nodes. This corresponds (on my GPSMap76CSx) to a symbol like this: .
    • resolution 20 tells mkgmap to make these nodes appear at zoom-level 20
  3. Run mkgmap using the following switches:
    java -Xmx1500m -jar mkgmap.jar --style-file=resources/mystyle --gmapsupp -c template.args
  4. Copy the gmapsupp.img file to your Garmin GPS and verify that you now see symbols everywhere there is a traffic light in the original OSM data

2. Make stiles/gates appear on your maps

  1. Determine the OSM tags used for stiles and gates. They are barrier=stile and barrier=gate
  2. Edit the points style file inside the mystyle directory: add a new line that reads as follows:
    barrier=stile | barrier=gate [0x0029 resolution 20]
    • barrier=stile | barrier=gate tells mkgmap to apply this rule to any node in the OSM data which has either of these keys set (the | symbol reflects a logical or operation).
    • 0x0029 tells mkgmap to use the specific Garmin type 0x0029 for these nodes, which looks like this:
    • resolution 20 tells mkgmap to make these nodes appear at zoom-level 20
  3. Run mkgmap using the following switches:
    java -Xmx1500m -jar mkgmap.jar --style-file=resources/mystyle --gmapsupp -c template.args
  4. Copy the gmapsupp.img file to your Garmin GPS and verify that you now see symbols everywhere there is a stile or gate in the original OSM data

3. Make hedges appear on your maps with a label

  1. Determine the OSM tags used for hedges. It is barrier=hedge
  2. Edit the lines style file inside the mystyle directory: add a new line that reads as follows:
    barrier=hedge [0x2d resolution 20 default_name 'Hedge']
    • barrier=hedge tells mkgmap to apply this rule to any way in the OSM data which has this key set.
    • 0x2d tells mkgmap to use the specific Garmin type 0x2d for these ways
    • resolution 20 tells mkgmap to make these ways appear at zoom-level 20
    • default_name 'Hedge'Tells mkgmap to give any such way the default name of Hedge, unless there is already a name tag in the original OSM data.
  3. Run mkgmap using the following switches:
    java -Xmx1500m -jar mkgmap.jar --style-file=resources/mystyle --gmapsupp -c template.args
  4. Copy the gmapsupp.img file to your Garmin GPS and verify that you now see labelled hedge lines everywhere there is a hedge in the original OSM data

How do I customise what a Garmin type actually looks like?

You can customise what a Garmin type actually looks like by using your own TYP file. Also, have a read of the FAQ, which has some further info on mkgmap style files.

  Copyright 2005-2011 All Rights Reserved cferrero.net