Merge pull request #79 from matthiasblaesing/valid-xml

Fix XML structure for gpx export of recorded track
This commit is contained in:
y20k 2020-08-27 13:59:25 +02:00 committed by GitHub
commit f3d4fb303f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,6 +158,7 @@ object TrackHelper {
// add header // add header
gpxString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n" + gpxString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n" +
"<gpx version=\"1.1\" creator=\"Trackbook App (Android)\"\n" + "<gpx version=\"1.1\" creator=\"Trackbook App (Android)\"\n" +
" xmlns=\"http://www.topografix.com/GPX/1/1\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n" " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"
@ -180,9 +181,11 @@ object TrackHelper {
/* Creates name for GPX file */ /* Creates name for GPX file */
private fun createGpxName(track: Track): String { private fun createGpxName(track: Track): String {
val gpxName = StringBuilder("") val gpxName = StringBuilder("")
gpxName.append("\t<name>") gpxName.append("\t<metadata>\n");
gpxName.append("\t\t<name>")
gpxName.append("Trackbook Recording: ${track.name}") gpxName.append("Trackbook Recording: ${track.name}")
gpxName.append("</name>\n") gpxName.append("</name>\n")
gpxName.append("\t</metadata>\n");
return gpxName.toString() return gpxName.toString()
} }
@ -241,16 +244,16 @@ object TrackHelper {
gpxTrack.append(wayPoint.longitude) gpxTrack.append(wayPoint.longitude)
gpxTrack.append("\">\n") gpxTrack.append("\">\n")
// add time
gpxTrack.append("\t\t\t\t<time>")
gpxTrack.append(dateFormat.format(Date(wayPoint.time)))
gpxTrack.append("</time>\n")
// add altitude // add altitude
gpxTrack.append("\t\t\t\t<ele>") gpxTrack.append("\t\t\t\t<ele>")
gpxTrack.append(wayPoint.altitude) gpxTrack.append(wayPoint.altitude)
gpxTrack.append("</ele>\n") gpxTrack.append("</ele>\n")
// add time
gpxTrack.append("\t\t\t\t<time>")
gpxTrack.append(dateFormat.format(Date(wayPoint.time)))
gpxTrack.append("</time>\n")
// add closing tag // add closing tag
gpxTrack.append("\t\t\t</trkpt>\n") gpxTrack.append("\t\t\t</trkpt>\n")
} }