top of page
Search
Writer's pictureterrycornall

Zoomies using mkgmap

Updated: Sep 22

Intro



Must be a very small hut!

I absolutely hate it when the hut I am looking for on my Fenix requires me to zoom in on the map down to almost the lowest level before it appears!

Below is a method I am playing with to let me set a better zoom level visibility.


mkgmap is a java utility to convert OSM maps into Garmin .img files.

You can get it from mkgmap

You run it using:

java -jar mkgmap.jar file.osm

I have downloaded it and it’s in d:\mkgmap

There’s a README and good  doco at  Background (mkgmap.org.uk)

You can get Victoria (and NSW and Tas) osm map from Index of /extracts/oceania/australia (openstreetmap.fr)

Regional extracts of OpenStreetMap data can also be obtained from download.geofabrik.de. (Might be same source)


TLDR

Skip to the final paragraph Finally, success! to find the destination unless you are interested in the journey...


Using mkgmap to change what zoom levels nodes are visible at

Note that if you put the resulting .img file that mkgmap makes onto flash-233G/Garmin then you can try it out in basecamp before putting it onto a Garmin device.

Conversion Style manual (mkgmap.org.uk) says that “You can completely change which features are displayed and at what zoom levels.” which sounds perfect for getting around the ‘huts not visible until you zoom right in’ problem on the Fenix 7.

To do this you need to edit the files in a style directory ((Or copy that dir and hack it, or make your own style dir) see examples in D:\mkgmap\examples\styles\default and change the resolution (probably from 24 to something smaller. Or use level rather than resolution. Read on.)

I looked into gwinear.osm and I see that there’s a node with tag k=name v=Rock Shelter and tag k=tourism v=camp_site so I edited the points style file in examples/default and changed

tourism=camp_site [0x2b03 resolution 20] [0x2b05 resolution 20] #TC changed res to 20 from 24 as a test

and then open a cmd window and run

cd d:\mkgmap

d:

java -jar mkgmap.jar --style-file=D:\mkgmap\examples\styles\default --description=GwinearTest D:\maps_OSM\gwinear\gwinear.osm 

It produces a bunch of .img files in d:\mkgmap and the one you want is called 63240001.img. Copy that to flash-233G/Garmin and restart basecamp. Then choose Maps->GwinearTest.

In basecamp the edit doesn’t appear to change the zoom level at which camp_sites like Rock Shelter appears

In the Dakota gps hand-held however, they did. When resolution set to 24, they only appeared for scales of 800m or less and disappeared above that. When I changed resolution to 18, the camp_site nodes stay visible up to scales of 54km! oooh! Dare I try it on a large osm map of the Vic alps? And NSW alps? And Tassie?

Test the idea by putting the .img file on the fenix 7 first to make sure it does what you want it to.

Maybe you’ll need to set up a management framework with the osm files and various style folders and some batch files to manage the files you produce.

Also it would be nice to have a map renderer that behaves the same as the fenix 7 because it looks like basecamp and real devices do things differently… GPSMapEdit?

Some success on the Fenix

I found some changes that makes more difference than the resolution is which icon I use and use level rather than resolution. If I replace

tourism=camp_site [0x2b03 resolution 24] [0x2b05 resolution 24]
with
tourism=camp_site [0x6412 level 0-4] #i.e. change the icon hex number and used level rather than resolution

I get a hiker icon instead of a tent and it is visible out to 8km scale on the fenix where the tent would disappear above the 80m scale.


BTW, mail-archive.com is a place you can find a description of icons and their codes. Can't guarantee that the Fenix 7 has all of them or that the description is accurate for it.


I can make a map transparent using the --transparent --draw-priority=100 commandline options that allows the map to display on top of others on the Fenix. (doesn’t work quite so well on basecamp, which won’t let me load 2 maps at once, but it does show the transparency over a built-in base map, though it uses blue squares rather than hiker icons)

If you create a style folder with nothing more than a version file (with just '1' in it) and just a points file with only that one rule (tourism=camp_site…) in it, only the camp_sites show up. All the roads and so-on disappear.

Also, use java 64 (rather than 32…) and give it lots of heap using -Xmx8G otherwise big .osm files like Victoria will run it out of memory.

java -Xmx8G -jar mkgmap.jar --style-file=D:\mkgmap\my_rules --description=VicCampSitesTransparent --transparent --draw-priority=100 D:\maps_OSM\australia\victoria\victoria-latest.osm.pbf

In the points file the only rules are:

tourism=camp_site {name '${name}'} [0x6412 level 0-4 default_name 'campsite' continue]
<finalize># The finalizer section is executed for each element when a rule with an element type matches
name=* {name '${name}'}

On Basecamp, the name doesn't appear on the map until a couple of levels down after the icon appears, which is also good. (At least on Basecamp, I have to test it on Fenix...)

Hmm, on the Fenix the name doesn't appear until you select the icon, no matter how far in you zoom. Not terrible, but I'd like it to show up at least on the highest zoom without needing to select. (Not least because the select method on the Fenix is literally very hit or miss...)


Iconography

Found a list of icons and their codes at  mail-archive.com  and a better icon hexcode (for camp_sites at least) that shows up just as well at zoomed out levels than the 'hiker' one is 0x4800 which shows a tent on the Fenix. So my points rules are now:


tourism=camp_site {name '${name}'} [0x4800 level 0-4 default_name 'campsite' continue] #0x4800 shows a tent
<finalize># The finalizer section is executed for each element when a rule with an element type matches
name=* {name '${name}'}

Still looking for a way to get the name to show at the most zoomed in or just above without having to select the icon. I tried to put a level in the 'name' rule in the 'finalize' section but it isn't allowed.


Here's a list of codes and icon descriptions I've found by trial and error and reference to OSM Map On Garmin/POI Types - OpenStreetMap Wiki

Note that this is particular to the Fenix 7. It's by no means complete and also other codes may well produce similar icons. Also it is possible that the icon code also determines the levels on which an icon shows. These ones seem to show up on most zoom levels except the most zoomed out ones. There are still some I want to find...


0x4a00 picnic-table

0x4E00 toilet

0x4800 tent

0x6412 hiker

????? summit

0x5000 water (check on Fenix)

????? lodge/hut

0x2B00 Bed disappears after 80m on Fenix


All depends on your point of interest

Another approach to the visibility issue is to mark all huts with a POI. Then they show up, with a label, at all zoom levels. It probably wouldn't be tooooo hard to extract node locations from OSM and create a .gpx with them as POIs. (I've done something similar a while ago using Python and the .JSON version of an OSM map... and there are libraries for Python dealing with other OSM map formats....)

Nonetheless, a major advantage of the transparent map is that you can turn it off when you don't care about alpine huts (or whatever)


Not so elementary, my dear Fenix

 There's a built-in functionality of mkgmap you can use to try to see what the symbols (elements) will look like on your device.

 java -jar mkgmap.jar test-map:all-elements

It makes a .img file full of symbols and some of them even have info about their hex code. (Sadly, some don't)

It appears at Chelmsford England by default though you can change that.

Here it is a small extract of what is displayed on Basecamp. (Can't give whole thing because it is too big and needs to be zoomed in on to see details)

I see that the tent symbol is 0x48(00-1F) which aligns with what I have found out by trial and error.

I tried to view it on the Fenix to see what the codes looked like there but despite numerous attempts with various options I couldn't see it on the watch.

It did give me hint though, that code 0x2B00 (a bed) might be useful...


Not my type

I was trying to avoid this, but maybe I need to define a custom symbol of my own (define a type) and have it loaded into the map. I'll think about it. I think the built-in symbols on the Fenix for buildings are pretty sucky anyway... and the one that comes up for wilderness huts is pathetic. Some pale blue small, low res of a hiker in front of a house, I think. Very hard to tell.


I used the mapnik.txt file in mkgmap/examples/typ folder (which I copied and renamed to myTyp.txt) It defines ONLY a (took out all the other types except 0x2b07 and hacked the image to make it bigger and red on green) symbol for the code 0x2b07 and then compiled and used that typ file by: (Note the use of --gmapsupp is new for me but apparently necessary if you are using a typ file) I temporarilly turned off the campsites because they were obscuring the hut icon)

java -jar mkgmap.jar --family-id=8094 D:\mkgmap\my_rules\typ\myTyp.txt 
java -Xmx8G -jar mkgmap.jar  --style-file=D:\mkgmap\my_rules --description=VicHutsTransparent --transparent --family-id=8094 --draw-priority=100 --gmapsupp D:\maps_OSM\australia\victoria\victoria-latest.osm.pbf myTyp.typ

with my point file containing just the rule for hut, with campsites turned off for now:
#tourism=camp_site [0x4800 level 0-4 default_name 'campsite' continue]  tourism=alpine_hut |tourism=wilderness_hut|tourism=lean_to [0x2b07 level 0-4 default_name 'hut' continue]  #0x2b07 is defined in a typ file in this dir
<finalize>
# The finalizer section is executed for each element when a rule with an element type matches
name=* {name '${name}'} #set the name to the tag name value

Then rename gmapsupp.img to something like vicHutBigger.img and copy it to the Fenix or to the flash drive you are testing with Basecamp. Make sure to remove previous attempts .img files (regardless of file name) because they may have the same map name inside and confuse selection menues.

Opening Basecamp and selecting VicHutsTransparent and zooming (where you know a hut to be) into 1km or lower you see the new house icon where the huts are! Yay. (Hmm, the roof is a bit wonky)

So, I need to work out how to up its zoom level visibility.

On the Fenix... it shows up but only when you zoom into 80m. Grr. At least the name appears now, when you zoom in a bit more (8m) so you don't have to select it to find its name. Nonetheless, I want it to appear at least at the 3K scale, with its name!


Finally, success!

OK, I got some hint that the type number is what determines the zoom level for an icon, so, knowing that 0x4800 shows up at a good zoom level, I tried to use 0x4801 for my hut symbol instead of 0x2b07 (which was kinda arbitrary anyway).

It worked! (for Basecamp)

Possibly too well... It seems to show up now at zoom levels from 1500km on down, with the labels appearing at 20km (which is nice). Can't get rid of the things!

On Fenix though.... icon appears at 8km, label at 120m. Not bad, I can live with that!

Bonus is that I can also search for the huts using hike settings->navigation->all POIs->search near->saved location->select some saved location->spell search->Hut.

Other types of search work too, of course.


Here are the final files:

points:

#This points file just huts
#tourism=camp_site [0x4800 level 0-4 default_name 'campsite' continue]  #was 0x6412 TC hacked this to use a hiker icon visible at more zoom levels on fenix. WORKS! Up to and including 8km scale

tourism=alpine_hut|tourism=wilderness_hut|tourism=lean_to [0x4801 level 0-4 default_name 'hut' continue]   #4801 defined in myTyp.txt#using 0x4801 because the 0x48nn types show up at much zoomed out level
<finalize>
# The finalizer section is executed for each element when a rule with an element type matches
name=* {name '${name}'} #set the name to the tag name value

myTyp.txt:

; TYP file to redefine 044801 symbol as a hut
; -*- coding: UTF-8 -*- NB: first 3 bytes/char in file is UTF-8 encoded ByteOrderMark (BOM)
;using 0x4801 because that type (0x48nn) shows up at much zoomed out
[_point]
type=0x048s
subtype=0x01
;GRMN_TYPE: //
String=Wilderness Hut
String1=0x01,Refuge
String2=0x02,Bergschutzhütte
String4=0x03,Bergschuilhut
String7=0x15,Schronisko
String8=0x10,Cabana
String9=0x05,Bivacco
ExtendedLabels=Y
FontStyle=SmallFont
CustomColor=Day
DaycustomColor:#0065D5
DayXpm="23 23 2 1"   Colormode=16
"!	c #FF0000"
"  	c #00FF00"
"           !!          "
"          !!!!         "
"         !!!!!!        "
"        !!!!!!!!       "
"       !!!!!!!!!!      "
"      !!!!!!!!!!!!     "
"     !!!!!!!!!!!!!!    "
"   !!!!!!!!!!!!!!!!!   "
" !!!!!!!!!!!!!!!!!!!!! "
"!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!             !!!!!"
"!!!!!             !!!!!"
"!!!!!             !!!!!"
"!!!!!             !!!!!"
" !!!!             !!!! "
" !!!!             !!!! "
" !!!!             !!!! "
" !!!!             !!!! "
" !!!!             !!!! "
" !!!!             !!!! "
" !!!!!!!!!!!!!!!!!!!!! "
" !!!!!!!!!!!!!!!!!!!!! "
" !!!!!!!!!!!!!!!!!!!!! "
;123456789012345678901234
[end]

batch file to make it all:

rem compile my typ file with custom stuff first
java -jar mkgmap.jar --family-id=8094 D:\mkgmap\my_rules\typ\myTyp.txt  rem to use typ files needs the --gmapsupp option 
java -Xmx8G -jar mkgmap.jar --family-id=8094 --style-file=D:\mkgmap\my_rules --description=VicHutsTransparent --transparent --draw-priority=100  --gmapsupp D:\maps_OSM\australia\victoria\victoria-latest.osm.pbf myTyp.typ

But wait, there's more!

I decided to complicate my life by trying to get all the huts in Australia. To do this I needed to use the splitter.jar that you can download from the same place you got mkgmap.jar because otherwise mkgmap can't handle all of Australia at once.

You only need to run splitter once.

I found that I needed to edit the template.args file that splitter made and give every tile a description (or maybe just the last one?). Leaving them commented out seemed to cause issues. (Now this might have been caused by something else because my PC crashed shortly thereafter and after a reboot , mkgmap played nice.) Anyway, the last tile's description is apparently what is used as the description of the whole gmapsupp.img so best to make it something like "Australian Huts Transparent"

Then:

rem USE splitAustralia.bat to do the following splitting because you have to edit template.args after and give each tile a description. mkgmap crashes otherwise
java -Xmx8G -jar splitter-r654\splitter.jar D:\maps_OSM\australia\australia-latest.osm.pbf > splitter.log

rem Edit template.args, give tiles a description, especially last one, and rename named_template.args so it isn't overwritten by accident
java -jar mkgmap.jar  --family-id=8094 --style-file=D:\mkgmap\my_rules --description=AusHutsTransparent --transparent --draw-priority=100  --gmapsupp -c named_template.args myTyp.typ

This does work and produced a transparent map of all of Australia with huts marked. (But read on, because there's a twist!)


Map Makers Screwed up!

However, I discovered something very annoying. Some huts appear to be put on the map not as points but as areas and they aren't being picked out by my rules which only apply to points! e.g. Lake Vera hut in Tassie. On this OSM map (not my transparent one which shows nothing there) it's that small puce square area and unlike, say, Lake Tahune Hut it doesn't show as an icon. This is affecting a bunch of others too, like Cesjack's Hut in NSW near Mt Jagungal. I'll have to make a rule for areas as well that discovers huts marked only as areas and shows my hut icon...


Lucky number 0x13

So I played a bit with the polygons rule file and this worked, to a degree. It at least shows the area (as an area) and a name. Shows up at some zoom levels though not as well as the icons for huts. The trick will be to get it to show an icon as well as the area.

tourism=wilderness_hut|tourism=alpine_hut|tourism=lean_to [0x13 level 0-4 default_name "hut" continue]  #tc added this to get huts? 0x11 no good

Note that the 0x13 works whereas others like 0x11 doesn't. Not exactly sure what those codes are for. They aren't icons but seem rather to be area-specific color/text styles. In this excerpt from what Basecamp displays when I use the all_elements command of mkgmap, I can see some of what the codes show for areas. Note that 0x13 is there (though its invisible and I can only see it because I am hovering in the right place) but I can't seem to find 0x11 which explains why previous attempts using that code didn't work. Maybe I should use 0x28 which seems to have more visible text and a blue area fill.


Note that I haven't tested this on the Fenix yet, just Basecamp, so on the watch it might be quite different.. In the image below, the name and area (area is too small to see at that zoom level) shows up for Vera Hut (which is specified as an area/way) and Tahune which is specified as a point/node. This is using 0x13.

So now I want to force the hut icon to appear too. Hmmm. New polygon rule or action needed.


Add Point to Areas flag

Actually it appears that the developers of mkgmap know about this problem so they provided a command-line fix for adding a point to an area. Here's what I get at the Vera Hut site if I use the suggested --add-pois-to-areas flag as suggested in Different ways to mark a POI - why? - OSM Help (openstreetmap.org)

The darker, larger text at Vera compared to Tahune is a result of it being processed by the polygon rule rather than the point rule but the added POI in the detected area caused by --add-pois-t-areas allows the points rule to add in my custom icon so it's even more visible! (remember that named_template.args and myType.typ are created using split and mkgmap previously)

java -jar -Xmx8G mkgmap.jar  --family-id=8094 --style-file=D:\mkgmap\my_rules --description=AusHutsTransparent --transparent --draw-priority=100 --add-pois-to-areas --gmapsupp -c named_template.args myTyp.typ

73 views

Recent Posts

See All
bottom of page