From 2b19746bb299635ddcafa8f399db2d85b729ca78 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Mon, 7 Aug 2023 18:56:28 +0200 Subject: [PATCH] Displaying a cycle icon when GPX locomotion tag is cycling --- .vscode/settings.json | 3 ++- src/components/gpx/styles.ts | 8 ++++++-- src/components/trkseg/Trkseg.tsx | 2 ++ src/icons/bicycle-man-svgrepo-com.svg | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/icons/bicycle-man-svgrepo-com.svg diff --git a/.vscode/settings.json b/.vscode/settings.json index 35248e4..55ca310 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "docuri", "Dyomedea", "stackoverflow" - ] + ], + "workbench.colorTheme": "Default Light Modern" } \ No newline at end of file diff --git a/src/components/gpx/styles.ts b/src/components/gpx/styles.ts index b81a070..e24b0c3 100644 --- a/src/components/gpx/styles.ts +++ b/src/components/gpx/styles.ts @@ -9,6 +9,7 @@ import trainIcon from '../../icons/train-svgrepo-com.svg'; import picnicIcon from '../../icons/picnic-svgrepo-com.svg'; import caveIcon from '../../icons/cave-entrance-svgrepo-com.svg'; import hikerIcon from '../../icons/hiker-svgrepo-com.svg'; +import cycleIcon from '../../icons/bicycle-man-svgrepo-com.svg'; import blackArrowheadPointingUp from '../../icons/black-arrowhead-pointing-up-svgrepo-com.svg'; import noteIcon from '../../icons/note-svgrepo-com.svg'; import { Feature } from 'ol'; @@ -28,6 +29,7 @@ import { } from '../overlays/overlay-definitions'; import { Category } from '../wpt/WptEditDialog'; import { mustBeDrawn } from '../drawing-selector'; +import { getTagValue } from '../../lib/tags/tags'; interface StyleParameters { type: string; @@ -290,17 +292,19 @@ const styles = { getParameters: (feature: Feature) => { if (!mustBeDrawn(feature)) return null; const positions: Set = feature.get('positions'); + const tags: any = feature.get('tags') || {}; return { isLast: positions.has('gpx-end') && positions.has('trk-end'), + locomotion: getTagValue(tags, 'locomotion') || 'hiking', }; }, getStyle: memoize((params: any) => { // console.log({ caller: 'getStyle', params }); - const { isLast } = params; + const { isLast, locomotion } = params; if (isLast) { return new Style({ image: new Icon({ - src: hikerIcon, + src: locomotion === 'cycling' ? cycleIcon : hikerIcon, scale: 1 / 20, opacity: 0.9, anchor: [0.5, 0.5], diff --git a/src/components/trkseg/Trkseg.tsx b/src/components/trkseg/Trkseg.tsx index ac51680..b0809ea 100644 --- a/src/components/trkseg/Trkseg.tsx +++ b/src/components/trkseg/Trkseg.tsx @@ -118,6 +118,7 @@ export const Trkseg: Component = ({ id: trksegId, context: { ...context, trkseg, trksegId }, positions: positions(), + tags, }, id: trksegId, }, @@ -141,6 +142,7 @@ export const Trkseg: Component = ({ id: trksegId, context: { ...context, trkseg, trksegId }, positions: positions(), + tags, }, id: `${trksegId}/end`, }, diff --git a/src/icons/bicycle-man-svgrepo-com.svg b/src/icons/bicycle-man-svgrepo-com.svg new file mode 100644 index 0000000..a38ec0b --- /dev/null +++ b/src/icons/bicycle-man-svgrepo-com.svg @@ -0,0 +1,21 @@ + + + + 1102 + + + + + + + + + + + + + + + + + \ No newline at end of file