66 lines
1.3 KiB
TypeScript
66 lines
1.3 KiB
TypeScript
import type { OsmTagFilter, SearchPresetId } from './types';
|
|
|
|
export type SearchPreset = {
|
|
id: SearchPresetId;
|
|
label: string;
|
|
tag: OsmTagFilter;
|
|
};
|
|
|
|
export const searchPresets: SearchPreset[] = [
|
|
{
|
|
id: 'drinking_water',
|
|
label: 'Drinking water',
|
|
tag: { key: 'amenity', value: 'drinking_water' },
|
|
},
|
|
{
|
|
id: 'toilets',
|
|
label: 'Public toilets',
|
|
tag: { key: 'amenity', value: 'toilets' },
|
|
},
|
|
{
|
|
id: 'bicycle_parking',
|
|
label: 'Bicycle parking',
|
|
tag: { key: 'amenity', value: 'bicycle_parking' },
|
|
},
|
|
{
|
|
id: 'hotels',
|
|
label: 'Hotels',
|
|
tag: { key: 'tourism', value: 'hotel' },
|
|
},
|
|
{
|
|
id: 'restaurants',
|
|
label: 'Restaurants',
|
|
tag: { key: 'amenity', value: 'restaurant' },
|
|
},
|
|
{
|
|
id: 'cafes',
|
|
label: 'Cafes',
|
|
tag: { key: 'amenity', value: 'cafe' },
|
|
},
|
|
{
|
|
id: 'shops',
|
|
label: 'Shops',
|
|
tag: { key: 'shop' },
|
|
},
|
|
{
|
|
id: 'benches',
|
|
label: 'Benches',
|
|
tag: { key: 'amenity', value: 'bench' },
|
|
},
|
|
{
|
|
id: 'atms',
|
|
label: 'ATMs',
|
|
tag: { key: 'amenity', value: 'atm' },
|
|
},
|
|
];
|
|
|
|
export function getPresetById(id: SearchPresetId): SearchPreset {
|
|
const preset = searchPresets.find((item) => item.id === id);
|
|
|
|
if (!preset) {
|
|
throw new Error(`Unknown preset: ${id}`);
|
|
}
|
|
|
|
return preset;
|
|
}
|