OpenStreetMap

OSM on Garmin

Posted by Mark Pokorny on 22 December 2008 in English.

After many attempts using various programmes in different modes, I have finally managed to create some decent routable maps for Ireland. I did it thus:

Gathered the data required using osmget.pl (http://forum.openstreetmap.org/viewtopic.php?id=1162);
Combined the .osm maps that were downloaded using osmsort.pl;
Converted the combined map to .mp using osm2mp.pl;
Used mkgmap to convert it to .img format using --route.

Maps generated this way work brilliantly, except that when searching addresses, etc. using the on board menus, my nüvi 200W insists on using the Navteq maps that shipped with it to find as its source - even if these maps are disabled in the settings. Deleting them from the unit (after backing up to my computer, of course!) stops this from happening, but the OSM based maps don't seem to provide any information that will allow address searching at all - or so I thought…

After testing non-routable maps made by CloudMade (http://downloads.cloudmade.com/) and routable ones by Radomir Mucha-Kruczyński (http://emexes.powweb.com/osm/), I noticed that some information in the OSM maps can be used in the Garmin search menus for finding destinations. It seems that mkgmap is filtering them out - I bet there's a simple option that I'm not activating that will do this for me.

I also updated a spelling mistake I made in my last map edit - should be OK now!

P.S. I forgot to say that if you want more details on how I made my maps, just let me know and I'll try and explain the process!

Discussion

Comment from Mark Pokorny on 23 December 2008 at 00:20

I promised that I would try and explain what I did if someone asked, and, well, maning did! They asked about running the whole thing in a bash script, so here we go:

I use Linux, so this applies primarily to users of Linux distributions. This will probably work on Mac and/or Windows too, but I have no way of testing them.

There are some prerequisites that are needed. You will need to get the following packages from your repositories. These are:

ant
perl
subversion
java

How to get these packages will depend on your linux distribution. You will then need the latest subversion for Liosha's 'osm2mp' tools, and the routing version for 'mkgmap' (I ended up using the latest subversion for this too). You can get these by doing:

svn co http://osm2mp.googlecode.com/svn/trunk/osm2mp osm2mp
svn co http://svn.parabola.me.uk/mkgmap/branches/nod mkgmap-nod
cd mkgmap-nod
ant dist

from your command line (you might want to do this in a new directory so that you can keep track of everything). These only need to be done once, so there's probably no point in putting them in the script. Once these steps are done, you can then build your script, which should be in the following format:

---------------------------
#!/bin/bash

cd [PATH_TO_WORKING_DIRECTORY]/osm2mp

perl osmget.pl "[BOUNDING BOX COÖRDINATES]" > ../map1.osm
# … do this for as many regions as you want

perl osmsort.pl ../*.osm > ../map_complete.osm

perl osm2mp.pl --nocodepage ../map_complete.osm > ../map_complete.mp

cd ../

java -jar mkgmap-nod/dist/mkgmap.jar --latin1 --route --gmapsupp map_complete.mp
---------------------------

Where [BOUNDING BOX COÖRDINATES] are the coördinates of the region you want to download (West, South, East, North); for example:

perl osmget.pl "-6.424,53.233,-6.017,53.426" > ../dublin.osm

will get you most of the city of Dublin. You can specify a box as large or as small as you wish; osmget.pl will automatically split it into smaller sections for the server to handle if necessary, and then recombine them once they have been downloaded. You can also change the names of the files in the script as you see fit.

If you have a problem with the 'java' command throwing an exception, the chances are that it ran out of memory. You can increase the amount of memory assigned to the 'java' command by adding -Xmx512m (or whatever value you wish to assign - make sure you actually have the amount you specify before doing so!) after the word 'java'. You can also use option --charset="[NAME]" instead of --latin1 if you are generating maps for a region that does not use the latin script; [NAME] in this case should be an encoding that covers the region you are doing (for example, koi8r for Russian Cyrillic).

This process will generate the gmapsupp.img file that you need to put onto your Garmin to make use of the routable maps. I strongly suggest you back up everything on your Garmin's memory before doing so!

Comment from skela on 21 January 2009 at 22:05

I had to pass --codepage=1252 to osm2mp.pl. In that way, the labels were in latin1 in the *.mp file. I also passed --latin1 to mkgmap-nod. Without the --codepage=1252, my Garmin Edge 705 would display the labels as if they were UTF-8 misinterpreted as ISO 8859-1 (two funny characters per non-ASCII character).

Comment from Mark Pokorny on 23 January 2009 at 00:03

Thanks skela! I'll edit the post with your suggestion now!

Comment from Mark Pokorny on 23 January 2009 at 00:09

Hmm, I thought I could edit my own comments, but it looks like I can't…I'll get the hang of this yet!

Comment from sxc625 on 6 February 2009 at 08:34

Hi Mark,
your tutorial works. Cool
But one question, how do download the data. I used osmget.pl also and took coordinates like that: 13,48,14,49 for box 1 and then 13,49,14,50 for box 2.
It works, I get a map which is routable and I'm also able to integrate it into Mapsource, but there, the boxes are overlapping. No only a few degrees are overlapping it an massive overlap. How can I prevent this? Do you know any hint for solving this problem?

Regards,
Marco

Comment from Mark Pokorny on 8 February 2009 at 19:23

Hi Marco, glad it works for you!

I think the OSM server automatically uploads the entire content of any ways or areas that cross the edges of the boxes you want to download. This means that if you download two adjacent boxes, any items that cross the boundary between the two boxes will be duplicated, causing the overlap.

As you're using two adjacent boxes, you should be able to use:

perl osmget.pl "13,48,14,50" > map_name.osm

to get the area you wish. osmget.pl will automatically break it up into smaller bits in order to retrieve them from the server, and then recombine them when they arrive at your computer into a single file (in this case, 'map_name.osm'). This should stop any duplication.

If you already have the boxes downloaded (no doubt you probably have), then you might be able to use the osmsort.pl tool to eliminate any duplicated ways. I'm not sure if that'll work, but you can give it a go to see.

I hope that helps a little. If not, let me know and I'll do a little bit more investigating.

Regards,

Mark.

Log in to leave a comment