Skip to content

Commit

Permalink
fix id-scheme + add moreFields
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Nov 12, 2023
1 parent 0d550c3 commit 9132803
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 50 deletions.
3 changes: 2 additions & 1 deletion src/components/FeaturePanel/ImageSection/PoiDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const PoiType = styled.div`
span {
position: absolute;
left: 20px;
${({ isSkeleton }) => isSkeleton && 'opacity: 0.4;'}
}
`;

Expand All @@ -38,7 +39,7 @@ export const PoiDescription = () => {
: t('featurepanel.no_name');

return (
<PoiType>
<PoiType isSkeleton={feature.skeleton}>
<Maki ico={properties.class} invert middle />
<span>{poiType}</span>
</PoiType>
Expand Down
31 changes: 30 additions & 1 deletion src/services/tagging/__tests__/idTaggingScheme.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
// ]);
// });
});
2 changes: 1 addition & 1 deletion src/services/tagging/idTaggingScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =>
Expand Down
128 changes: 81 additions & 47 deletions src/services/tagging/ourPresets.ts
Original file line number Diff line number Diff line change
@@ -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': {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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: {
Expand Down
4 changes: 4 additions & 0 deletions src/services/tagging/types/Presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export type Presets = {
[presetKey: string]: Preset;
};

export type RawPresets = {
[presetKey: string]: Omit<Preset, 'presetKey'>;
};

export type FieldTranslation = {
label: string;
placeholder: string;
Expand Down

0 comments on commit 9132803

Please sign in to comment.