Trt2gpx.sh
FEWiki
Seuraavanlaisella skriptillä Harald käsittelee SeaTrace ohjelman luomia TRT-tiedostoja suoraan gpsactionreplay javaohjelman ymmärtämään muotoon. Skripti lukee TRT-tiedoston ja arvailee siitä kyseisen trackin päivämäärän. Se muuntaa kyseisen TRT-tiedoston GPX-muotoon, poistaa siitä turhia pisteitä jotta tiedostonkoko olisi sopiva gpsar:ille sekä nimeää tiedostossa olevan jäljen veneen nimen perusteella.
Lopuksi skripti kysyy koska kisa alkoi, ja päättyi. Ellei anneta aikoja, skripti olettaa niitten olevan 15:08 ja 22:00 välisenä aikana. Nämä ajat on toistaiseksi annettava UTC-ajassa, joka on siis suomen kesäaikaa miinus kolme tuntia. Lähtö 18:10 suomen aikaa on täten UTC-muodossa 15:10.
Skripti on bash shell-skripti, vaatii gpsbabel version 1.3.6 tai uudempi, sekä seatrace.style-tiedoston konfiguroimista skriptiin.
Tallenna skripti tiedostoon nimeltään trt2gpx.sh. Aseta skriptille ajo-oikeudet komennolla chmod 755 trt2gpx.sh ja tarkasta että skripti löytyy hakupolustasi.
trt2gpx.sh
#! /bin/bash
# © 21 aug 06, Harald Hannelius
# this one reads a SeaTrace trt-file and spits out a GPX file
stylefile=/home/harald/gpsbabel/seatrace.style
if [ -z ${1} ] ; then
echo give input file as arg1
exit 1
elif [ ! -f "${1}" ] ; then
echo "file $1 not found, exiting"
exit 2
else
infile="${1}"
fi
defaultname="Charlotta" # Edit this for your boat
echo -n "Enter boatname [$defaultname]: "
read name
if [ -z "${name}" ] ; then
name=$defaultname
fi
# filter, 3s average
shorten="-x simplify,count=500"
title="-x track,title=${name}"
newfile="`basename "$infile" .trt`.gpx"
echo -n "figuring out the date from TRT "
date=$(head -n3 "${infile}" | tail -n1 | awk '{print $1}')
echo [$date] .. done
echo -n "converting TRT to GPX.. "
if [ ! -f "${stylefile}" ] ; then
echo "stylefile $stylefile not found, exiting"
exit 6
fi
gpsbabel -t -i xcsv,style=$stylefile -f "$infile" $shorten $title -o gpx -F "$newfile"
echo done
echo -n "cropping the track, UTC start-time [1508]: "
read starttime
if [ -z "${starttime}" ]; then
starttime=1508
fi
echo -n "enter goaltime in UTC (EEST - 3 hrs) [2000]: "
read goaltime
if [ -z "${goaltime}" ] ; then
goaltime=2000
fi
gpsbabel -t -i gpx -f "$newfile" -x track,start=${date}${starttime},stop=${date}${goaltime} -o gpx -F "${newfile%.gpx}.cut.gpx"
echo "GPX: ${newfile}, cropped GPX: ${newfile%.gpx}.cut.gpx"
exit 0
Skriptin käyttäminen on helppoa. Kerro sille TRT-tiedoston nimi, ja skripti tekee loput:
$ trt2gpx.sh 20090520.TRT Enter boatname [Charlotta]: figuring out the date from TRT [20090520] .. done converting TRT to GPX.. done cropping the track, UTC start-time [1508]: enter goaltime in UTC (EEST - 3 hrs) [2000]: 1646 GPX: 20090520.TRT.gpx, cropped GPX: 20090520.TRT.cut.gpx $
Jos on tarvetta, julkaistaan skripti joka lukee ibt747 GPS-dataloggeria, ja tekee tästä automaattisesti GPX-tiedoston seurantaa varten.
