2022-11-14 10:39:37 +00:00
|
|
|
import getUri, { intToGpxId } from '../lib/ids';
|
2022-11-07 17:20:01 +00:00
|
|
|
import { put } from './lib';
|
2022-11-07 15:38:44 +00:00
|
|
|
|
|
|
|
const emptyGpx: Gpx = {
|
|
|
|
$: {
|
|
|
|
version: '1.1',
|
|
|
|
creator: 'dyomedea version 0.000002',
|
|
|
|
xmlns: 'http://www.topografix.com/GPX/1/1',
|
|
|
|
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
|
|
'xsi:schemaLocation':
|
|
|
|
'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd',
|
|
|
|
'xmlns:gpxx': 'http://www.garmin.com/xmlschemas/GpxExtensions/v3',
|
|
|
|
'xmlns:wptx1': 'http://www.garmin.com/xmlschemas/WaypointExtension/v1',
|
|
|
|
'xmlns:gpxtpx': 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1',
|
|
|
|
'xmlns:dyo': 'http://xmlns.dyomedea.com/',
|
|
|
|
},
|
|
|
|
metadata: {
|
2022-11-08 13:16:23 +00:00
|
|
|
name: undefined,
|
|
|
|
desc: undefined,
|
|
|
|
author: undefined,
|
|
|
|
copyright: undefined,
|
|
|
|
link: undefined,
|
|
|
|
time: undefined,
|
|
|
|
keywords: undefined,
|
|
|
|
bounds: undefined,
|
|
|
|
extensions: undefined,
|
2022-11-07 15:38:44 +00:00
|
|
|
},
|
2022-11-08 13:16:23 +00:00
|
|
|
wpt: undefined,
|
|
|
|
rte: undefined,
|
|
|
|
trk: undefined,
|
|
|
|
extensions: undefined,
|
2022-11-07 15:38:44 +00:00
|
|
|
};
|
|
|
|
|
2022-11-09 09:32:06 +00:00
|
|
|
export const putNewGpx = async (
|
2022-11-14 10:39:37 +00:00
|
|
|
id: IdGpx = { gpx: intToGpxId(Date.now()) }
|
2022-11-09 09:32:06 +00:00
|
|
|
) => {
|
2022-11-07 21:12:50 +00:00
|
|
|
const uri = getUri('gpx', id);
|
2022-11-08 13:16:23 +00:00
|
|
|
await put(
|
2022-11-07 17:20:01 +00:00
|
|
|
uri,
|
|
|
|
'gpx',
|
|
|
|
(gpx) => {
|
2022-11-08 13:16:23 +00:00
|
|
|
(gpx.metadata ??= {}).time = new Date(Date.now()).toISOString();
|
2022-11-07 17:20:01 +00:00
|
|
|
return gpx;
|
|
|
|
},
|
|
|
|
emptyGpx
|
|
|
|
);
|
2022-11-07 21:12:50 +00:00
|
|
|
return id;
|
2022-11-07 15:38:44 +00:00
|
|
|
};
|