summaryrefslogtreecommitdiffstats
path: root/generate.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-10-10 23:59:38 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-10-10 23:59:38 +0200
commit682b308d8a7804d0ae2b2606b3ba0ff8814c1473 (patch)
tree9a191e0b4f963668fa60cabdd9ee33694886f35e /generate.sh
downloadopenmtbmap-682b308d8a7804d0ae2b2606b3ba0ff8814c1473.tar.gz
openmtbmap-682b308d8a7804d0ae2b2606b3ba0ff8814c1473.tar.bz2
openmtbmap-682b308d8a7804d0ae2b2606b3ba0ff8814c1473.tar.xz
openmtbmap-682b308d8a7804d0ae2b2606b3ba0ff8814c1473.zip
Initial release
Diffstat (limited to 'generate.sh')
-rwxr-xr-xgenerate.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/generate.sh b/generate.sh
new file mode 100755
index 0000000..721e09d
--- /dev/null
+++ b/generate.sh
@@ -0,0 +1,88 @@
+#! /bin/bash
+
+function prepare {
+ rm -rf work
+ mkdir work
+ mkdir -p maps
+ 7z x -owork $1 &> /dev/null
+ [ $? -ne 0 ] && 7z x -owork $1
+
+ for file_name in `find work -maxdepth 1 -name "???"`; do mv $file_name/* work/ ; done
+}
+
+function clean {
+ rm -rf work
+}
+
+if [ -z "$1" ]; then
+ echo "Usage: $1 [map_file.exe]"
+ exit 1
+fi
+
+file=$1
+
+echo "====> Generating Garmin maps for $file"
+
+if [[ "$file" =~ "velo" ]]; then
+ typ=velo*.TYP
+ name=`basename $file .exe | cut -c 5-`
+ img=maps/velo-$name.img
+else
+ typ=thin*.TYP
+ name=`basename $file .exe | cut -c 4-`
+ img=maps/mtb-$name.img
+fi
+
+if [ -f $img ]; then
+ echo "Already existing, skipping..."
+ exit 0
+fi
+
+prepare $file
+
+if [ ! -f work/$typ ]; then
+ echo "Type file is not found, failing out..."
+ exit 1
+fi
+
+id=`ls work/6*.img | head -n 1 | cut -c 6-9`
+if [ $? -ne 0 ]; then
+ echo "No image files in $file, failing out..."
+ exit 1
+fi
+
+date=`date +%d.%m.%Y`
+(
+ cd work
+
+# java -Xmx2048M -jar /usr/share/mkgmap/lib/mkgmap.jar \
+
+ if [ -f velo*.TYP ]; then
+ mkgmap \
+ --route --index --unicode \
+ --family-id=$id --family-name=velo-$name --series-name=velo-$name --area-name=$name --country-name="$name" --region-name="$name" --description="$name [velo $date]" \
+ --gmapsupp 6*.img $typ
+ else
+ mkgmap \
+ --route --index --unicode \
+ --family-id=$id --family-name=$name --series-name=$name --area-name=$name --country-name="$name" --region-name="$name" --description="$name [mtb $date]" \
+ --gmapsupp 6*.img $typ
+ fi
+)
+
+exit_code=$?
+if [ $exit_code -ne 0 ]; then
+ echo "mkgmap failed with code $exit_code, failing out..."
+ exit $exit_code
+fi
+
+if [ ! -f work/gmapsupp.img ]; then
+ echo "mkgmap failed to produce Garmin image, failing out..."
+ exit 1
+fi
+
+mv work/gmapsupp.img $img
+
+echo "====> $img done"
+
+clean