1# 2# Quick tests for Google Earth/KML format 3# Note: Reference files are from GPSBabel's own output. 4# 5gpsbabel -i gpx -f ${REFERENCE}/gc/GC7FA4.gpx -f ${REFERENCE}/gc/GCGCA8.gpx -o kml -F ${TMPDIR}/ge-gc.kml 6compare ${REFERENCE}/earth-gc.kml ${TMPDIR}/ge-gc.kml 7gpsbabel -i gpx -f ${REFERENCE}/expertgps.gpx -o kml -F ${TMPDIR}/ge-eg.kml 8compare ${REFERENCE}/earth-expertgps.kml ${TMPDIR}/ge-eg.kml 9 10# And again, but with tracks. 11gpsbabel -i gpx -f ${REFERENCE}/expertgps.gpx -o kml,track=1 \ 12 -F ${TMPDIR}/ge-eg-track.kml 13compare ${REFERENCE}/earth-expertgps-track.kml ${TMPDIR}/ge-eg-track.kml 14 15# Segmented input, with and without <Track>. 16gpsbabel -i gpx -f ${REFERENCE}/track/segmented_tracks.gpx -o kml,track=0 \ 17 -F ${TMPDIR}/ge-seg.kml 18compare ${REFERENCE}/track/segmented_tracks.kml ${TMPDIR}/ge-seg.kml 19 20gpsbabel -i gpx -f ${REFERENCE}/track/segmented_tracks.gpx -o kml,track=1 \ 21 -F ${TMPDIR}/ge-seg-track.kml 22compare ${REFERENCE}/track/segmented_tracks-track.kml ${TMPDIR}/ge-seg-track.kml 23 24# Fitness data. 25gpsbabel -i gpx -f ${REFERENCE}/track/gpx_garmin_extensions.gpx \ 26 -o kml,track=1 -F ${TMPDIR}/ge-fitness-track.kml 27compare ${REFERENCE}/track/gpx_garmin_extensions-kml_track.kml ${TMPDIR}/ge-fitness-track.kml 28# Fitness data with more extended data, specifically power. 29gpsbabel -i gtrnctr -f ${REFERENCE}/track/gtrnctr_power.tcx \ 30 -o kml,track=1,points=0,lines=0 -F ${TMPDIR}/ge-power.kml 31compare ${REFERENCE}/track/gtrnctr_power-kml.kml ${TMPDIR}/ge-power.kml 32 33# test searches for route and waypoint min and max altitudes 34gpsbabel -i gpx -f ${REFERENCE}/bounds-test.gpx -o kml -F ${TMPDIR}/bnds.kml 35compare ${REFERENCE}/bounds-test.kml ${TMPDIR}/bnds.kml 36gpsbabel -i gpx -f ${REFERENCE}/track/bounds-test-track.gpx -o kml -F ${TMPDIR}/bnds-track.kml 37compare ${REFERENCE}/track/bounds-test-track.kml ${TMPDIR}/bnds-track.kml 38 39# Write the same file multiple times...File should always be identical. 40# This exercises two bugs discovered on 2013-06-02 in the QXmlWriter code. 41# 1) ostring wasn't cleared, so writing two KML files would accumulate them. 42# 2) There is, IMO, a bug when reinitializing the QXmlWriter that results 43# in a blank line at the beginning of the output, which makes Google Earth 44# grumpy. This totally tanks the realtime tracking mode which relies on 45# this heavily. 46gpsbabel -i gpx -f ${REFERENCE}/expertgps.gpx -o kml,track=1 \ 47 -F ${TMPDIR}/ge-eg-track1.kml \ 48 -F ${TMPDIR}/ge-eg-track2.kml \ 49 -F ${TMPDIR}/ge-eg-track3.kml 50 51# 1 should be == 2. 2 should be == 3. 52compare ${TMPDIR}/ge-eg-track1.kml ${TMPDIR}/ge-eg-track2.kml 53compare ${TMPDIR}/ge-eg-track2.kml ${TMPDIR}/ge-eg-track3.kml 54 55# test std output 56rm -f ${TMPDIR}/bnds_so.kml 57gpsbabel -i gpx -f ${REFERENCE}/bounds-test.gpx -o kml -F - 1> ${TMPDIR}/bnds_so.kml 58compare ${REFERENCE}/bounds-test.kml ${TMPDIR}/bnds_so.kml 59 60# test direction icons 61gpsbabel -i gpx -f ${REFERENCE}/track/tracks.gpx -o kml,track=1,trackdirection=1,units='m' -F ${TMPDIR}/tracks~gpx.kml 62compare ${REFERENCE}/track/tracks~gpx.kml ${TMPDIR}/tracks~gpx.kml 63 64# kml 2.3 65gpsbabel -i kml -f ${REFERENCE}/track/Placemark-Track-1.kml -o gpx -F ${TMPDIR}/Placemark-Track-1~kml.gpx 66compare ${REFERENCE}/track/Placemark-Track-1~kml.gpx ${TMPDIR}/Placemark-Track-1~kml.gpx 67 68# kml realtime writer 69gpsbabel -T -i random,points=20,seed=33,nodelay -f dummy -o kml,track -F ${TMPDIR}/realtime.kml 70compare ${REFERENCE}/realtime.kml ${TMPDIR}/realtime.kml 71 72if [ "${RUNNINGVALGRIND}" != "0" ]; then 73 set -e 74 if which xmllint > /dev/null; 75 then 76 KMLS=$(find ${REFERENCE} -name \*.kml) 77 for f in $KMLS 78 do 79 case $f in 80 # Argue with the KML wizards about this. It was the intent for that 81 # to be legal in Earth GX 2.2. 82 ${REFERENCE}/track/segmented_tracks-track.kml) continue;; 83 *) 84 tmpf=${TMPDIR}/$(basename $f) 85 gpsbabel -i kml -f $f -o kml -F $tmpf 86 xmllint --schema ${BASEPATH}/tools/kml22-schema/kml22gx.xsd --noout $tmpf 87 esac; 88 done 89 else 90 echo "Skipping KML validation phase." 91 fi 92 set +e 93fi 94