| 1 | # Script file for converting POSPac output ASCII SBET files into nav files readable by CaliGeo |
|---|
| 2 | # |
|---|
| 3 | # Author: Ben Taylor |
|---|
| 4 | # Date: 05/02/2008 |
|---|
| 5 | # |
|---|
| 6 | # Arguments: |
|---|
| 7 | # $1: Input file name |
|---|
| 8 | # $2: Output file name |
|---|
| 9 | # $3: -del to delete original ASCII sbet file when done (default), -nodel to leave it there |
|---|
| 10 | |
|---|
| 11 | if [ ! $2 ] ; then |
|---|
| 12 | echo "Not enough arguments. Usage: sbet2cali.sh Input_File Output_File [-del|-nodel]" |
|---|
| 13 | exit 1 |
|---|
| 14 | elif [ $3 ] ; then |
|---|
| 15 | if [ $3 == "-nodel" ] ; then |
|---|
| 16 | NODELETEFILE=true |
|---|
| 17 | elif [ $3 != "-del" ] ; then |
|---|
| 18 | echo "Delete argument unrecognised. Usage: sbet2cali.sh Input_File Output_File [-del|-nodel]" |
|---|
| 19 | exit 1 |
|---|
| 20 | fi |
|---|
| 21 | fi |
|---|
| 22 | |
|---|
| 23 | TEMPDIR=/tmp #Temp directory location - must exist |
|---|
| 24 | |
|---|
| 25 | #Temporary files |
|---|
| 26 | TEMPFILE=${TEMPDIR}/cali_tmp.txt |
|---|
| 27 | |
|---|
| 28 | # First line specifies that first column is GPS time |
|---|
| 29 | echo "time = gps" > $2 |
|---|
| 30 | echo "; TIME(s) LATITUDE(deg) LONGITUDE(deg) ALTITUDE(m) ROLL(deg) PITCH(deg) HEADING(deg)" >> $2 |
|---|
| 31 | |
|---|
| 32 | # Trim off first 23 lines - header information not used by CaliGeo |
|---|
| 33 | tail -n +24 $1 > $TEMPFILE |
|---|
| 34 | |
|---|
| 35 | # Run AWK script to trim unwanted columns |
|---|
| 36 | awk '{ \ |
|---|
| 37 | printf "%s %s %s %s %s %s %s\n", $1, $6, $7, $8, $9, $10, $11 |
|---|
| 38 | }' $TEMPFILE >> $2 |
|---|
| 39 | |
|---|
| 40 | # Delete temporary file |
|---|
| 41 | rm -f $TEMPFILE |
|---|
| 42 | |
|---|
| 43 | # Delete original ASCII sbet file unless user opted not to (don't need it any more) |
|---|
| 44 | if [ ! $NODELETEFILE ] ; then |
|---|
| 45 | rm -f $1 |
|---|
| 46 | fi |
|---|