From 353b0774b68cfbc6dc8550a4b1d10899e1ff8713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Thu, 5 Oct 2023 20:14:32 +0200 Subject: [PATCH 01/14] services: add climbing presets --- src/services/tagging/data.ts | 66 +++++++++++++++++++++++++++- src/services/tagging/translations.ts | 20 +++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/services/tagging/data.ts b/src/services/tagging/data.ts index 52e0fad7d..1b9e6d6fa 100644 --- a/src/services/tagging/data.ts +++ b/src/services/tagging/data.ts @@ -4,14 +4,76 @@ import { Fields } from './types/Fields'; import { Presets } from './types/Presets'; import { publishDbgObject } from '../../utils'; + +const ourPresets = { // i want only sport=climbing without gyms: leisure=sport_center + 'leisure/climbing/site': { + icon: 'temaki-abseiling', + geometry: ['point', 'way', 'area'], + fields: [], + tags: { + sport: 'climbing' + }, + reference: { + key: 'sport', + value: 'climbing', + }, + name: 'Climbing site', // could be both gym or + }, + 'leisure/climbing/route': { + icon: 'temaki-abseiling', + geometry: ['point', 'way'], + fields: [], + tags: { + climbing: 'route', + }, + addTags: { + sport: 'climbing', + climbing: 'route', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Climbing route', + }, + 'leisure/climbing/route_bottom': { + icon: 'temaki-abseiling', + geometry: ['point'], + fields: [], + tags: { + climbing: 'route_bottom', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Bottom of climbing route', + }, + 'leisure/climbing/route_top': { + icon: 'temaki-abseiling', + geometry: ['point'], + fields: [], + tags: { + climbing: 'route_top', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Top of climbing route', + }, +} as Presets; + + export const fields = fieldsJson as unknown as Fields; Object.keys(fieldsJson).forEach((fieldKey) => { fields[fieldKey].fieldKey = fieldKey; }); -export const presets = presetsJson as unknown as Presets; -Object.keys(presetsJson).forEach((presetKey) => { +const upstreamPresets = presetsJson as unknown as Presets; +export const presets = { ...upstreamPresets, ...ourPresets }; +Object.keys(presets).forEach((presetKey) => { presets[presetKey].presetKey = presetKey; }); diff --git a/src/services/tagging/translations.ts b/src/services/tagging/translations.ts index 628952611..c46b0f8af 100644 --- a/src/services/tagging/translations.ts +++ b/src/services/tagging/translations.ts @@ -19,6 +19,26 @@ export const fetchSchemaTranslations = async () => { translations = await fetchJson( `${cdnUrl}@${version}/dist/translations/${intl.lang}.min.json`, ); + + + translations[intl.lang].presets.presets['leisure/climbing/site'] = { + name: 'Climbing site', + terms: 'Místo k lezení' + } + translations[intl.lang].presets.presets['leisure/climbing/route'] = { + name: 'Climbing route', + terms: 'lezecká cesta' + } + translations[intl.lang].presets.presets['leisure/climbing/route_bottom'] = { + name: 'Bottom of climbing route', + terms: 'začátek lezecké cesty' + } + translations[intl.lang].presets.presets['leisure/climbing/route_top'] = { + name: 'Top of climbing route', + terms: 'top lezecké cesty' + } + + publishDbgObject('schemaTranslations', translations); }; From 6b38234072e54a05fb45061bacc982d478341613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Wed, 8 Nov 2023 19:09:52 +0100 Subject: [PATCH 02/14] refactor --- src/services/tagging/data.ts | 62 +------------------- src/services/tagging/ourPresets.ts | 86 ++++++++++++++++++++++++++++ src/services/tagging/translations.ts | 21 +------ 3 files changed, 90 insertions(+), 79 deletions(-) create mode 100644 src/services/tagging/ourPresets.ts diff --git a/src/services/tagging/data.ts b/src/services/tagging/data.ts index 1b9e6d6fa..2933eeca6 100644 --- a/src/services/tagging/data.ts +++ b/src/services/tagging/data.ts @@ -3,67 +3,7 @@ import presetsJson from '@openstreetmap/id-tagging-schema/dist/presets.json'; import { Fields } from './types/Fields'; import { Presets } from './types/Presets'; import { publishDbgObject } from '../../utils'; - - -const ourPresets = { // i want only sport=climbing without gyms: leisure=sport_center - 'leisure/climbing/site': { - icon: 'temaki-abseiling', - geometry: ['point', 'way', 'area'], - fields: [], - tags: { - sport: 'climbing' - }, - reference: { - key: 'sport', - value: 'climbing', - }, - name: 'Climbing site', // could be both gym or - }, - 'leisure/climbing/route': { - icon: 'temaki-abseiling', - geometry: ['point', 'way'], - fields: [], - tags: { - climbing: 'route', - }, - addTags: { - sport: 'climbing', - climbing: 'route', - }, - reference: { - key: 'climbing', - value: 'route', - }, - name: 'Climbing route', - }, - 'leisure/climbing/route_bottom': { - icon: 'temaki-abseiling', - geometry: ['point'], - fields: [], - tags: { - climbing: 'route_bottom', - }, - reference: { - key: 'climbing', - value: 'route', - }, - name: 'Bottom of climbing route', - }, - 'leisure/climbing/route_top': { - icon: 'temaki-abseiling', - geometry: ['point'], - fields: [], - tags: { - climbing: 'route_top', - }, - reference: { - key: 'climbing', - value: 'route', - }, - name: 'Top of climbing route', - }, -} as Presets; - +import { ourPresets } from './ourPresets'; export const fields = fieldsJson as unknown as Fields; diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts new file mode 100644 index 000000000..c83837be6 --- /dev/null +++ b/src/services/tagging/ourPresets.ts @@ -0,0 +1,86 @@ +import { Presets } from './types/Presets'; + +export const getOurTranslations = (lang) => ({ + [lang]: { + presets: { + presets: { + 'leisure/climbing/site': { + name: 'Climbing site', + terms: 'Místo k lezení', + }, + 'leisure/climbing/route': { + name: 'Climbing route', + terms: 'lezecká cesta', + }, + 'leisure/climbing/route_bottom': { + name: 'Start of climbing route', + terms: 'začátek lezecké cesty', + }, + 'leisure/climbing/route_top': { + name: 'Top of climbing route', + terms: 'top lezecké cesty', + }, + }, + }, + }, +}); + +export const ourPresets = { + // i want only sport=climbing without gyms: leisure=sport_center + 'leisure/climbing/site': { + icon: 'temaki-abseiling', + geometry: ['point', 'way', 'area'], + fields: [], + tags: { + sport: 'climbing', + }, + reference: { + key: 'sport', + value: 'climbing', + }, + name: 'Climbing site', // could be both gym or + }, + 'leisure/climbing/route': { + icon: 'temaki-abseiling', + geometry: ['point', 'way'], + fields: [], + tags: { + climbing: 'route', + }, + addTags: { + sport: 'climbing', + climbing: 'route', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Climbing route', + }, + 'leisure/climbing/route_bottom': { + icon: 'temaki-abseiling', + geometry: ['point'], + fields: [], + tags: { + climbing: 'route_bottom', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Bottom of climbing route', + }, + 'leisure/climbing/route_top': { + icon: 'temaki-abseiling', + geometry: ['point'], + fields: [], + tags: { + climbing: 'route_top', + }, + reference: { + key: 'climbing', + value: 'route', + }, + name: 'Top of climbing route', + }, +} as unknown as Presets; diff --git a/src/services/tagging/translations.ts b/src/services/tagging/translations.ts index c46b0f8af..249d36e3c 100644 --- a/src/services/tagging/translations.ts +++ b/src/services/tagging/translations.ts @@ -1,8 +1,10 @@ +import { merge } from 'lodash'; import { fetchJson } from '../fetch'; import { Field } from './types/Fields'; import { intl } from '../intl'; import { publishDbgObject } from '../../utils'; import { FieldTranslation } from './types/Presets'; +import { getOurTranslations } from './ourPresets'; // https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@6.1.0/dist/translations/en.min.json const cdnUrl = `https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema`; @@ -20,24 +22,7 @@ export const fetchSchemaTranslations = async () => { `${cdnUrl}@${version}/dist/translations/${intl.lang}.min.json`, ); - - translations[intl.lang].presets.presets['leisure/climbing/site'] = { - name: 'Climbing site', - terms: 'Místo k lezení' - } - translations[intl.lang].presets.presets['leisure/climbing/route'] = { - name: 'Climbing route', - terms: 'lezecká cesta' - } - translations[intl.lang].presets.presets['leisure/climbing/route_bottom'] = { - name: 'Bottom of climbing route', - terms: 'začátek lezecké cesty' - } - translations[intl.lang].presets.presets['leisure/climbing/route_top'] = { - name: 'Top of climbing route', - terms: 'top lezecké cesty' - } - + merge(translations, getOurTranslations(intl.lang)); publishDbgObject('schemaTranslations', translations); }; From 0e3497ddc7ed8264a98aad25d468bda8612c07f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Sun, 12 Nov 2023 11:21:08 +0100 Subject: [PATCH 03/14] add some fields --- .../Properties/IdSchemeFields.tsx | 10 +- src/services/tagging/data.ts | 10 +- src/services/tagging/idTaggingScheme.ts | 9 +- src/services/tagging/ourPresets.ts | 142 ++++++++++-------- 4 files changed, 95 insertions(+), 76 deletions(-) diff --git a/src/components/FeaturePanel/Properties/IdSchemeFields.tsx b/src/components/FeaturePanel/Properties/IdSchemeFields.tsx index d03ca6a0d..daf2ba465 100644 --- a/src/components/FeaturePanel/Properties/IdSchemeFields.tsx +++ b/src/components/FeaturePanel/Properties/IdSchemeFields.tsx @@ -31,6 +31,12 @@ const render = (uiField: UiField, feature: Feature): string | ReactNode => { return renderValue('wikidata', feature.tags.wikidata); } + // combo with options + if (fieldTranslation?.options?.[v]) { + return renderValue(k, fieldTranslation.options[v]?.title); + } + + // multicombo ? if (fieldTranslation?.types && fieldTranslation?.options) { return tagsForField.map(({ key, value: value2 }) => (
@@ -72,7 +78,9 @@ const removeUnits = (label) => label.replace(unitRegExp, ''); const addUnits = (label, value: string | ReactNode) => { if (typeof value !== 'string') return value; const unit = label.match(unitRegExp); - return `${value}${unit ? ` (${unit[1]})` : ''}`; + if (!unit) return value; + if (unit[1] === 'm') return `${value} m`; + return `${value} (${unit[1]})`; }; const getTooltip = (field: Field, key: string) => diff --git a/src/services/tagging/data.ts b/src/services/tagging/data.ts index 2933eeca6..e223d26e2 100644 --- a/src/services/tagging/data.ts +++ b/src/services/tagging/data.ts @@ -3,16 +3,14 @@ import presetsJson from '@openstreetmap/id-tagging-schema/dist/presets.json'; import { Fields } from './types/Fields'; import { Presets } from './types/Presets'; import { publishDbgObject } from '../../utils'; -import { ourPresets } from './ourPresets'; +import { ourFields, ourPresets } from './ourPresets'; -export const fields = fieldsJson as unknown as Fields; - -Object.keys(fieldsJson).forEach((fieldKey) => { +export const fields = { ...fieldsJson, ...ourFields } as unknown as Fields; +Object.keys(fields).forEach((fieldKey) => { fields[fieldKey].fieldKey = fieldKey; }); -const upstreamPresets = presetsJson as unknown as Presets; -export const presets = { ...upstreamPresets, ...ourPresets }; +export const presets = { ...presetsJson, ...ourPresets } as unknown as Presets; Object.keys(presets).forEach((presetKey) => { presets[presetKey].presetKey = presetKey; }); diff --git a/src/services/tagging/idTaggingScheme.ts b/src/services/tagging/idTaggingScheme.ts index 625a4aba4..481aaf4a3 100644 --- a/src/services/tagging/idTaggingScheme.ts +++ b/src/services/tagging/idTaggingScheme.ts @@ -27,10 +27,11 @@ const getUiField = ( feature: Feature, key: string, ): UiField => { - if (field.type === 'typeCombo') { - keysTodo.remove(field.key); // ignores eg. railway=tram_stop on public_transport=stop_position - return undefined; - } + // TODO this should be removed now the parsing works ok + // if (field.type === 'typeCombo') { + // keysTodo.remove(field.key); // ignores eg. railway=tram_stop on public_transport=stop_position + // return undefined; + // } const value = feature.tags[key]; diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index c83837be6..f41ca04d7 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -1,86 +1,98 @@ import { Presets } from './types/Presets'; -export const getOurTranslations = (lang) => ({ - [lang]: { - presets: { - presets: { - 'leisure/climbing/site': { - name: 'Climbing site', - terms: 'Místo k lezení', - }, - 'leisure/climbing/route': { - name: 'Climbing route', - terms: 'lezecká cesta', - }, - 'leisure/climbing/route_bottom': { - name: 'Start of climbing route', - terms: 'začátek lezecké cesty', - }, - 'leisure/climbing/route_top': { - name: 'Top of climbing route', - terms: 'top lezecké cesty', - }, - }, - }, - }, -}); - export const ourPresets = { - // i want only sport=climbing without gyms: leisure=sport_center - 'leisure/climbing/site': { + 'leisure/climbing/crag_2': { icon: 'temaki-abseiling', - geometry: ['point', 'way', 'area'], - fields: [], - tags: { - sport: 'climbing', - }, - reference: { - key: 'sport', - value: 'climbing', - }, - name: 'Climbing site', // could be both gym or + fields: ['climbing/rock', 'climbing/orientation', 'climbing/routes'], + geometry: ['point', 'relation'], + tags: { climbing: 'crag' }, + name: 'Climbing crag', }, + 'leisure/climbing/route': { icon: 'temaki-abseiling', - geometry: ['point', 'way'], fields: [], - tags: { - climbing: 'route', - }, - addTags: { - sport: 'climbing', - climbing: 'route', - }, - reference: { - key: 'climbing', - value: 'route', - }, + geometry: ['point', 'way'], + tags: { climbing: 'route' }, name: 'Climbing route', }, 'leisure/climbing/route_bottom': { icon: 'temaki-abseiling', + fields: ['climbing/length', 'climbing/bolts'], geometry: ['point'], - fields: [], - tags: { - climbing: 'route_bottom', - }, - reference: { - key: 'climbing', - value: 'route', - }, - name: 'Bottom of climbing route', + tags: { climbing: 'route_bottom' }, + name: 'Climbing route - start', }, 'leisure/climbing/route_top': { icon: 'temaki-abseiling', + fields: [], geometry: ['point'], + tags: { climbing: 'route_top' }, + name: 'Climbing route - top', + }, + + 'leisure/climbing/site': { + icon: 'temaki-abseiling', fields: [], - tags: { - climbing: 'route_top', + geometry: ['point', 'way', 'area'], + tags: { sport: 'climbing' }, // we need only sport=climbing without gyms: leisure=sport_center, is it possible? + name: 'Climbing site', + // matchScore: 0.9, + }, +} as unknown as Presets; + +export const ourFields = { + 'climbing/length': { + key: 'climbing:length', + type: 'number', + minValue: 0, + label: 'Length (m)', + }, + 'climbing/bolts': { + key: 'climbing:bolts', + type: 'number', + minValue: 0, + label: 'Bolts', + }, + 'climbing/rock': { + key: 'climbing:rock', + type: 'combo', + label: 'Rock type', + }, + 'climbing/orientation': { + key: 'climbing:orientation', + type: 'combo', + options: { + N: 'North', + NE: 'North-East', + E: 'East', + SE: 'South-East', + S: 'South', + SW: 'South-West', + W: 'West', + NW: 'North-West', }, - reference: { - key: 'climbing', - value: 'route', + label: 'Orientation', + }, + // 'climbing/urls': { + // keys: ['climbing:url:mountainproject', 'climbing:url:openbeta', 'climbing:url:thecrag'], + // type: 'url', + // label: 'Websites', + // } + + 'climbing/routes': { + key: 'climbing:routes', + type: 'number', + minValue: 0, + label: 'Number of routes', + }, +}; + +export const getOurTranslations = (lang) => ({ + [lang]: { + presets: { + presets: ourPresets, + fields: ourFields, }, - name: 'Top of climbing route', }, -} as unknown as Presets; +}); From f105299127c819e518450ae5c7a64c0416bc2b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Sun, 12 Nov 2023 11:46:05 +0100 Subject: [PATCH 04/14] fix tests --- src/services/tagging/idTaggingScheme.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/tagging/idTaggingScheme.ts b/src/services/tagging/idTaggingScheme.ts index 481aaf4a3..c44878c44 100644 --- a/src/services/tagging/idTaggingScheme.ts +++ b/src/services/tagging/idTaggingScheme.ts @@ -27,11 +27,11 @@ const getUiField = ( feature: Feature, key: string, ): UiField => { - // TODO this should be removed now the parsing works ok - // if (field.type === 'typeCombo') { - // keysTodo.remove(field.key); // ignores eg. railway=tram_stop on public_transport=stop_position - // return undefined; - // } + // TODO this should be removed now the parsing works ok (+run tests) + if (field.type === 'typeCombo') { + keysTodo.remove(field.key); // ignores eg. railway=tram_stop on public_transport=stop_position + return undefined; + } const value = feature.tags[key]; From 8f8d17a82151d255797edf9d366e2ceb933bbac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Sun, 12 Nov 2023 12:47:10 +0100 Subject: [PATCH 05/14] fix id-scheme + add moreFields --- .../ImageSection/PoiDescription.tsx | 3 +- .../tagging/__tests__/idTaggingScheme.test.ts | 31 ++++- src/services/tagging/idTaggingScheme.ts | 2 +- src/services/tagging/ourPresets.ts | 128 +++++++++++------- src/services/tagging/types/Presets.ts | 4 + 5 files changed, 118 insertions(+), 50 deletions(-) diff --git a/src/components/FeaturePanel/ImageSection/PoiDescription.tsx b/src/components/FeaturePanel/ImageSection/PoiDescription.tsx index 48ff68087..a9b63abf2 100644 --- a/src/components/FeaturePanel/ImageSection/PoiDescription.tsx +++ b/src/components/FeaturePanel/ImageSection/PoiDescription.tsx @@ -19,6 +19,7 @@ const PoiType = styled.div` span { position: absolute; left: 20px; + ${({ isSkeleton }) => isSkeleton && 'opacity: 0.4;'} } `; @@ -31,7 +32,7 @@ export const PoiDescription = () => { : t('featurepanel.no_name'); return ( - + {poiType} diff --git a/src/services/tagging/__tests__/idTaggingScheme.test.ts b/src/services/tagging/__tests__/idTaggingScheme.test.ts index 235f9d20c..9fee35629 100644 --- a/src/services/tagging/__tests__/idTaggingScheme.test.ts +++ b/src/services/tagging/__tests__/idTaggingScheme.test.ts @@ -43,12 +43,15 @@ describe('idTaggingScheme', () => { expect(result.label).toBe('Motorway'); expect(result.presetKey).toBe('highway/motorway'); - expect(result.matchedFields).toMatchObject([ + expect( + result.matchedFields.map(({ label, value }) => ({ label, value })), + ).toMatchObject([ { label: 'Road Number', value: 'I 84' }, { label: 'One Way', value: 'Yes' }, { label: 'Speed Limit', value: '55 mph' }, { label: 'Lanes', value: '2' }, { label: 'Surface', value: 'Asphalt' }, + { label: 'Structure', value: undefined }, { label: 'Allowed Access', value: 'Foot: Prohibited,\nBicycles: Prohibited,\nHorses: Prohibited', @@ -167,4 +170,30 @@ describe('idTaggingScheme', () => { 'source', ]); }); + // + // + // it('xxxsxhouafdld remove from keysTodo if address is in restTags', () => { + // // TOOD find better tags which have some multikey field in tagsWithFields + // const feature = { + // osmMeta: { + // type: 'way', + // id: 149398903, + // }, + // tags: { + // "climbing": "route", + // "climbing:boulder": "yes", + // "climbing:grade:uiaa": "7+", + // "description": "Hard boulder problem", + // "sport": "climbing" + // } + // , + // } as unknown as Feature; + // + // const schema = getSchemaForFeature(feature); + // + // expect(schema.presetKey).toEqual('leisure/climbing/route'); + // expect(schema.tagsWithFields.map((x: any) => x.field.fieldKey)).toEqual([ + // 'source', + // ]); + // }); }); diff --git a/src/services/tagging/idTaggingScheme.ts b/src/services/tagging/idTaggingScheme.ts index c44878c44..4cd71d83a 100644 --- a/src/services/tagging/idTaggingScheme.ts +++ b/src/services/tagging/idTaggingScheme.ts @@ -80,7 +80,7 @@ const matchFieldsFromPreset = ( return getUiField(field, keysTodo, feature, key); }) - .filter((field) => field?.value); + .filter(Boolean); }; const matchRestToFields = (keysTodo: KeysTodo, feature: Feature): UiField[] => diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index f41ca04d7..de6124245 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -1,45 +1,4 @@ -import { Presets } from './types/Presets'; - -export const ourPresets = { - 'leisure/climbing/crag_2': { - icon: 'temaki-abseiling', - fields: ['climbing/rock', 'climbing/orientation', 'climbing/routes'], - geometry: ['point', 'relation'], - tags: { climbing: 'crag' }, - name: 'Climbing crag', - }, - - 'leisure/climbing/route': { - icon: 'temaki-abseiling', - fields: [], - geometry: ['point', 'way'], - tags: { climbing: 'route' }, - name: 'Climbing route', - }, - 'leisure/climbing/route_bottom': { - icon: 'temaki-abseiling', - fields: ['climbing/length', 'climbing/bolts'], - geometry: ['point'], - tags: { climbing: 'route_bottom' }, - name: 'Climbing route - start', - }, - 'leisure/climbing/route_top': { - icon: 'temaki-abseiling', - fields: [], - geometry: ['point'], - tags: { climbing: 'route_top' }, - name: 'Climbing route - top', - }, - - 'leisure/climbing/site': { - icon: 'temaki-abseiling', - fields: [], - geometry: ['point', 'way', 'area'], - tags: { sport: 'climbing' }, // we need only sport=climbing without gyms: leisure=sport_center, is it possible? - name: 'Climbing site', - // matchScore: 0.9, - }, -} as unknown as Presets; +import { RawPresets } from './types/Presets'; export const ourFields = { 'climbing/length': { @@ -59,6 +18,21 @@ export const ourFields = { type: 'combo', label: 'Rock type', }, + + 'climbing/grade': { + keys: [ + 'climbing:grade:uiaa', // plus :min :max :mean variants ??? + 'climbing:grade:french', + 'climbing:grade:saxon', + 'climbing:grade:aid', + 'climbing:grade:hueco', + 'climbing:grade:yds_class', + 'climbing:grade:ice', + ], + type: 'text', + label: 'Grade', + }, + 'climbing/orientation': { key: 'climbing:orientation', type: 'combo', @@ -74,11 +48,15 @@ export const ourFields = { }, label: 'Orientation', }, - // 'climbing/urls': { - // keys: ['climbing:url:mountainproject', 'climbing:url:openbeta', 'climbing:url:thecrag'], - // type: 'url', - // label: 'Websites', - // } + 'climbing/urls': { + keys: [ + 'climbing:url:mountainproject', + 'climbing:url:openbeta', + 'climbing:url:thecrag', + ], + type: 'url', + label: 'Websites', + }, 'climbing/routes': { key: 'climbing:routes', @@ -88,6 +66,62 @@ export const ourFields = { }, }; +export const ourPresets = { + 'leisure/climbing/crag_2': { + icon: 'temaki-abseiling', + fields: ['climbing/rock', 'climbing/orientation', 'climbing/routes'], + moreFields: Object.keys(ourFields), + geometry: ['point', 'relation'], + tags: { climbing: 'crag' }, + name: 'Climbing crag', + }, + + 'leisure/climbing/route': { + icon: 'temaki-abseiling', + fields: [ + 'climbing/grade', + 'climbing/length', + 'climbing/bolts', + 'climbing/orientation', + ], + moreFields: Object.keys(ourFields), + geometry: ['point', 'line'], + tags: { climbing: 'route' }, + name: 'Climbing route', + }, + 'leisure/climbing/route_bottom': { + icon: 'temaki-abseiling', + fields: [ + 'climbing/grade', + 'climbing/length', + 'climbing/bolts', + 'climbing/orientation', + ], + moreFields: Object.keys(ourFields), + geometry: ['point'], + tags: { climbing: 'route_bottom' }, + name: 'Climbing route - start', + }, + 'leisure/climbing/route_top': { + icon: 'temaki-abseiling', + fields: [], + moreFields: Object.keys(ourFields), + geometry: ['point'], + tags: { climbing: 'route_top' }, + name: 'Climbing route - top', + }, + + 'leisure/climbing/site': { + icon: 'temaki-abseiling', + fields: [], + moreFields: Object.keys(ourFields), + geometry: ['point', 'line', 'area'], + tags: { sport: 'climbing' }, // we need only sport=climbing without gyms: leisure=sport_center, is it possible? + name: 'Climbing site', + matchScore: 0.9, + }, +} as RawPresets; + export const getOurTranslations = (lang) => ({ [lang]: { presets: { diff --git a/src/services/tagging/types/Presets.ts b/src/services/tagging/types/Presets.ts index 0141d8fb3..de16db514 100644 --- a/src/services/tagging/types/Presets.ts +++ b/src/services/tagging/types/Presets.ts @@ -98,6 +98,10 @@ export type Presets = { [presetKey: string]: Preset; }; +export type RawPresets = { + [presetKey: string]: Omit; +}; + export type FieldTranslation = { label: string; placeholder: string; From 23da46084ac3e6094702e121377928e876df5c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Tue, 30 Jan 2024 13:14:44 +0100 Subject: [PATCH 06/14] add current presets from id-tagging-scheme dist --- src/services/tagging/ourPresets.ts | 201 ++++++++++++++++------------- 1 file changed, 113 insertions(+), 88 deletions(-) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index de6124245..a6fff881e 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -1,132 +1,157 @@ import { RawPresets } from './types/Presets'; export const ourFields = { - 'climbing/length': { - key: 'climbing:length', - type: 'number', - minValue: 0, - label: 'Length (m)', + 'climbing/summit_log': { + key: 'climbing:summit_log', + type: 'check', }, - 'climbing/bolts': { - key: 'climbing:bolts', + 'climbing/routes': { + key: 'climbing:routes', type: 'number', minValue: 0, - label: 'Bolts', }, 'climbing/rock': { key: 'climbing:rock', type: 'combo', - label: 'Rock type', + options: ['limestone', 'sandstone', 'granite', 'basalt'], }, - - 'climbing/grade': { - keys: [ - 'climbing:grade:uiaa', // plus :min :max :mean variants ??? - 'climbing:grade:french', - 'climbing:grade:saxon', - 'climbing:grade:aid', - 'climbing:grade:hueco', - 'climbing:grade:yds_class', - 'climbing:grade:ice', - ], - type: 'text', - label: 'Grade', + 'climbing/quality': { + key: 'climbing:quality', + type: 'combo', + options: ['fragile', 'medium', 'solid'], }, - 'climbing/orientation': { key: 'climbing:orientation', type: 'combo', - options: { - N: 'North', - NE: 'North-East', - E: 'East', - SE: 'South-East', - S: 'South', - SW: 'South-West', - W: 'West', - NW: 'North-West', - }, - label: 'Orientation', + options: ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'], }, - 'climbing/urls': { - keys: [ - 'climbing:url:mountainproject', - 'climbing:url:openbeta', - 'climbing:url:thecrag', - ], - type: 'url', - label: 'Websites', + 'climbing/length': { + key: 'climbing:length', + type: 'number', + minValue: 0, }, - - 'climbing/routes': { - key: 'climbing:routes', + 'climbing/grade': { + key: 'climbing:grade:uiaa', + type: 'text', + }, + 'climbing/bolts': { + key: 'climbing:bolts', type: 'number', minValue: 0, - label: 'Number of routes', + }, + 'climbing/bolted': { + key: 'climbing:bolted', + type: 'check', + }, + 'climbing/bolt_type': { + key: 'climbing:bolt_type', + type: 'combo', + options: ['expansion', 'glue-in', 'ring'], }, }; export const ourPresets = { - 'leisure/climbing/crag_2': { - icon: 'temaki-abseiling', - fields: ['climbing/rock', 'climbing/orientation', 'climbing/routes'], - moreFields: Object.keys(ourFields), - geometry: ['point', 'relation'], - tags: { climbing: 'crag' }, - name: 'Climbing crag', - }, - - 'leisure/climbing/route': { + 'climbing/route': { icon: 'temaki-abseiling', + geometry: ['point', 'line'], fields: [ 'climbing/grade', - 'climbing/length', 'climbing/bolts', + 'climbing/bolt_type', + 'climbing/bolted', + 'climbing/length', 'climbing/orientation', + 'climbing/quality', + 'climbing/rock', + 'climbing/summit_log', + 'website', ], - moreFields: Object.keys(ourFields), - geometry: ['point', 'line'], - tags: { climbing: 'route' }, - name: 'Climbing route', + moreFields: ['ele'], + tags: { + climbing: 'route', + }, }, - 'leisure/climbing/route_bottom': { + 'climbing/crag': { icon: 'temaki-abseiling', + geometry: ['point', 'line'], fields: [ - 'climbing/grade', + 'climbing/routes', + 'climbing/bolt_type', + 'climbing/bolted', 'climbing/length', - 'climbing/bolts', 'climbing/orientation', + 'climbing/quality', + 'climbing/rock', + 'website', ], - moreFields: Object.keys(ourFields), - geometry: ['point'], - tags: { climbing: 'route_bottom' }, - name: 'Climbing route - start', - }, - 'leisure/climbing/route_top': { - icon: 'temaki-abseiling', - fields: [], - moreFields: Object.keys(ourFields), - geometry: ['point'], - tags: { climbing: 'route_top' }, - name: 'Climbing route - top', - }, - - 'leisure/climbing/site': { - icon: 'temaki-abseiling', - fields: [], - moreFields: Object.keys(ourFields), - geometry: ['point', 'line', 'area'], - tags: { sport: 'climbing' }, // we need only sport=climbing without gyms: leisure=sport_center, is it possible? - name: 'Climbing site', - matchScore: 0.9, + moreFields: ['ele'], + tags: { + climbing: 'crag', + }, }, } as RawPresets; export const getOurTranslations = (lang) => ({ [lang]: { presets: { - presets: ourPresets, - fields: ourFields, + presets: { + 'climbing/route': { + name: 'Climbing route', + terms: 'rock climbing,climbing', + }, + 'climbing/crag': { + name: 'Climbing crag', + terms: 'rock climbing,climbing', + }, + }, + fields: { + 'climbing/summit_log': { + label: 'Summit log', + }, + 'climbing/routes': { + label: 'Number of routes', + }, + 'climbing/rock': { + label: 'Rock type', + }, + 'climbing/quality': { + label: 'Rock quality', + }, + 'climbing/orientation': { + label: 'Orientation', + options: { + N: 'North', + NE: 'North-East', + E: 'East', + SE: 'South-East', + S: 'South', + SW: 'South-West', + W: 'West', + NW: 'North-West', + }, + }, + 'climbing/length': { + label: 'Length (m)', + }, + 'climbing/grade': { + label: 'Grade', + placeholder: '6+', + }, + 'climbing/bolts': { + label: 'Number of bolts', + }, + 'climbing/bolted': { + label: 'Bolted', + }, + 'climbing/bolt_type': { + label: 'Bolt type', + options: { + expansion: 'expansion bolt', + 'glue-in': 'glue-in bolt', + ring: 'ring bolt', + }, + }, + }, }, }, }); From bfb0d2b617b7b6de087b5bc14b56d4ef8f0ccc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Tue, 30 Jan 2024 13:22:55 +0100 Subject: [PATCH 07/14] add route_bottom --- src/services/tagging/ourPresets.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index a6fff881e..440835cf8 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -51,6 +51,15 @@ export const ourFields = { }; export const ourPresets = { + 'climbing/route_bottom': { + icon: 'temaki-abseiling', + geometry: ['point'], + fields: ['{climbing/route}'], + moreFields: ['{climbing/route}'], + tags: { + climbing: 'route_bottom', + }, + }, 'climbing/route': { icon: 'temaki-abseiling', geometry: ['point', 'line'], @@ -95,6 +104,10 @@ export const getOurTranslations = (lang) => ({ [lang]: { presets: { presets: { + 'climbing/route_bottom': { + name: 'Climbing route - bottom', + terms: 'rock climbing,climbing', + }, 'climbing/route': { name: 'Climbing route', terms: 'rock climbing,climbing', From 363c4428bb59a8fc9603740a0648262a61cd0b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Tue, 30 Jan 2024 13:30:58 +0100 Subject: [PATCH 08/14] crag is relation --- src/services/tagging/ourPresets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index 440835cf8..ade72cced 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -82,7 +82,7 @@ export const ourPresets = { }, 'climbing/crag': { icon: 'temaki-abseiling', - geometry: ['point', 'line'], + geometry: ['point', 'relation'], fields: [ 'climbing/routes', 'climbing/bolt_type', From 28587274385db110b6f8a7e6bfb1ea4c2e8df07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Thu, 8 Feb 2024 10:43:48 +0100 Subject: [PATCH 09/14] brackets --- src/services/tagging/ourPresets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index ade72cced..03aaee2d6 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -105,7 +105,7 @@ export const getOurTranslations = (lang) => ({ presets: { presets: { 'climbing/route_bottom': { - name: 'Climbing route - bottom', + name: 'Climbing route (start)', terms: 'rock climbing,climbing', }, 'climbing/route': { From 315c27959a9f73da1ef5209811a337fe37ed1cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Thu, 8 Feb 2024 11:03:13 +0100 Subject: [PATCH 10/14] poi class --- src/services/getPoiClass.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/services/getPoiClass.ts b/src/services/getPoiClass.ts index 9ba0c8de7..06f0e7aee 100644 --- a/src/services/getPoiClass.ts +++ b/src/services/getPoiClass.ts @@ -23,6 +23,7 @@ const keys = [ 'power', 'natural', 'route', // relation route=bicycle etc + 'climbing', ]; const shops = [ @@ -90,7 +91,7 @@ const shops = [ // https://github.com/openmaptiles/openmaptiles/blob/bb00b4e53fa9dbf5778b394c910c629182c441f9/layers/poi/class.sql#L33 // TODO get from here https://github.com/openmaptiles/openmaptiles/blob/1614a46/layers/poi/poi.yaml#L18 -const subclassToClassRules = [ +const rules = [ { subclass: shops, resultClass: 'shop', @@ -272,6 +273,10 @@ const subclassToClassRules = [ subclass: 'memorial', resultClass: 'art_gallery', }, + // { + // mappingKey: 'climbing', + // resultClass: 'climbing', + // } ]; interface PoiClass { @@ -284,7 +289,7 @@ export const getPoiClass = (tags): PoiClass => { const value = tags[key]; // its value // find first matching rule - const resultRule = subclassToClassRules.find( + const resultRule = rules.find( (rule) => (!rule.mappingKey && rule.subclass.includes(value)) || (rule.mappingKey === key && !rule.subclass) || From 7c19960688fd0f3ded7a4f3f6e12ebcd424f77b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Thu, 8 Feb 2024 16:31:51 +0100 Subject: [PATCH 11/14] bolt type --- src/services/tagging/ourPresets.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index 03aaee2d6..c493d221c 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -43,8 +43,8 @@ export const ourFields = { key: 'climbing:bolted', type: 'check', }, - 'climbing/bolt_type': { - key: 'climbing:bolt_type', + 'climbing/bolt': { + key: 'climbing:bolt', type: 'combo', options: ['expansion', 'glue-in', 'ring'], }, @@ -66,7 +66,7 @@ export const ourPresets = { fields: [ 'climbing/grade', 'climbing/bolts', - 'climbing/bolt_type', + 'climbing/bolt', 'climbing/bolted', 'climbing/length', 'climbing/orientation', @@ -85,7 +85,7 @@ export const ourPresets = { geometry: ['point', 'relation'], fields: [ 'climbing/routes', - 'climbing/bolt_type', + 'climbing/bolt', 'climbing/bolted', 'climbing/length', 'climbing/orientation', @@ -156,7 +156,7 @@ export const getOurTranslations = (lang) => ({ 'climbing/bolted': { label: 'Bolted', }, - 'climbing/bolt_type': { + 'climbing/bolt': { label: 'Bolt type', options: { expansion: 'expansion bolt', From 32acbcb4cc9e29412a8e05adcd3e2728c576f41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Sat, 10 Feb 2024 08:07:23 +0100 Subject: [PATCH 12/14] current schema from PR --- src/services/tagging/ourPresets.ts | 54 +++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index c493d221c..a2df80be7 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -30,10 +30,6 @@ export const ourFields = { type: 'number', minValue: 0, }, - 'climbing/grade': { - key: 'climbing:grade:uiaa', - type: 'text', - }, 'climbing/bolts': { key: 'climbing:bolts', type: 'number', @@ -48,6 +44,18 @@ export const ourFields = { type: 'combo', options: ['expansion', 'glue-in', 'ring'], }, + 'climbing/grade/uiaa': { + key: 'climbing:grade:uiaa', + type: 'text', + }, + 'climbing/grade/saxon': { + key: 'climbing:grade:saxon', + type: 'text', + }, + 'climbing/grade/french': { + key: 'climbing:grade:french', + type: 'text', + }, }; export const ourPresets = { @@ -64,18 +72,23 @@ export const ourPresets = { icon: 'temaki-abseiling', geometry: ['point', 'line'], fields: [ - 'climbing/grade', + 'name', + 'climbing/length', + 'climbing/grade/uiaa', + 'climbing/grade/french', + 'climbing/grade/saxon', + ], + moreFields: [ 'climbing/bolts', - 'climbing/bolt', 'climbing/bolted', - 'climbing/length', + 'climbing/bolt', 'climbing/orientation', 'climbing/quality', 'climbing/rock', 'climbing/summit_log', 'website', + 'ele', ], - moreFields: ['ele'], tags: { climbing: 'route', }, @@ -83,17 +96,18 @@ export const ourPresets = { 'climbing/crag': { icon: 'temaki-abseiling', geometry: ['point', 'relation'], - fields: [ + fields: ['name'], + moreFields: [ + 'climbing/length', 'climbing/routes', - 'climbing/bolt', 'climbing/bolted', - 'climbing/length', + 'climbing/bolt', 'climbing/orientation', 'climbing/quality', 'climbing/rock', 'website', + 'ele', ], - moreFields: ['ele'], tags: { climbing: 'crag', }, @@ -146,10 +160,6 @@ export const getOurTranslations = (lang) => ({ 'climbing/length': { label: 'Length (m)', }, - 'climbing/grade': { - label: 'Grade', - placeholder: '6+', - }, 'climbing/bolts': { label: 'Number of bolts', }, @@ -164,6 +174,18 @@ export const getOurTranslations = (lang) => ({ ring: 'ring bolt', }, }, + 'climbing/grade/uiaa': { + label: 'Grade (UIAA)', + placeholder: '6-', + }, + 'climbing/grade/saxon': { + label: 'Grade (saxon)', + placeholder: 'VIIa', + }, + 'climbing/grade/french': { + label: 'Grade (french)', + placeholder: '5c', + }, }, }, }, From 55b9ac33446af53d72edf35c1cc07e2733302d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Mon, 12 Feb 2024 15:48:52 +0100 Subject: [PATCH 13/14] update to current PR --- src/services/tagging/ourPresets.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/services/tagging/ourPresets.ts b/src/services/tagging/ourPresets.ts index a2df80be7..14c53576c 100644 --- a/src/services/tagging/ourPresets.ts +++ b/src/services/tagging/ourPresets.ts @@ -67,6 +67,10 @@ export const ourPresets = { tags: { climbing: 'route_bottom', }, + addTags: { + sport: 'climbing', + climbing: 'route_bottom', + }, }, 'climbing/route': { icon: 'temaki-abseiling', @@ -92,6 +96,10 @@ export const ourPresets = { tags: { climbing: 'route', }, + addTags: { + sport: 'climbing', + climbing: 'route', + }, }, 'climbing/crag': { icon: 'temaki-abseiling', @@ -111,6 +119,10 @@ export const ourPresets = { tags: { climbing: 'crag', }, + addTags: { + sport: 'climbing', + climbing: 'crag', + }, }, } as RawPresets; From 1ac7cff0b16115778dd2a33bcb53203b089b065d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Zbytovsk=C3=BD?= Date: Mon, 12 Feb 2024 15:51:40 +0100 Subject: [PATCH 14/14] remove comment --- .../tagging/__tests__/idTaggingScheme.test.ts | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/services/tagging/__tests__/idTaggingScheme.test.ts b/src/services/tagging/__tests__/idTaggingScheme.test.ts index 9fee35629..aa51c2cea 100644 --- a/src/services/tagging/__tests__/idTaggingScheme.test.ts +++ b/src/services/tagging/__tests__/idTaggingScheme.test.ts @@ -170,30 +170,4 @@ describe('idTaggingScheme', () => { 'source', ]); }); - // - // - // it('xxxsxhouafdld remove from keysTodo if address is in restTags', () => { - // // TOOD find better tags which have some multikey field in tagsWithFields - // const feature = { - // osmMeta: { - // type: 'way', - // id: 149398903, - // }, - // tags: { - // "climbing": "route", - // "climbing:boulder": "yes", - // "climbing:grade:uiaa": "7+", - // "description": "Hard boulder problem", - // "sport": "climbing" - // } - // , - // } as unknown as Feature; - // - // const schema = getSchemaForFeature(feature); - // - // expect(schema.presetKey).toEqual('leisure/climbing/route'); - // expect(schema.tagsWithFields.map((x: any) => x.field.fieldKey)).toEqual([ - // 'source', - // ]); - // }); });