Drop xmlbuilder from gps-to-gpx dep
This commit is contained in:
parent
7557d3b64c
commit
f5fdb2aeb0
@ -15,7 +15,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/polyfill": "^7.0.0",
|
"@babel/polyfill": "^7.0.0",
|
||||||
"file-saver": "^1.3.8",
|
"file-saver": "^1.3.8",
|
||||||
"gps-to-gpx": "^1.4.0",
|
"gps-to-gpx": "git://github.com/phyks/gps-to-gpx.git#2c9da24ca98ecd520ee75276714d4df337696475",
|
||||||
"howler": "^2.0.15",
|
"howler": "^2.0.15",
|
||||||
"material-icons": "^0.2.3",
|
"material-icons": "^0.2.3",
|
||||||
"nosleep.js": "^0.7.0",
|
"nosleep.js": "^0.7.0",
|
||||||
|
@ -5,31 +5,47 @@ import { VERSION } from '@/constants';
|
|||||||
import { formatDate } from '@/tools/date';
|
import { formatDate } from '@/tools/date';
|
||||||
|
|
||||||
export default function (activityName, locationGPX) {
|
export default function (activityName, locationGPX) {
|
||||||
const courseKey = 'heading';
|
|
||||||
const eleKey = 'elevation';
|
const eleKey = 'elevation';
|
||||||
const hdopKey = 'hdop';
|
const hdopKey = 'hdop';
|
||||||
const speedKey = 'speed';
|
|
||||||
const vdopKey = 'vdop';
|
const vdopKey = 'vdop';
|
||||||
|
|
||||||
|
// Extensions
|
||||||
|
const extKey = 'extensions';
|
||||||
|
const extensionsKeys = {
|
||||||
|
heading: 'course',
|
||||||
|
speed: 'speed',
|
||||||
|
};
|
||||||
|
|
||||||
const waypoints = [];
|
const waypoints = [];
|
||||||
locationGPX.forEach((item) => {
|
locationGPX.forEach((item) => {
|
||||||
const waypoint = Object.assign({}, item, { timestamp: new Date(item.timestamp) });
|
const waypoint = Object.assign({}, item, { timestamp: new Date(item.timestamp) });
|
||||||
[courseKey, eleKey, hdopKey, speedKey, vdopKey].forEach((key) => {
|
|
||||||
|
// Omit keys with empty values
|
||||||
|
[eleKey, hdopKey, vdopKey].forEach((key) => {
|
||||||
if (waypoint[key] === null || waypoint[key] === undefined) {
|
if (waypoint[key] === null || waypoint[key] === undefined) {
|
||||||
delete waypoint[key];
|
delete waypoint[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle extensions
|
||||||
|
waypoint[extKey] = {};
|
||||||
|
Object.keys(extensionsKeys).forEach((key) => {
|
||||||
|
if (waypoint[key] !== null && waypoint[key] !== undefined) {
|
||||||
|
waypoint[extKey][extensionsKeys[key]] = waypoint[key];
|
||||||
|
delete waypoint[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
waypoints.push(waypoint);
|
waypoints.push(waypoint);
|
||||||
});
|
});
|
||||||
const gpx = createGPX(waypoints, {
|
const gpx = createGPX(waypoints, {
|
||||||
activityName,
|
activityName,
|
||||||
creator: `Cycl'Assist v${VERSION}`,
|
creator: `Cycl'Assist v${VERSION}`,
|
||||||
courseKey,
|
|
||||||
eleKey,
|
eleKey,
|
||||||
|
extKey,
|
||||||
hdopKey,
|
hdopKey,
|
||||||
latKey: 'latitude',
|
latKey: 'latitude',
|
||||||
lonKey: 'longitude',
|
lonKey: 'longitude',
|
||||||
speedKey,
|
|
||||||
startTime: waypoints[0].timestamp,
|
startTime: waypoints[0].timestamp,
|
||||||
timeKey: 'timestamp',
|
timeKey: 'timestamp',
|
||||||
vdopKey,
|
vdopKey,
|
||||||
|
@ -36,6 +36,10 @@ export function mockLocationRandom() {
|
|||||||
if (Math.random() > 0.25) {
|
if (Math.random() > 0.25) {
|
||||||
heading = Math.random() * 360;
|
heading = Math.random() * 360;
|
||||||
}
|
}
|
||||||
|
let speed = null;
|
||||||
|
if (Math.random() > 0.25) {
|
||||||
|
speed = Math.random() * 20;
|
||||||
|
}
|
||||||
const newLocation = {
|
const newLocation = {
|
||||||
coords: {
|
coords: {
|
||||||
accuracy: Math.random() * 100, // In meters
|
accuracy: Math.random() * 100, // In meters
|
||||||
@ -48,6 +52,7 @@ export function mockLocationRandom() {
|
|||||||
+ MOCK_LOCATION_LNG_MIN
|
+ MOCK_LOCATION_LNG_MIN
|
||||||
),
|
),
|
||||||
heading,
|
heading,
|
||||||
|
speed,
|
||||||
},
|
},
|
||||||
timestamp: new Date().getTime(),
|
timestamp: new Date().getTime(),
|
||||||
};
|
};
|
||||||
|
@ -3711,13 +3711,12 @@ got@^7.0.0:
|
|||||||
url-parse-lax "^1.0.0"
|
url-parse-lax "^1.0.0"
|
||||||
url-to-options "^1.0.1"
|
url-to-options "^1.0.1"
|
||||||
|
|
||||||
gps-to-gpx@^1.4.0:
|
"gps-to-gpx@git://github.com/phyks/gps-to-gpx.git#2c9da24ca98ecd520ee75276714d4df337696475":
|
||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/gps-to-gpx/-/gps-to-gpx-1.4.0.tgz#9cf4e5ae630189e0058dd01897111a55168009bc"
|
resolved "git://github.com/phyks/gps-to-gpx.git#2c9da24ca98ecd520ee75276714d4df337696475"
|
||||||
dependencies:
|
dependencies:
|
||||||
babel-runtime "6.18.0"
|
babel-runtime "6.18.0"
|
||||||
loose-envify "1.3.0"
|
loose-envify "1.3.0"
|
||||||
xmlbuilder "8.2.2"
|
|
||||||
|
|
||||||
graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
|
graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
|
||||||
version "4.1.11"
|
version "4.1.11"
|
||||||
@ -8817,10 +8816,6 @@ xml2js@^0.4.5:
|
|||||||
sax ">=0.6.0"
|
sax ">=0.6.0"
|
||||||
xmlbuilder "~9.0.1"
|
xmlbuilder "~9.0.1"
|
||||||
|
|
||||||
xmlbuilder@8.2.2:
|
|
||||||
version "8.2.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-8.2.2.tgz#69248673410b4ba42e1a6136551d2922335aa773"
|
|
||||||
|
|
||||||
xmlbuilder@~9.0.1:
|
xmlbuilder@~9.0.1:
|
||||||
version "9.0.7"
|
version "9.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
||||||
|
Loading…
Reference in New Issue
Block a user