Avoid emitting empty `<ele>` items in GPX

This commit is contained in:
Lucas Verney 2018-08-06 23:28:47 +02:00
parent 6a70deec70
commit 2cce5e9dba
1 changed files with 8 additions and 3 deletions

View File

@ -98,9 +98,14 @@ export default {
methods: {
exportGPX() {
const activityName = this.$t('misc.activityName');
const waypoints = this.$store.state.location.gpx.map(
item => Object.assign({}, item, { timestamp: new Date(item.timestamp) }),
);
const waypoints = [];
this.$store.state.location.gpx.forEach((item) => {
const waypoint = Object.assign({}, item, { timestamp: new Date(item.timestamp) });
if (waypoint.elevation === null || waypoint.elevation === undefined) {
delete waypoint.elevation;
}
waypoints.push(waypoint);
});
const gpx = createGPX(waypoints, {
activityName,
creator: `Cycl'Assist v${VERSION}`,