dyomedea/src/components/overlays/overlay-definitions.ts

299 lines
7.6 KiB
TypeScript

import { Feature } from 'ol';
export interface OsmTag {
name: string;
value: string;
}
export const osmTags = {
bar: { name: 'amenity', value: 'bar' },
fast_food: { name: 'amenity', value: 'fast_food' },
food_court: { name: 'amenity', value: 'food_court' },
pub: { name: 'amenity', value: 'pub' },
restaurant: { name: 'amenity', value: 'restaurant' },
cafe: { name: 'amenity', value: 'cafe' },
atm: { name: 'amenity', value: 'atm' },
bank: { name: 'amenity', value: 'bank' },
doctors: { name: 'amenity', value: 'doctors' },
hospital: { name: 'amenity', value: 'hospital' },
pharmacy: { name: 'amenity', value: 'pharmacy' },
police: { name: 'amenity', value: 'police' },
fire_station: { name: 'amenity', value: 'fire_station' },
drinking_water: { name: 'amenity', value: 'drinking_water' },
water_point: { name: 'amenity', value: 'water_point' },
waste_basket: { name: 'amenity', value: 'waste_basket' },
waste_disposal: { name: 'amenity', value: 'waste_disposal' },
vending_machine: { name: 'amenity', value: 'vending_machine' },
bicycle_parking: { name: 'amenity', value: 'bicycle_parking' },
parking: { name: 'amenity', value: 'parking' },
bakery: { name: 'shop', value: 'bakery' },
butcher: { name: 'shop', value: 'butcher' },
cheese: { name: 'shop', value: 'cheese' },
chocolate: { name: 'shop', value: 'chocolate' },
convenience: { name: 'shop', value: 'convenience' },
dairy: { name: 'shop', value: 'dairy' },
farm: { name: 'shop', value: 'farm' },
greengrocer: { name: 'shop', value: 'greengrocer' },
health_food: { name: 'shop', value: 'health_food' },
pasta: { name: 'shop', value: 'pasta' },
pastry: { name: 'shop', value: 'pastry' },
seafood: { name: 'shop', value: 'seafood' },
water: { name: 'shop', value: 'water' },
department_store: { name: 'shop', value: 'department_store' },
general: { name: 'shop', value: 'general' },
mall: { name: 'shop', value: 'mall' },
supermarket: { name: 'shop', value: 'supermarket' },
wholesale: { name: 'shop', value: 'wholesale' },
outdoor: { name: 'shop', value: 'outdoor' },
laundry: { name: 'shop', value: 'laundry' },
hotel: { name: 'tourism', value: 'hotel' },
alpine_hut: { name: 'tourism', value: 'alpine_hut' },
apartment: { name: 'tourism', value: 'apartment' },
camp_site: { name: 'tourism', value: 'camp_site' },
chalet: { name: 'tourism', value: 'chalet' },
guest_house: { name: 'tourism', value: 'guest_house' },
hostel: { name: 'tourism', value: 'hostel' },
motel: { name: 'tourism', value: 'motel' },
wilderness_hut: { name: 'tourism', value: 'wilderness_hut' },
viewpoint: { name: 'tourism', value: 'viewpoint' },
waterfall: { name: 'waterway', value: 'waterfall' },
peak: { name: 'natural', value: 'peak' },
cave_entrance: { name: 'natural', value: 'cave_entrance' },
volcano: { name: 'natural', value: 'volcano' },
arch: { name: 'natural', value: 'arch' },
arete: { name: 'natural', value: 'arete' },
fumarole: { name: 'natural', value: 'fumarole' },
rock: { name: 'natural', value: 'rock' },
saddle: { name: 'natural', value: 'saddle' },
sinkhole: { name: 'natural', value: 'sinkhole' },
stone: { name: 'natural', value: 'stone' },
glacier: { name: 'natural', value: 'glacier' },
spring: { name: 'natural', value: 'spring' },
hot_spring: { name: 'natural', value: 'hot_spring' },
geyser: { name: 'natural', value: 'geyser' },
};
export const overlayDefinitions = {
hiking: {
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
eating: [
'fast_food',
'food_court',
'pub',
'restaurant',
'bakery',
'butcher',
'cheese',
'chocolate',
'convenience',
'dairy',
'farm',
'greengrocer',
'health_food',
'pasta',
'pastry',
'seafood',
'supermarket',
'wholesale',
'outdoor',
],
money: ['atm', 'bank'],
dayToDay: [
'atm',
'bank',
'waste_basket',
'waste_disposal',
'vending_machine',
'department_store',
'general',
'mall',
'laundry',
],
health: ['doctors', 'hospital', 'pharmacy'],
security: ['police', 'fire_station'],
sleeping: [
'hotel',
'alpine_hut',
'apartment',
'camp_site',
'chalet',
'guest_house',
'hostel',
'motel',
'wilderness_hut',
],
naturalSites: [
'viewpoint',
'waterfall',
'peak',
'cave_entrance',
'volcano',
'arch',
'arete',
'fumarole',
'rock',
'saddle',
'sinkhole',
'stone',
'glacier',
'spring',
'hot_spring',
'geyser',
],
},
cycling: {
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
eating: [
'fast_food',
'food_court',
'pub',
'restaurant',
'bakery',
'butcher',
'cheese',
'chocolate',
'convenience',
'dairy',
'farm',
'greengrocer',
'health_food',
'pasta',
'pastry',
'seafood',
'supermarket',
'wholesale',
'outdoor',
],
money: ['atm', 'bank'],
dayToDay: [
'atm',
'bank',
'waste_basket',
'waste_disposal',
'vending_machine',
'department_store',
'general',
'mall',
'laundry',
],
health: ['doctors', 'hospital', 'pharmacy'],
security: ['police', 'fire_station'],
parking: ['bicycle_parking'],
sleeping: [
'hotel',
'alpine_hut',
'apartment',
'camp_site',
'chalet',
'guest_house',
'hostel',
'motel',
'wilderness_hut',
],
naturalSites: [
'viewpoint',
'waterfall',
'peak',
'cave_entrance',
'volcano',
'arch',
'arete',
'fumarole',
'rock',
'saddle',
'sinkhole',
'stone',
'glacier',
'spring',
'hot_spring',
'geyser',
],
},
vanlife: {
drinking: ['bar', 'pub', 'cafe', 'drinking_water', 'water_point', 'water'],
eating: [
'fast_food',
'food_court',
'pub',
'restaurant',
'bakery',
'butcher',
'cheese',
'chocolate',
'convenience',
'dairy',
'farm',
'greengrocer',
'health_food',
'pasta',
'pastry',
'seafood',
'supermarket',
'wholesale',
'outdoor',
],
money: ['atm', 'bank'],
dayToDay: [
'atm',
'bank',
'waste_basket',
'waste_disposal',
'vending_machine',
'department_store',
'general',
'mall',
'laundry',
],
health: ['doctors', 'hospital', 'pharmacy'],
security: ['police', 'fire_station'],
parking: ['parking'],
sleeping: ['parking', 'camp_site'],
naturalSites: [
'viewpoint',
'waterfall',
'peak',
'cave_entrance',
'volcano',
'arch',
'arete',
'fumarole',
'rock',
'saddle',
'sinkhole',
'stone',
'glacier',
'spring',
'hot_spring',
'geyser',
],
},
};
export const getTagType = (feature: Feature) => {
for (const tagType of Object.keys(osmTags)) {
const tag: OsmTag = osmTags[tagType];
const tagValue = feature.get(tag.name);
if (tagValue === tag.value) {
return tagType;
}
}
return false;
};
export const getVectorTileFeatureType = (feature: Feature) => {
if (
['hiking'].includes(feature.get('route')) ||
['path', 'track', 'footway', 'steps'].includes(feature.get('highway'))
) {
return 'way';
}
if (getTagType(feature)) {
return 'poi';
}
};
console.log({
caller: 'overlay-definitions',
overlayDefinitions,
});