Adding GPX tags extension

This commit is contained in:
Eric van der Vlist 2023-08-06 18:06:54 +02:00
parent a9e2855e3f
commit 2d73315a9a
5 changed files with 30 additions and 10 deletions

View File

@ -13,6 +13,7 @@ import {
createCachedSignal, createCachedSignal,
destroyCachedSignal, destroyCachedSignal,
} from '../../workers/cached-signals'; } from '../../workers/cached-signals';
import { getTagsFromObj } from '../../lib/tags/tags';
interface Props { interface Props {
gpxId: string; gpxId: string;
@ -72,6 +73,7 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
vectorSources={vectorSources} vectorSources={vectorSources}
trkId={trkId} trkId={trkId}
context={{ gpx, gpxId }} context={{ gpx, gpxId }}
tags={getTagsFromObj(gpx())}
/> />
</Suspense> </Suspense>
); );

View File

@ -1,12 +1,4 @@
import { import { Component, createEffect, For, onCleanup, Suspense } from 'solid-js';
Component,
createEffect,
For,
onCleanup,
Suspense,
} from 'solid-js';
import Trkseg from '../trkseg'; import Trkseg from '../trkseg';
import VectorSource from 'ol/source/Vector'; import VectorSource from 'ol/source/Vector';
@ -19,8 +11,14 @@ interface Props {
trkId: string; trkId: string;
vectorSources: VectorSource[]; vectorSources: VectorSource[];
context: any; context: any;
tags: any;
} }
export const Trk: Component<Props> = ({ vectorSources, trkId, context }) => { export const Trk: Component<Props> = ({
vectorSources,
trkId,
context,
tags,
}) => {
const params = { const params = {
id: trkId, id: trkId,
method: 'getTrk', method: 'getTrk',
@ -47,6 +45,7 @@ export const Trk: Component<Props> = ({ vectorSources, trkId, context }) => {
vectorSources={vectorSources} vectorSources={vectorSources}
trksegId={trksegId} trksegId={trksegId}
context={{ ...context, trk, trkId }} context={{ ...context, trk, trkId }}
tags={tags}
/> />
</Suspense> </Suspense>
); );

View File

@ -13,12 +13,14 @@ interface Props {
trksegId: string; trksegId: string;
vectorSources: VectorSource[]; vectorSources: VectorSource[];
context: any; context: any;
tags: any;
} }
export const Trkseg: Component<Props> = ({ export const Trkseg: Component<Props> = ({
vectorSources, vectorSources,
trksegId, trksegId,
context, context,
tags,
}) => { }) => {
const params = { const params = {
id: trksegId, id: trksegId,
@ -99,6 +101,7 @@ export const Trkseg: Component<Props> = ({
id: trksegId, id: trksegId,
context: { ...context, trkseg, trksegId }, context: { ...context, trkseg, trksegId },
positions: positions(), positions: positions(),
tags,
}, },
id: `${trksegId}/start`, id: `${trksegId}/start`,
}, },

1
src/db/types.d.ts vendored
View File

@ -55,6 +55,7 @@ interface Extensions {
endTime?: string; endTime?: string;
category?: Category; category?: Category;
subCategory?: SubCategory; subCategory?: SubCategory;
tags?: any;
} }
interface Trk { interface Trk {

15
src/lib/tags/tags.ts Normal file
View File

@ -0,0 +1,15 @@
export const getTagsFromObj = (obj: any) => {
if (!obj) {
return {};
}
if (!obj.extensions) {
return {};
}
if (!obj.extensions.tags) {
return {};
}
return obj.extensions.tags;
};