Adding a button to force importing tracks as routes
This commit is contained in:
1 parent
856cd7637e
commit
f17cc2e073
2 files changed
+14
-6
No files matched your search
+4
-4
@@ -150,13 +150,13 @@ const hasMissingTimestamps = (trk: Trk) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const convertTrkToRteWhenNeeded = (gpx: Gpx) => {
|
||||
const convertTrkToRteWhenNeeded = (gpx: Gpx, forceImportAsRoutes: boolean) => {
|
||||
if (gpx.trk === undefined) {
|
||||
return;
|
||||
}
|
||||
const newTrks: Trk[] = [];
|
||||
for (const trk of gpx.trk) {
|
||||
if (hasMissingTimestamps(trk)) {
|
||||
if (forceImportAsRoutes || hasMissingTimestamps(trk)) {
|
||||
const rte = { ...trk, trkseg: undefined, rtept: [] };
|
||||
for (const trkseg of trk.trkseg!) {
|
||||
rte.rtept = rte.rtept.concat(trkseg.trkpt);
|
||||
@@ -174,7 +174,7 @@ const convertTrkToRteWhenNeeded = (gpx: Gpx) => {
|
||||
|
||||
export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||
console.log({ caller: 'pruneAndSaveImportedGpx', params });
|
||||
const { id, gpx, tech } = params;
|
||||
const { id, gpx, tech, forceImportAsRoutes } = params;
|
||||
let gpxId: IdGpx;
|
||||
let docs: any[] = [];
|
||||
const extensions = {
|
||||
@@ -186,7 +186,7 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||
extensions: gpx.extensions,
|
||||
},
|
||||
};
|
||||
convertTrkToRteWhenNeeded(gpx);
|
||||
convertTrkToRteWhenNeeded(gpx, forceImportAsRoutes);
|
||||
let previousGpx: Gpx | null = null;
|
||||
let to: string[];
|
||||
if (id === 'new') {
|
||||
|
||||
Reference in new issue
Block a user