GpxDialog (working).

This commit is contained in:
vdv committed 2022-12-12 20:57:25 +01:00
1 parent 6da10713a0
commit daed8e5dc1
5 files changed
+29 -11

No files matched your search

+1 -1
View File
@@ -43,7 +43,7 @@ const changeHandler = async (change: any) => {
if (parentId === 'gpx') {
const gpxes = await getAllGpxes();
console.log({ caller: 'changeHandler / gpxes', gpxes, id });
if (!(id in gpxes)) {
if (!gpxes.includes(id)) {
await put(
parentId,
`idx-${parentId}`,
+16 -2
View File
@@ -1,10 +1,11 @@
import { cloneDeep } from 'lodash';
import { PureComponent } from 'react';
import { Point, Rectangle } from '../components/map/types';
import { lat2tile, lon2tile, rectanglesIntersect } from '../lib/geo';
import getUri, { intToGpxId, intToTrkptId } from '../lib/ids';
import { get, getDocsByType, getFamily, put, putAll } from './lib';
const emptyGpx: Gpx = {
export const emptyGpx: Gpx = {
$: {
version: '1.1',
creator: 'dyomedea version 0.000002',
@@ -276,6 +277,13 @@ export const getFullGpx = async (params: any) => {
export const getGpx = async (params: any) => {
const { id } = params;
if (id === 'new') {
const newGpx = cloneDeep(emptyGpx);
newGpx.metadata!.time = new Date().toISOString();
return newGpx;
}
const docs = await getFamily(id, { include_docs: true });
let target: any[];
let gpx: Gpx | undefined = undefined;
@@ -306,7 +314,13 @@ export const getGpx = async (params: any) => {
};
export const putGpx = async (params: any) => {
const { id, gpx } = params;
let { id, gpx } = params;
if (id === 'new') {
id = getUri('gpx', {
gpx: intToGpxId(new Date(gpx.metadata.time).valueOf()),
});
}
const extensions = gpx?.extensions;