First version with a GPX export (#9) that works in a browser but, unfortunately, doesn't wotk on Adroid !
This commit is contained in:
1 parent
93054115a5
commit
cb4a257003
3 files changed
+52
-22
No files matched your search
+25
-1
@@ -3,7 +3,7 @@ import {
|
||||
string_to_bytes,
|
||||
bytes_to_base64,
|
||||
} from '@openpgp/asmcrypto.js';
|
||||
import { documentSharp } from 'ionicons/icons';
|
||||
import GPX from '../lib/gpx-parser-builder';
|
||||
|
||||
export const pushGpx = async (db: any, payload: any) => {
|
||||
const gpxString = JSON.stringify(payload.gpx);
|
||||
@@ -170,3 +170,27 @@ export const deleteCurrent = async (db: any) => {
|
||||
await deleteGps(db, docs[i]);
|
||||
}
|
||||
};
|
||||
|
||||
export const getGpx = async (db: any, gpxId: string) => {
|
||||
var gpxResult = await db.get(gpxId);
|
||||
var gpx = gpxResult.gpx;
|
||||
var trkptResults = await db.find({
|
||||
selector: {
|
||||
type: 'trkpt',
|
||||
gpx: gpx._id,
|
||||
},
|
||||
});
|
||||
var trkpts = trkptResults.docs;
|
||||
trkpts.sort((first: any, second: any) =>
|
||||
first.trkpt.time.localeCompare(second.trkpt.time)
|
||||
);
|
||||
trkpts.map((trkptDoc: any) => {
|
||||
gpx.trk[0].trkseg[0].trkpt.push(trkptDoc.trkpt);
|
||||
});
|
||||
return gpx;
|
||||
};
|
||||
|
||||
export const getGpxAsXmlString = async (db: any, gpxId: string) => {
|
||||
const gpx = new GPX(await getGpx(db, gpxId));
|
||||
return gpx.toString({});
|
||||
};
|
||||
Reference in new issue
Block a user