# This covers conversions to and from various speed units.
echo 'DESCRIPTION  Speed Test' > ${TMPDIR}/speed.style
echo 'EXTENSION csv' >> ${TMPDIR}/speed.style
echo 'FIELD_DELIMITER COMMA' >> ${TMPDIR}/speed.style
echo 'RECORD_DELIMITER NEWLINE' >> ${TMPDIR}/speed.style
echo 'DATATYPE TRACK' >> ${TMPDIR}/speed.style
echo 'PROLOGUE Lat,Lon,Speed(m/s),Speed(km/hr),Speed(mile/hr),Speed(knots)' >> ${TMPDIR}/speed.style
echo 'OFIELD LAT_DECIMAL,"","%f"' >> ${TMPDIR}/speed.style
echo 'OFIELD LON_DECIMAL,"","%f"' >> ${TMPDIR}/speed.style
echo 'OFIELD PATH_SPEED,"","%.6e"' >> ${TMPDIR}/speed.style
echo 'OFIELD PATH_SPEED_KPH,"","%.6e"' >> ${TMPDIR}/speed.style
echo 'OFIELD PATH_SPEED_MPH,"","%.6e"' >> ${TMPDIR}/speed.style
echo 'OFIELD PATH_SPEED_KNOTS,"","%.6e"' >> ${TMPDIR}/speed.style

gpsbabel -t -i unicsv -f ${REFERENCE}/speed.csv -o xcsv,style=${TMPDIR}/speed.style -F ${TMPDIR}/speed~csv.csv
compare ${REFERENCE}/speed~csv.csv ${TMPDIR}/speed~csv.csv

# This covers distance conversions to meters, but only a couple from meters.
echo 'DESCRIPTION  Distance Test' > ${TMPDIR}/distance.style
echo 'EXTENSION csv' >> ${TMPDIR}/distance.style
echo 'FIELD_DELIMITER COMMA' >> ${TMPDIR}/distance.style
echo 'RECORD_DELIMITER NEWLINE' >> ${TMPDIR}/distance.style
echo 'DATATYPE TRACK' >> ${TMPDIR}/distance.style
echo 'PROLOGUE Lat,Lon,Alt(m),Alt(ft)' >> ${TMPDIR}/distance.style
echo 'OFIELD LAT_DECIMAL,"","%f"' >> ${TMPDIR}/distance.style
echo 'OFIELD LON_DECIMAL,"","%f"' >> ${TMPDIR}/distance.style
echo 'OFIELD ALT_METERS,"","%.6e"' >> ${TMPDIR}/distance.style
echo 'OFIELD ALT_FEET,"","%.6e"' >> ${TMPDIR}/distance.style

gpsbabel -t -i unicsv -f ${REFERENCE}/distance.csv -o xcsv,style=${TMPDIR}/distance.style -F ${TMPDIR}/distance~csv.csv
compare ${REFERENCE}/distance~csv.csv ${TMPDIR}/distance~csv.csv

# This covers additional distance conversions from meters.
echo 'DESCRIPTION  Distance 2 Test' > ${TMPDIR}/distance2.style
echo 'EXTENSION csv' >> ${TMPDIR}/distance2.style
echo 'FIELD_DELIMITER COMMA' >> ${TMPDIR}/distance2.style
echo 'RECORD_DELIMITER NEWLINE' >> ${TMPDIR}/distance2.style
echo 'DATATYPE TRACK' >> ${TMPDIR}/distance2.style
echo 'PROLOGUE Lat,Lon,Dist(m),Dist(mile),Dist(nautical miles)' >> ${TMPDIR}/distance2.style
echo 'IFIELD LAT_DECIMAL,"","%f"' >> ${TMPDIR}/distance2.style
echo 'IFIELD LON_DECIMAL,"","%f"' >> ${TMPDIR}/distance2.style
echo 'IFIELD PATH_DISTANCE_METERS,"","%.6e"' >> ${TMPDIR}/distance2.style
echo 'OFIELD LAT_DECIMAL,"","%f"' >> ${TMPDIR}/distance2.style
echo 'OFIELD LON_DECIMAL,"","%f"' >> ${TMPDIR}/distance2.style
echo 'OFIELD PATH_DISTANCE_METERS,"","%.6e"' >> ${TMPDIR}/distance2.style
echo 'OFIELD PATH_DISTANCE_MILES,"","%.6e"' >> ${TMPDIR}/distance2.style
echo 'OFIELD PATH_DISTANCE_NAUTICAL_MILES,"","%.6e"' >> ${TMPDIR}/distance2.style

gpsbabel -t -i xcsv,style=${TMPDIR}/distance2.style -f ${REFERENCE}/distance2.csv -o xcsv,style=${TMPDIR}/distance2.style -F ${TMPDIR}/distance2~csv.csv
compare ${REFERENCE}/distance2~csv.csv ${TMPDIR}/distance2~csv.csv

# This covers xcsv path distances.
# Reference has points ~1000m apart.
echo 'DESCRIPTION  Distance 3 Test' > ${TMPDIR}/distance3.style
echo 'EXTENSION csv' >> ${TMPDIR}/distance3.style
echo 'FIELD_DELIMITER COMMA' >> ${TMPDIR}/distance3.style
echo 'RECORD_DELIMITER NEWLINE' >> ${TMPDIR}/distance3.style
echo 'DATATYPE TRACK' >> ${TMPDIR}/distance3.style
echo 'PROLOGUE Utm,Dist(m),Dist(km),Dist(mile),Dist(nautical miles)' >> ${TMPDIR}/distance3.style
echo 'IFIELD UTM,"","%s"' >> ${TMPDIR}/distance3.style
echo 'OFIELD UTM,"","%s"' >> ${TMPDIR}/distance3.style
echo 'OFIELD PATH_DISTANCE_METERS,"","%.6e"' >> ${TMPDIR}/distance3.style
echo 'OFIELD PATH_DISTANCE_KM,"","%.6e"' >> ${TMPDIR}/distance3.style
echo 'OFIELD PATH_DISTANCE_MILES,"","%.6e"' >> ${TMPDIR}/distance3.style
echo 'OFIELD PATH_DISTANCE_NAUTICAL_MILES,"","%.6e"' >> ${TMPDIR}/distance3.style

gpsbabel -t -i xcsv,style=${TMPDIR}/distance3.style -f ${REFERENCE}/distance3.csv -o xcsv,style=${TMPDIR}/distance3.style -F ${TMPDIR}/distance3~csv.csv
compare ${REFERENCE}/distance3~csv.csv ${TMPDIR}/distance3~csv.csv

echo 'DESCRIPTION	dotnet test' > ${TMPDIR}/dotnet.style
echo 'EXTENSION	csv' >> ${TMPDIR}/dotnet.style
echo 'DATATYPE	WAYPOINT' >> ${TMPDIR}/dotnet.style
echo 'FIELD_DELIMITER		COMMA' >> ${TMPDIR}/dotnet.style
echo 'RECORD_DELIMITER	NEWLINE' >> ${TMPDIR}/dotnet.style
echo 'BADCHARS	COMMA' >> ${TMPDIR}/dotnet.style
echo 'IFIELD	NET_TIME, "","%lld"' >> ${TMPDIR}/dotnet.style
echo 'IFIELD	LAT_DECIMAL,"","%.9f"' >> ${TMPDIR}/dotnet.style
echo 'IFIELD	LON_DECIMAL,"","%.9f"' >> ${TMPDIR}/dotnet.style
gpsbabel -i xcsv,style=${TMPDIR}/dotnet.style -f ${REFERENCE}/dotnet.csv -o unicsv,utc=0 -F ${TMPDIR}/dotnet.csv
compare ${REFERENCE}/dotnet~csv.csv ${TMPDIR}/dotnet.csv

