Skip to content

Commit

Permalink
add some fields
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Nov 12, 2023
1 parent 1921b50 commit a13993a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 76 deletions.
10 changes: 9 additions & 1 deletion src/components/FeaturePanel/Properties/IdSchemeFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => (
<div key={key}>
Expand Down Expand Up @@ -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) =>
Expand Down
10 changes: 4 additions & 6 deletions src/services/tagging/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
9 changes: 5 additions & 4 deletions src/services/tagging/idTaggingScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
142 changes: 77 additions & 65 deletions src/services/tagging/ourPresets.ts
Original file line number Diff line number Diff line change
@@ -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;
});

0 comments on commit a13993a

Please sign in to comment.