„Nejkrásnější ze všech tajemství je být géniem a vědět to jen sám.“ Mark Twain

   ____   _____ __  __                         
  / __ \ / ____|  \/  |                            
 | |  | | (___ | \  / |  _ __ ___   __ _ _ __  ___ 
 | |  | |\___ \| |\/| | | '_ ` _ \ / _` | '_ \/ __|
 | |__| |____) | |  | | | | | | | | (_| | |_) \__ \
  \____/|_____/|_|  |_| |_| |_| |_|\__,_| .__/|___/
                                        | |        
                                        |_|
            ... on Garmin Mobile XT

UPDATE 2016/01/14

The script for converting was improved a little-bit. Now are all steps included in one script. Plus, there is no longer need for manually renaming and entering the number of maps.

Now is it simple - just keep all downloaded maps (.osm.pbf) and polygons.poly in one folder and run script osm2img.sh

Notes:
Please edit variables in the script (lines 20 - 25)

PATH_JAVA=""
PATH_OSMCONVERT=""
PATH_SPLITTER=""
PATH_MKGMAP=""
PATH_OSMFILTER=""
USING_POLY="1"

to set proper paths to your Java and other utilities (which are described below) and to choose, if you want to use file polygons.poly
(read below about polygons.poly)

Here is new bash script: osm2img.sh


1. the story behind

This is not necessary to read it... :)
In the past (maybe 9 yrs ago) I bought PDA with Windows Mobile OS, with preinstalled Nav'N'Go iGo v. 8. But when then maps we're too obsolete and new maps we're for higher versions only available, I installed there Garmin Mobile XT.
It's very old and no longer supported application, but I like it more than other (e.g. better routing that Mapfactor Free or Be-on-road...)


2. prerequisites


3. steps by general

Our goal is to create gmapsupp.img file, which contains detailed routable maps.
The steps to get gmapsupp.img file are:

  1. download countries in format .osm.pbf from download.geofabrik.de

  2. then you need to make a polygon, to define boundary of the requested area from countries (this is not needed for single country)
  3. the polygon's coordinates must be transformed into file format, which splitter can read
  4. the .osm.pbf are converted to .o5m file format, which can be merged in step 6
  5. the OSM datas can be filtered to remove tags not needed for navigation
  6. if there is more than one country downloaded/requested, then the all .o5m files must be merged into one
  7. and then the files must be splitted to tiles
  8. and finally the gmapsupp.img can be created
  9. the file gmapsupp.img can be uploaded into your PDA device, mostly into Garmin folder

Sound too difficult? No, it isn't. Here are the steps described better:


4. detailed steps

Step 1 Download .osm.pbf

Geofabrik.de has always fresh OSM data extracts, sorted by continents and countries. Visit their website and get some countries: download.geofabrik.de

Then rename all downloaded files like:
fileXXX.osm.pbf -> 1.osm.pbf
fileYYY.osm.pbf -> 2.osm.pbf
fileZZZ.osm.pbf -> 3.osm.pbf
... etc


Step 2 Creating the polygon

  1. Visit Geoplaner.com
    Then by clicking select the requested region. (shape like rectangle or circle etc)
    After that click download Route button to get .gpx file.
screenshot_geoplaner

screenshot_geoplaner


Step 3 Converting the polygon (.gpx -> .poly)

  1. Visit geocaching-dresden.de
    There you can convert .gpx file to polygon .poly.
    After that rename file to polygons.poly.
screenshot_geochaging

screenshot_geochaging

  1. Then you must close polygon (it means, than the last point of the polygon is exact the same like first point of polygon).
    Open polygons.poly in your favourite text editor, copy first coordinate to last position - see picture below.
screenshot_polygons

screenshot_polygons


Step 4 Converting .osm.pbf to .o5m

This is necessary as all .o5m files must be merged into one big .o5m file (in later step).
For this please use following command:

osmconvert -v fileXXX.osm.pbf -o=fileXXX.o5m

Here is downloadable bash script: osm2img_convert.sh
(note: please change the path to your osmconvert file and possible remove command beep.)


Step 5 Filtering .o5m

For navigation and car routing many tags are not needed. So they can be filtered out from .o5m file. So the final size of gmapsupp.img file (file with routable map) will be smaller.
For this please use following command:

osmfilter32 fileXXX.o5m -v --drop-version --keep="highway=" --keep="aeroways=aerodrome =terminal =helipad =runway" --keep="amenity =bar =cafe =fast_food =food_court =pub =restaurant =library =school =university =bus_station =car_rental =car_wash =ferry_terminal =parking =parking_entrance =parking_space =taxi =atm =bank =bureau_de_change =clinic =dentist =doctors =hospital =pharmacy =cinema =planetarium =nightclub =stripclub =theatre =courthouse =embassy =fire_station =marketplace =place_of_worship =police =post_box =post_office =shower =telephone =toilets =townhall" --keep="barrier=" --keep="boundary=" --keep="building=hotel =warehouse =cathedral =chapel =church =hospital =school =train_station =transportation =university =bridge =garage =garages" --keep="emergency=" --drop="highway=cycleway =footway" --keep="landuse=cemetery =basin =farmland =farm =forest =grass =reservoir =village_green =vineyard" --keep="leisure=marina =golf_course =park =playground =stadium =swimming_pool =water_park" --keep="place=" --keep="railway=" --keep="route=ferry =detour =road" --keep="shop=" --keep="place=" --keep="tourism=" --keep="addr=" --keep="access=" --drop-author --drop="addr:country" --drop="Annotation=" -o=${i}_filtered.o5m

Here is downloadable bash script: osm2img_filter.sh
(note: please change the path to your osmfilter32 file and possible remove command beep.)


Step 6 Merging .o5m files

This steps merges all .o5m into one and converts them back to .osm.pbf.
(the osmconvert can't merging .osm.pbf files, so that's why we have first to convert them into .o5m, then merging .o5m and then (after merging) convert them back to .osm.pbf).

osmconvert --drop-version all_files.o5m -o=merged.osm.pbf

Here is downloadable bash script: osm2img_merge.sh
(note: please change the path to your osmconvert file and possible remove command beep.)


Step 7 Splitting merged.osm.pbf

This step splits big merged.osm.pbf file into small chunks, which mgkmap.jar can handle.

java -Xmx3G -jar splitter.jar --max-nodes=1500000 --max-areas=2048 --polygon-file=polygons.poly merged.osm.pbf

Here is downloadable bash script: osm2img_split.sh
(note: please change the path to your splitter.jar file, maybe path to java and possible remove command beep.)
(note: the switch -Xmx3G defines amount of memory for java heap, can be lowered or raised, depends of your free memory in the system.)


Step 8 Creating gmapsupp.img

This step makes from small splitted parts the routable Garmin map, with the name gmapsupp.img

java -Xmx3G -jar mkgmap.jar --road-name-pois --remove-short-arcs --index --add-pois-to-areas --drive-on-right --check-roundabouts --latin1 --show-profiles=1 --link-pois-to-ways --location-autofill=2 --merge-lines --description="OSM MAPA" --reduce-point-density=3 --country-name='MAPA' --country-abbr=MAP --gmapsupp --code-page:1250 --route --remove-ovm-work-files --lower-case --housenumbers --generate-sea=multipolygon,extend-sea-sectors,floodblocker 6324*.osm.pbf

Here is downloadable bash script: osm2img_make_gmapsupp.sh
(note: please change the path to your mkgmap.jar file, maybe path to java and possible remove command beep.)
(note: the switch -Xmx3G defines amount of memory for java heap, can be lowered or raised, depends of your free memory in the system.)


Step 9 Uploading gmapsupp.img into PDA

So final file gmapsupp.img can be copied into your PDA, into folder named Garmin.



Well, now you can delete all temporary files. Or you can save polygons.poly for future use.



In case of question do not hesitate to read manuals about all utilities. :)
Or you can still drop me an e-mail: fela.nascarfan(at)gmail(dot)com



Proudly made with GNU Emacs with markdown-mode.
Author of CSS style: Florian Wolters, http://github.com/FlorianWolters/jekyll-bootstrap-theme

  ,           , 
 /             \ 
((__-^^-,-^^-__)) 
 `-_---' `---_-' 
  `--|o` 'o|--' 
     \  `  / 
      ): :( 
      :o_o: 
       "-" 
      
      G N U