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

View File

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

View File

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

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

@ -55,6 +55,7 @@ interface Extensions {
endTime?: string;
category?: Category;
subCategory?: SubCategory;
tags?: any;
}
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;
};