From c4d2aba012967a8636069b723c428622680b969b Mon Sep 17 00:00:00 2001 From: lookshe Date: Sun, 21 Sep 2014 00:26:15 +0200 Subject: scripts and configuration for calculating open street maps to mapsforge maps --- osm/download_and_convert.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 osm/download_and_convert.sh (limited to 'osm/download_and_convert.sh') diff --git a/osm/download_and_convert.sh b/osm/download_and_convert.sh new file mode 100755 index 0000000..d5c4d5a --- /dev/null +++ b/osm/download_and_convert.sh @@ -0,0 +1,68 @@ +#!/bin/bash +#set -x + +if [ $# -ne 8 ] +then + echo "wrong argument count" + exit 1 +fi + +url_map="$1" +url_map_filename="$(basename $url_map)" +download_map="$dir_maps/$url_map_filename" +url_poly="$2" +url_poly_filename="$(basename $url_poly)" +download_poly="$dir_poly/$url_poly_filename" +mapfile="$3" +wm_type="$4" +start_zoom="$5" +language="$6" +use_poly="$7" +output_subdir="$8" +stage_map="$dir_stage/$mapfile" +mkdir -p "$dir_output/$output_subdir/" +output_map="$dir_output/$output_subdir/$mapfile" + + +# cause of some timing problems we wait a random number of 1-10 seconds +sleep $[($RANDOM % 10) + 1] + +# check if we need to download +if [ ! -e "$download_map" ] +then + # wait if another process is downloading it + if [ -e "$download_map.tmp" ] + then + while [ ! -e "$download_map" ] + do + sleep 10 + done + # download if we are the only one + else + touch "$download_map.tmp" + wget -q --limit-rate=$wget_limit_rate "$url_map" -O "$download_map.tmp" + mv -f "$download_map.tmp" "$download_map" + fi +fi + +# download poly-file +wget -q --limit-rate=$wget_limit_rate "$url_poly" -O "$download_poly" + +echo "start: $(date)" >> "$stage_map.time" +if [ "$use_poly" = "true" ] +then + echo "command: $osmosis_executable --rb \"$download_map\" --bp clipIncompleteEntities=true file=\"$download_poly\" --mw file=\"$stage_map\" type=\"$wm_type\" map-start-zoom=\"$start_zoom\" preferred-language=\"$language\"" >> "$stage_map.time" + $osmosis_executable --rb "$download_map" --bp clipIncompleteEntities=true file="$download_poly" --mw file="$stage_map" type="$wm_type" map-start-zoom="$start_zoom" preferred-language="$language" > "$stage_map.log" 2>&1 + ret=$? +else + echo "command: $osmosis_executable --rb \"$download_map\" --mw file=\"$stage_map\" type=\"$wm_type\" map-start-zoom=\"$start_zoom\" preferred-language=\"$language\"" >> "$stage_map.time" + $osmosis_executable --rb "$download_map" --mw file="$stage_map" type="$wm_type" map-start-zoom="$start_zoom" preferred-language="$language" > "$stage_map.log" 2>&1 + ret=$? +fi +echo "end: $(date)" >> "$stage_map.time" + +if [ $ret -eq 0 ] +then + mv -f "$stage_map" "$output_map" + rm -f "$stage_map.log" +fi -- cgit v1.2.3