#!/bin/bash # Programs SELF=gpxproc #GPSBABEL=/home/teemu/bin/gpsbabel GPSBABEL=/usr/local/bin/gpsbabel # Home coordinates HOME_LAT=60.142347 HOME_LON=24.666657 # Config TYPE=FIN # Files if [ x$TYPE = xFIN ]; then ZIP_FILES="3264892 3264964 3264987 3265004 3264898 3264970 3264995" ZIP_FILES="$ZIP_FILES 3265008 3264921 3264977 3265000 3265011" ZIP_FILES="$ZIP_FILES 3660369 3656955" LAST_ZIP="3656955" fi # # Process GPX files # echo "Processing $TYPE" echo "" ## ## Clean old files ## rm -f /tmp/$SELF-* rm -f /tmp/GC_$TYPE* rm -f GC_$TYPE* # Unzip GPX files for i in $ZIP_FILES; do echo Uncompressing $i.zip unzip -p $i.zip -x *-wpts.gpx > /tmp/$SELF-$$-$i.gpx done # Check if last PQ is approaching 500 caches echo echo -n "Last PQ: " echo -n `egrep "" /tmp/$SELF-$$-$LAST_ZIP.gpx | wc -l` echo " caches." echo ## ## Output one big GPX file ## echo -n "Creating GC_$TYPE.gpx .. " # Hack to prevent fixing gpsbabel for i in $ZIP_FILES; do GPX_FILES="-f /tmp/$SELF-$$-$i.gpx $GPX_FILES" done ${GPSBABEL} -i gpx \ $GPX_FILES \ -o gpx \ -F GC_$TYPE.gpx echo `egrep "" GC_$TYPE.gpx | wc -l` caches. ## ## Output nearest 1900 from home (for Garmin) ## echo -n "Creating GC_$TYPE-1900.gpx .. " ${GPSBABEL} \ -i gpx \ -f GC_$TYPE.gpx \ -x radius,lat=$HOME_LAT,lon=$HOME_LON,distance=10000,maxcount=1900 \ -o gpx \ -F GC_$TYPE-1900.gpx echo `egrep "" GC_$TYPE-1900.gpx | wc -l` caches. ## ## Output SW FIN ## echo -n "Creating GC_$TYPE-SW.gpx .. " ${GPSBABEL} -i gpx \ -f GC_$TYPE.gpx \ -x polygon,file=swfincoords \ -o gpx \ -F GC_$TYPE-SW.gpx echo `egrep "" GC_$TYPE-SW.gpx | wc -l` caches. ## ## Output Hki-Kne ## echo -n "Creating GC_$TYPE-HKIKNE.gpx .. " ${GPSBABEL} -i gpx \ -f GC_$TYPE.gpx \ -x polygon,file=hkiknecoords \ -o gpx \ -F GC_$TYPE-HKIKNE.gpx echo `egrep "" GC_$TYPE-HKIKNE.gpx | wc -l` caches. ## ## Output Tku-Kne ## echo -n "Creating GC_$TYPE-TKUKNE.gpx .. " ${GPSBABEL} -i gpx \ -f GC_$TYPE.gpx \ -x polygon,file=tkuknecoords \ -o gpx \ -F GC_$TYPE-TKUKNE.gpx echo `egrep "" GC_$TYPE-TKUKNE.gpx | wc -l` caches. ## ## Output TomTom ## echo -n "Creating GC_$TYPE.ov2 .. " ${GPSBABEL} -i gpx \ -f GC_$TYPE.gpx \ -o tomtom \ -F GC_$TYPE.ov2 echo done. ## ## Clean tmp ## rm -f /tmp/$SELF-* rm -f /tmp/GC_$TYPE* echo "" echo "All done!" echo ""