Move GPX export function and matching node_modules to the same chunk as the map
This commit is contained in:
parent
718791e95f
commit
948962987c
41
src/App.vue
41
src/App.vue
@ -63,11 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import FileSaver from 'file-saver';
|
import { DELAY_BETWEEN_API_BATCH_REQUESTS } from '@/constants';
|
||||||
import createGPX from 'gps-to-gpx';
|
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
import { DELAY_BETWEEN_API_BATCH_REQUESTS, VERSION } from '@/constants';
|
|
||||||
|
|
||||||
import ReportErrorModal from '@/components/ReportErrorModal.vue';
|
import ReportErrorModal from '@/components/ReportErrorModal.vue';
|
||||||
import ReportIssueModal from '@/components/ReportIssueModal.vue';
|
import ReportIssueModal from '@/components/ReportIssueModal.vue';
|
||||||
@ -104,41 +100,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
exportGPX() {
|
exportGPX() {
|
||||||
|
import('@/tools/exportGPX' /* webpackChunkName: "MapView" */).then((module) => {
|
||||||
const activityName = this.$t('misc.activityName');
|
const activityName = this.$t('misc.activityName');
|
||||||
|
module.default(activityName, this.$store.state.location.gpx);
|
||||||
const courseKey = 'heading';
|
|
||||||
const eleKey = 'elevation';
|
|
||||||
const hdopKey = 'hdop';
|
|
||||||
const speedKey = 'speed';
|
|
||||||
const vdopKey = 'vdop';
|
|
||||||
|
|
||||||
const waypoints = [];
|
|
||||||
this.$store.state.location.gpx.forEach((item) => {
|
|
||||||
const waypoint = Object.assign({}, item, { timestamp: new Date(item.timestamp) });
|
|
||||||
[courseKey, eleKey, hdopKey, speedKey, vdopKey].forEach((key) => {
|
|
||||||
if (waypoint[key] === null || waypoint[key] === undefined) {
|
|
||||||
delete waypoint[key];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
waypoints.push(waypoint);
|
|
||||||
});
|
|
||||||
const gpx = createGPX(waypoints, {
|
|
||||||
activityName,
|
|
||||||
creator: `Cycl'Assist v${VERSION}`,
|
|
||||||
courseKey,
|
|
||||||
eleKey,
|
|
||||||
hdopKey,
|
|
||||||
latKey: 'latitude',
|
|
||||||
lonKey: 'longitude',
|
|
||||||
speedKey,
|
|
||||||
startTime: waypoints[0].timestamp,
|
|
||||||
timeKey: 'timestamp',
|
|
||||||
vdopKey,
|
|
||||||
});
|
|
||||||
FileSaver.saveAs(
|
|
||||||
new Blob([gpx], { type: 'application/gpx+xml;charset=utf-8' }),
|
|
||||||
`cyclassist_${moment().locale('en').format('YYYY-MM-DD_HH-mm_ddd')}.gpx`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
goToAbout() {
|
goToAbout() {
|
||||||
this.$router.push({ name: 'About' });
|
this.$router.push({ name: 'About' });
|
||||||
|
41
src/tools/exportGPX.js
Normal file
41
src/tools/exportGPX.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import FileSaver from 'file-saver';
|
||||||
|
import createGPX from 'gps-to-gpx';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
import { VERSION } from '@/constants';
|
||||||
|
|
||||||
|
export default function (activityName, locationGPX) {
|
||||||
|
const courseKey = 'heading';
|
||||||
|
const eleKey = 'elevation';
|
||||||
|
const hdopKey = 'hdop';
|
||||||
|
const speedKey = 'speed';
|
||||||
|
const vdopKey = 'vdop';
|
||||||
|
|
||||||
|
const waypoints = [];
|
||||||
|
locationGPX.forEach((item) => {
|
||||||
|
const waypoint = Object.assign({}, item, { timestamp: new Date(item.timestamp) });
|
||||||
|
[courseKey, eleKey, hdopKey, speedKey, vdopKey].forEach((key) => {
|
||||||
|
if (waypoint[key] === null || waypoint[key] === undefined) {
|
||||||
|
delete waypoint[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
waypoints.push(waypoint);
|
||||||
|
});
|
||||||
|
const gpx = createGPX(waypoints, {
|
||||||
|
activityName,
|
||||||
|
creator: `Cycl'Assist v${VERSION}`,
|
||||||
|
courseKey,
|
||||||
|
eleKey,
|
||||||
|
hdopKey,
|
||||||
|
latKey: 'latitude',
|
||||||
|
lonKey: 'longitude',
|
||||||
|
speedKey,
|
||||||
|
startTime: waypoints[0].timestamp,
|
||||||
|
timeKey: 'timestamp',
|
||||||
|
vdopKey,
|
||||||
|
});
|
||||||
|
FileSaver.saveAs(
|
||||||
|
new Blob([gpx], { type: 'application/gpx+xml;charset=utf-8' }),
|
||||||
|
`cyclassist_${moment().locale('en').format('YYYY-MM-DD_HH-mm_ddd')}.gpx`,
|
||||||
|
);
|
||||||
|
}
|
@ -8,7 +8,7 @@ import Loading from '@/views/Loading.vue';
|
|||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Map: () => ({
|
Map: () => ({
|
||||||
component: import('@/views/Map.vue'),
|
component: import('@/views/Map.vue' /* webpackChunkName: "MapView" */),
|
||||||
loading: Loading,
|
loading: Loading,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user