import getUri, { intToTrkptId } from '../lib/ids'; import { put } from './lib'; import { putNewTrkseg } from './trkseg'; const emptyTrkpt: Wpt = { $: { lat: 0, lon: 0 }, ele: undefined, time: undefined, magvar: undefined, geoidheight: undefined, name: undefined, cmt: undefined, desc: undefined, src: undefined, link: undefined, sym: undefined, type: undefined, fix: undefined, sat: undefined, hdop: undefined, vdop: undefined, pdop: undefined, ageofdgpsdata: undefined, dgpsid: undefined, extensions: { 'dyo:speed': undefined, 'dyo:course': undefined, 'dyo:accuracy': undefined, 'dyo:batterylevel': undefined, 'dyo:useragent': undefined, }, }; export const putNewTrkpt = async (id?: IdTrk | IdGpx | IdTrkseg | IdTrkpt) => { let finalId = { ...id }; if (!('trkpt' in finalId)) { const trksegId = await putNewTrkseg(id); finalId = { ...trksegId, trkpt: intToTrkptId(Date.now()) }; } const uri = getUri('trkpt', finalId); await put( uri, 'trkpt', (trkpt) => { return trkpt; }, emptyTrkpt ); return finalId; };