
# Garmin Mapsource This is a binary format with some undocumented
# fields.  This test is therefore intentionally vague.  We read a file,
# convert it to GPX, then write a file as MPS, then read it back and
# write it as GPX and compare them.  Since we're writing both GPX files
# ourselves from the same version, we're immune to changes in our own
# GPX output.

rm -fr ${TMPDIR}/ms.gpx ${TMPDIR}/ms[12].gpx
gpsbabel -i mapsource -f ${REFERENCE}/mapsource.mps  -o gpx -F ${TMPDIR}/ms1.gpx
gpsbabel -i mapsource -f ${REFERENCE}/mapsource.mps  -o mapsource -F ${TMPDIR}/ms.mps
gpsbabel -i mapsource -f ${TMPDIR}/ms.mps -o gpx -F ${TMPDIR}/ms2.gpx
compare ${TMPDIR}/ms1.gpx ${TMPDIR}/ms2.gpx

#
# MRCB mapsource track test
#
rm -f ${TMPDIR}/mps-track.mps
gpsbabel -t -i mapsource -f ${REFERENCE}/track/mps-track.mps -o mapsource,mpsverout=3 \
         -F ${TMPDIR}/mps-track.mps
compare ${TMPDIR}/mps-track.mps ${REFERENCE}/track

# Now do a test of reading waypoints from a track-only file - should have an empty result
rm -f ${TMPDIR}/mps-track.mps
gpsbabel -i mapsource -f ${REFERENCE}/track/mps-track.mps -o mapsource,mpsverout=3 \
         -F ${TMPDIR}/mps-track.mps
compare ${REFERENCE}/mps-empty.mps ${TMPDIR}/mps-track.mps

#
# MRCB mapsource route test
#
rm -f ${TMPDIR}/mps-route.mps
gpsbabel -r -i mapsource -f ${REFERENCE}/route/route.mps -o mapsource,mpsverout=4 \
         -F ${TMPDIR}/mps-route.mps
compare ${REFERENCE}/route/route.mps ${TMPDIR}/mps-route.mps

# Now do a test of reading tracks from a route-only file - should have an empty result
rm -f ${TMPDIR}/mps-route.mps
gpsbabel -t -i mapsource -f ${REFERENCE}/route/route.mps -o mapsource,mpsverout=3 \
         -F ${TMPDIR}/mps-route.mps
compare ${REFERENCE}/mps-empty.mps ${TMPDIR}/mps-route.mps
