Last active
January 4, 2020 18:58
-
-
Save alexfouche/906a122d8f6ad66fcc1d3dec33ea6876 to your computer and use it in GitHub Desktop.
Convert GPS data from Columbus V900 to GPX format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
# | |
# Convert Visiontac VGPS-900 log file to GPX | |
# | |
# 2009-02-08 | |
# mip@rootcamp.net | |
# | |
SED='/usr/local/bin/gsed' # brew install gnu-sed | |
GREP='/usr/bin/grep' | |
GPSBABEL='/Applications/gpsbabel-20120327_1103CEST' # http://www.gpsbabel.org/download.html | |
for FILE in $* ; do | |
if [ -f "${FILE}" ] ; then | |
TMPFILE1=`mktemp -t v9csv2gpx` | |
TMPFILE2=`mktemp -t v9csv2gpx` | |
TMPFILE3=`mktemp -t v9csv2gpx` | |
TMPFILE4=`mktemp -t v9csv2gpx` | |
TMPFILE5=`mktemp -t v9csv2gpx` | |
OUTFILE=`echo ${FILE} | ${SED} -e 's/\.csv/.gpx/i'` | |
# OUTFILE_10m=`echo ${FILE} | ${SED} -e 's/\.csv/_10m.gpx/i'` | |
# OUTFILE_1m=`echo ${FILE} | ${SED} -e 's/\.csv/_1m.gpx/i'` | |
echo processing $OUTFILE .... | |
# Reformat CSV into something understandable by gpsbabel unicsv | |
# moving E/W,N/S from lon/lat fields into separate ones, | |
# renaming of audio references to proper filenames, | |
# reformatting of date and time fields | |
${SED} -n -e ' s/\x0//g; | |
1s/INDEX/NAME/; | |
1s/TAG/ICON/; | |
1s# N/S#,N/S#;1s# E/W#,E/W#; | |
1s/VOX/URL/p; | |
1d;s/\([NSEW]\{1,1\}\),/,\1,/g; | |
s/ ,/,/g; | |
s/VOX\([0-9]*\)/VOX\1.WAV/g; | |
s/,\([VCT]\{1,1\}\),\([0-9]\{2,2\}\)\([0-9]\{2,2\}\)\([0-9]\{2,2\}\),\([0-9]\{2,2\}\)\([0-9]\{2,2\}\)\([0-9]\{2,2\}\)/,\1,20\2-\3-\4,\5:\6:\7/p' \ | |
"${FILE}" > $TMPFILE1 | |
# Get trackpoints and convert to gpx | |
${GREP} -E ',T,|URL' ${TMPFILE1} | ${GPSBABEL} -i unicsv -f - -x transform,trk=wpt,del -o gpx -F ${TMPFILE2} | |
# ${GREP} -E ',T,|URL' ${TMPFILE1} | ${GPSBABEL} -i unicsv -f - -x transform,trk=wpt,del -x position,distance=10m -o gpx -F ${TMPFILE4} | |
# ${GREP} -E ',T,|URL' ${TMPFILE1} | ${GPSBABEL} -i unicsv -f - -x transform,trk=wpt,del -x position,distance=1m -o gpx -F ${TMPFILE5} | |
# Get waypoints and convert to gpx | |
${GREP} -v ',T,' ${TMPFILE1} | ${GPSBABEL} -i unicsv -f - -o gpx -F ${TMPFILE3} | |
# Merge track and waypoints into single gpx, substituting url tag with link tag as known by JOSM | |
${GPSBABEL} -i gpx -f ${TMPFILE2} -i gpx -f ${TMPFILE3} -o gpx -F - | ${SED} -e 's#<\(/\{0,1\}\)url>#<\1link>#g;' > "${OUTFILE}" | |
# ${GPSBABEL} -i gpx -f ${TMPFILE4} -i gpx -f ${TMPFILE3} -o gpx -F - | ${SED} -e 's#<\(/\{0,1\}\)url>#<\1link>#g;' > "${OUTFILE_10m}" | |
# ${GPSBABEL} -i gpx -f ${TMPFILE5} -i gpx -f ${TMPFILE3} -o gpx -F - | ${SED} -e 's#<\(/\{0,1\}\)url>#<\1link>#g;' > "${OUTFILE_1m}" | |
rm -f ${TMPFILE1} | |
rm -f ${TMPFILE2} | |
rm -f ${TMPFILE3} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment