Displaying routes.

This commit is contained in:
vdv committed 2022-12-09 17:31:56 +01:00
1 parent f84c82bc32
commit da053dcb50
8 files changed
+173 -3

No files matched your search

+2
View File
@@ -1,6 +1,7 @@
import { getWpt } from '../db/wpt';
import { returnAgain } from '../workers/dispatcher-worker';
import { getAllGpxes, getGpx } from './gpx';
import { getRte } from './rte';
import { getTrk } from './trk';
import { getTrkseg } from './trkseg';
@@ -14,6 +15,7 @@ const methods = {
getTrk,
getTrkseg,
getWpt,
getRte,
};
const sendUpdate = async (params: any) => {
+23 -2
View File
@@ -1,6 +1,6 @@
import getUri from '../lib/ids';
import { putNewGpx } from './gpx';
import { put } from './lib';
import { appendToArray, putNewGpx } from './gpx';
import { getFamily, put } from './lib';
export const emptyRte: Rte = {
name: undefined,
@@ -31,3 +31,24 @@ export const putNewRte = async (id?: IdRte | IdGpx) => {
);
return finalId as IdRte;
};
export const getRte = async (params: any) => {
const { id } = params;
const docs = await getFamily(id, { include_docs: true });
let target: any[];
let rte: Rte | undefined = undefined;
docs.rows.forEach((row: any) => {
// level 0
if (row.doc.type === 'rte') {
target = [row.doc.doc];
rte = row.doc.doc;
}
//level 1
if (row.doc.type === 'rtept') {
target.splice(1);
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
target.push(row.doc.doc);
}
});
return rte;
};