@echo off
rem --------------------------------------------------
rem --- CreateIMG.bat - By Marco Certelli - Beta07 ---
rem --------------------------------------------------
rem **** Define your default country ****
set country=africa-latest
rem *************************************
rem Available styles: drivemap, kleineisel, masterstyle, default, marine, noname, test
set style=drivemap
rem Available TYPfiles: DRIVEMAP.TYP, KLEINEISEL.TYP, MASTER.TYP, TEDDY.TYP, DOM.TYP
set typfile=velwaus.TYP
rem Put AddTypToIMG=yes to add TYPfile to gmapsupp.img (so it is active in garmin too)
set AddTypToIMG=yes
rem MapSource Family-ID: must be a unique (in mapsource) 3 digit number (000 to 999)
set FID=890
rem MSDir shall contain the "existing" directory where mapsource installs maps
rem Next usually results in MSDir=C:\\Garmin
set MSDir=%systemdrive%\\Garmin
rem Next usually results in MSDir=C:\\Program Files\\Garmin
rem set MSDir=%ProgramFiles%
rem set MSDir=%MSDir:\=\\%
rem set MSDir=%MSDir%\\Garmin
hen
rem Available continents: europe, africa, asia, north-america, south-america
set continent=
rem Just leave debug=no for production & to delete intermediate temporary files.
set debug=no
echo.
echo ******************************************************
echo * This script downloads (if needed) and compiles the *
echo * OSM map data to generate a Garmin IMG routable map *
echo ******************************************************
echo.
rem Override default country if a name is given to the batch as parameter
if "%1" NEQ "" set country=%1
rem Ask user for a country name if no default and no parameter is set
if "%country%" NEQ "" goto :Search4Map
set /P country="Enter the country to build: "
echo.
:Search4Map
if NOT EXIST OSM-Data mkdir OSM-Data
cd OSM-Data
rem 1) search for xxx.osm file
rem set osmfile=%country%.osm
rem if EXIST %osmfile% echo File OSM-Data\%osmfile% found (no download required)
rem if EXIST %osmfile% GOTO :SplitMap
rem 2) search for xxx.osm.bz2 file
rem set osmfile=%country%.osm.bz2
rem if EXIST %osmfile% echo File OSM-Data\%osmfile% found: delete it for a new download
rem if EXIST %osmfile% GOTO :SplitMap
rem 3) search for xxx.osm.pbf file
set osmfile=%country%.osm.pbf
if EXIST %osmfile% echo File OSM-Data\%osmfile% found: delete it for a new download
if EXIST %osmfile% GOTO :SplitMap
echo.
echo Downloading OSM data for %country%
echo.
if EXIST %osmfile% goto :SplitMap
echo.
echo *************************************************************
echo *** SORRY: download of /%continent%/%osmfile% has FAILED!!!
echo *** and manually download %osmfile%
echo *************************************************************
echo.
goto :END
:SplitMap
echo.
echo Start converting %country% OSM data into IMG Map...
if NOT EXIST ..\IMG-OSM-%country% mkdir ..\IMG-OSM-%country%
cd ..\IMG-OSM-%country%
if EXIST template.args goto :Compile
echo.
echo Splitting OSM-Data\%osmfile%. Please wait
echo.
rem start /low /b /wait java -enableassertions -Xmx1000m -jar ..\bin\splitter.jar --mapid=66%FID%001 --max-nodes=1000000 ..\OSM-Data\%osmfile%
rem start /low /b /wait java -enableassertions -Xmx1250m -jar ..\bin\splitter.jar --mapid=66%FID%001 --output=xml ..\OSM-Data\%osmfile%
start /low /b /wait java -enableassertions -Xmx800m -jar ..\bin\splitter.jar --mapid=66%FID%001 ..\OSM-Data\%osmfile% --output=xml --max-nodes=80000 --problem-report=problem.txt --keep-complete=true --status-freq=120
:Compile
echo.
echo Compiling OSM-Data\%osmfile% into IMG, FID=%FID%. Please wait
echo.
set TypFileToAdd=
if "%AddTypToIMG%" NEQ "yes" goto :NoTypToAdd
copy "..\bin\typ\%typfile%" style.typ 2>nul 1>nul
..\bin\TYPtool %FID% 1 style.typ >nul
set TypFileToAdd=style.typ
:NoTypToAdd
rem start /low /b /wait java -enableassertions -Xmx1000m -jar ..\bin\mkgmap.jar --country-name="%country%" --family-id=%FID% --mapname=66%FID%001 --overview-mapname=66%FID%000 --series-name="OSM-%country%" --family-name="OpenStreetMap: %country%" --style-file=..\bin\styles\ --style=%style% --description="%country%" -c ..\bin\template_basic.args -c template.args %TypFileToAdd%
rem start /low /b /wait java -enableassertions -Xmx800m -jar ..\bin\mkgmap.jar --overview-levels --link-pois-to-ways --polygon-size-limits="24:12, 18:10, 16:8, 14:4, 12:2, 11:0" --check-styles --process-exits --merge-lines --add-pois-to-areas --style=default --pois-to-areas-placement=tagelist --add-pois-to-lines --tdbfile --transparent --make-poi-index --reduce-point-density=2.6 --reduce-point-density-polygon=4 --index --levels=0:24,1:22,2:20,3:18,4:16,5:14 --make-poi-index --verbose --route --country-name="%country%" --family-id=%FID% --mapname=66%FID%001 --overview-mapname=66%FID%000 --series-name="OSM-%country%" --family-name="OpenStreetMap: %country%" --style-file=..\bin\styles\ --style=%style% --description="%country%" -c ..\bin\template_basic.args -c template.args %TypFileToAdd%
start /low /b /wait java -enableassertions -Xmx500m -jar ..\bin\mkgmap.jar --housenumbers --overview-levels --link-pois-to-ways --polygon-size-limits="24:12, 18:10, 16:8, 14:4, 12:2, 11:0" --process-exits --merge-lines --add-pois-to-areas --style=default --pois-to-areas-placement=tagelist --add-pois-to-lines --tdbfile --transparent --make-poi-index --reduce-point-density=2.6 --reduce-point-density-polygon=4 --index --levels=0:24,1:22,2:20,3:18,4:16,5:14 --make-poi-index --verbose --route --country-name="%country%" --family-id=%FID% --mapname=66%FID%001 --overview-mapname=66%FID%000 --series-name="OSM-%country%" --family-name="OpenStreetMap: %country%" --style-file=..\bin\styles\ --style=%style% --description="%country%" -c ..\bin\template_basic.args -c template.args %TypFileToAdd%
if EXIST 66%FID%001.img goto :Cleanup
echo.
echo ***********************************************
echo *** SORRY: IMG compiling task has FAILED!!! ***
echo ***********************************************
echo.
goto :END
:Cleanup
if "%debug%" NEQ "no" goto :MSPrepare
del *.gz 2>nul
del *.pbf 2>nul
del areas.list 2>nul
del template.args 2>nul
if EXIST %MSDir% goto :MSPrepare
echo.
echo MapSource Install files not prepared ("%MSDir%" not existing)
goto :END
:MSPrepare
echo.
echo Preparing MapSource Install (.reg)
echo.
copy ..\bin\typ\%typfile% style.typ 2>nul 1>nul
rem preparing MapSource installer registry
echo Windows Registry Editor Version 5.00 > IMG-OSM-%country%_MSInstall.reg
echo. >> IMG-OSM-%country%_MSInstall.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Garmin\Mapsource\Families\IMG-OSM-%country%] >> IMG-OSM-%country%_MSInstall.reg
rem TYPtool <family_id> <product_id> <stylefile>
..\bin\TYPtool %FID% 1 style.typ >> IMG-OSM-%country%_MSInstall.reg
if EXIST style.typ echo "TYP"="%MSDir%\\IMG-OSM-%country%\\style.typ" >> IMG-OSM-%country%_MSInstall.reg
echo. >> IMG-OSM-%country%_MSInstall.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Garmin\Mapsource\Families\IMG-OSM-%country%\1] >> IMG-OSM-%country%_MSInstall.reg
echo "BMAP"="%MSDir%\\IMG-OSM-%country%\\66%FID%000.img" >> IMG-OSM-%country%_MSInstall.reg
echo "LOC"="%MSDir%\\IMG-OSM-%country%" >> IMG-OSM-%country%_MSInstall.reg
echo "TDB"="%MSDir%\\IMG-OSM-%country%\\66%FID%000.tdb" >> IMG-OSM-%country%_MSInstall.reg
rem preparing un-installer registry
echo Windows Registry Editor Version 5.00 > IMG-OSM-%country%_MSUnInstall.reg
echo. >> IMG-OSM-%country%_MSUnInstall.reg
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Garmin\Mapsource\Families\IMG-OSM-%country%] >> IMG-OSM-%country%_MSUnInstall.reg
:END
cd..
echo.
echo ********************************************
echo *** CreateIMG Script End - Press any key ***
echo ********************************************
if "%1" EQU "" pause >nul
the script i use gerd
will look for the logs ok
stephen