<Gpx> component
This commit is contained in:
1 parent
346b9a1186
commit
79fb39100f
7 files changed
+76
-22
No files matched your search
+25
-8
@@ -187,7 +187,7 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
|
||||
};
|
||||
|
||||
export const getAllGpxes = async () => {
|
||||
return await getDocsByType('gpx');
|
||||
return (await getDocsByType('gpx')).map((doc: any) => doc._id);
|
||||
};
|
||||
|
||||
export const getGpxesForViewport = async (params: any) => {
|
||||
@@ -261,13 +261,30 @@ export const getFullGpx = async (params: any) => {
|
||||
export const getGpx = async (params: any) => {
|
||||
const { id } = params;
|
||||
const docs = await getFamily(id, { include_docs: true });
|
||||
console.log(`getGpx, uri: ${id} docs: ${JSON.stringify(docs)}`);
|
||||
return docs.rows.filter(
|
||||
(row: any) =>
|
||||
row.doc.type === 'gpx' ||
|
||||
let target: any[];
|
||||
let gpx: Gpx | undefined = undefined;
|
||||
docs.rows.forEach((row: any) => {
|
||||
// level 0
|
||||
if (row.doc.type === 'gpx') {
|
||||
target = [row.doc.doc];
|
||||
gpx = row.doc.doc;
|
||||
}
|
||||
//level 1 (extensions)
|
||||
if (row.doc.type === 'extensions') {
|
||||
target.splice(1);
|
||||
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||
target.push(row.doc.doc);
|
||||
}
|
||||
//level 1 (others)
|
||||
if (
|
||||
row.doc.type === 'wpt' ||
|
||||
row.doc.type === 'rte' ||
|
||||
row.doc.type === 'trk' ||
|
||||
row.doc.type === 'extensions'
|
||||
);
|
||||
row.doc.type === 'trk'
|
||||
) {
|
||||
target.splice(1);
|
||||
appendToArray(target.at(-1), row.doc.type, row.doc._id);
|
||||
target.push(row.doc.doc);
|
||||
}
|
||||
});
|
||||
return gpx;
|
||||
};
|
||||
Reference in new issue
Block a user