version 0.4: add all route segments to gpx file

This commit is contained in:
Sebastian Hugentobler 2021-06-16 12:42:39 +02:00
parent 8eed835aa2
commit e18added04
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
2 changed files with 8 additions and 5 deletions

View File

@ -84,7 +84,12 @@ function trackTitle(geoJson) {
* @returns Simple gpx string.
*/
function toGpx(geoJson) {
const route = geoJson.segments[0].geom;
let trackSegments = geoJson.segments.map(segment => {
return `<trkseg>
${segment.geom.coordinates.map(toTrackPoint).join("")}
</trkseg>`;
}).join("");
const routeTitle = trackTitle(geoJson);
const xmlString = `<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
@ -98,9 +103,7 @@ function toGpx(geoJson) {
${toWayPoint(geoJson.destination_poi)}
<trk>
<name>Track ${routeTitle}</name>
<trkseg>
${route.coordinates.map(toTrackPoint).join("")}
</trkseg>
${trackSegments}
</trk>
</gpx>
`;

View File

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "SAC Route Portal GPX Downloader",
"version": "0.3",
"version": "0.4",
"developer": {
"name": "Sebastian Hugentobler",
"url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"