#!/bin/bash set -e if [ "$(basename "$(pwd)")" != "work" ] then >&2 echo 'You should call this script within a directory called "work".' exit 1 fi mainUrl='https://download.geofabrik.de/europe/' countries=( austria belgium croatia czech-republic germany italy luxembourg netherlands poland slovakia slovenia ) numJobs=$(($(/usr/bin/getconf _NPROCESSORS_ONLN)/2)) if [ ${numJobs} -lt 1 ] then numJobs=1 fi [ -f "sea.zip" ] || \ wget -nd 'http://osm2.pleiades.uni-wuppertal.de/sea/latest/sea.zip' [ -f "bounds.zip" ] || \ wget -nd 'http://osm2.pleiades.uni-wuppertal.de/bounds/latest/bounds.zip' needsRecompilation=false nextId="63240001" for country in "${countries[@]}" do baseName="${country}-latest.osm.pbf" baseNameDir="${country}-latest_dir" dlItem="${mainUrl}${baseName}" if [ ! -e "${baseName}" ] || ! wget -O - "${dlItem}.md5" 2> /dev/null | md5sum -c then rm -f "${baseName}" wget -nd "${dlItem}" needsRecompilation=true fi if [ ! -d "${baseNameDir}" ] then needsRecompilation=true fi if ${needsRecompilation} then if [ -d "${baseNameDir}" ] then if ls "${baseNameDir}" | grep -q '' then rm "${baseNameDir}"/* fi rmdir "${baseNameDir}" fi mkdir "${baseNameDir}" /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/splitter/splitter.jar \ --output-dir="${baseNameDir}" \ --mapid="${nextId}" \ "${baseName}" fi nextId=$[ $( ls -1 "${baseNameDir}" | \ grep '^6324....\.osm\.pbf$' | \ cut -d. -f1 | \ sort -n | \ tail -n1 ) +1 ] done if [ ! -d mkgmap-style-sheets ] then git clone 'https://github.com/ligfietser/mkgmap-style-sheets.git' needsRecompilation=true fi git -C mkgmap-style-sheets fetch --all -p if [ "$(git -C mkgmap-style-sheets rev-parse origin/HEAD)" != "$(git -C mkgmap-style-sheets rev-parse HEAD)" ] then git -C mkgmap-style-sheets checkout master git -C mkgmap-style-sheets reset --hard origin/master needsRecompilation=true fi if ${needsRecompilation} then nice /usr/lib/jvm/java-8-openjdk/jre/bin/java -jar /usr/share/java/mkgmap/mkgmap.jar \ --route \ --add-pois-to-lines \ --add-pois-to-areas \ --bounds=bounds.zip \ --precomp-sea=sea.zip \ --generate-sea \ --index \ --gmapsupp \ --family-name="OpenStreetmap mkgmap" \ --area-name="parts of europe" \ --max-jobs="${numJobs}" \ --remove-ovm-work-files \ --style-file=mkgmap-style-sheets/styles \ --style="generic new" \ "mkgmap-style-sheets/typ/osm generic new/2000.typ" \ *-latest_dir/6324????.osm.pbf rm -f 6324????.img fi