import { indexOf } from 'lodash'; import { Feature } from 'ol'; 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 legacyOverlayDefinitions = { amenity: { bar: { hiking: { drinking: true }, cycling: { drinking: true }, vanlife: { drinking: true }, }, fast_food: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, food_court: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, pub: { hiking: { eating: true, drinking: true }, cycling: { eating: true, drinking: true }, vanlife: { eating: true, drinking: true }, }, restaurant: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, cafe: { hiking: { drinking: true }, cycling: { drinking: true }, vanlife: { drinking: true }, }, atm: { hiking: { money: true, dayToDay: true }, cycling: { money: true, dayToDay: true }, vanlife: { money: true, dayToDay: true }, }, bank: { hiking: { money: true, dayToDay: true }, cycling: { money: true, dayToDay: true }, vanlife: { money: true, dayToDay: true }, }, doctors: { hiking: { health: true }, cycling: { health: true }, vanlife: { health: true }, }, hospital: { hiking: { health: true }, cycling: { health: true }, vanlife: { health: true }, }, pharmacy: { hiking: { health: true }, cycling: { health: true }, vanlife: { health: true }, }, police: { hiking: { security: true }, cycling: { security: true }, vanlife: { security: true }, }, fire_station: { hiking: { security: true }, cycling: { security: true }, vanlife: { security: true }, }, drinking_water: { hiking: { drinking: true }, cycling: { drinking: true }, vanlife: { drinking: true }, }, water_point: { hiking: { drinking: true }, cycling: { drinking: true }, vanlife: { drinking: true }, }, waste_basket: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, waste_disposal: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, vending_machine: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, bicycle_parking: { cycling: { parking: true } }, parking: { vanlife: { parking: true, sleeping: true } }, }, shop: { bakery: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, butcher: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, cheese: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, chocolate: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, convenience: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, dairy: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, farm: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, greengrocer: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, health_food: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, pasta: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, pastry: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, seafood: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, water: { hiking: { drinking: true }, cycling: { drinking: true }, vanlife: { drinking: true }, }, department_store: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, general: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, mall: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, supermarket: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, wholesale: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, outdoor: { hiking: { eating: true }, cycling: { eating: true }, vanlife: { eating: true }, }, laundry: { hiking: { dayToDay: true }, cycling: { dayToDay: true }, vanlife: { dayToDay: true }, }, }, tourism: { hotel: { hiking: { sleeping: true }, cycling: { sleeping: true } }, alpine_hut: { hiking: { sleeping: true }, cycling: { sleeping: true } }, apartment: { hiking: { sleeping: true }, cycling: { sleeping: true } }, camp_site: { hiking: { sleeping: true }, cycling: { sleeping: true }, vanlife: { sleeping: true }, }, chalet: { hiking: { sleeping: true }, cycling: { sleeping: true } }, guest_house: { hiking: { sleeping: true }, cycling: { sleeping: true } }, hostel: { hiking: { sleeping: true }, cycling: { sleeping: true } }, motel: { hiking: { sleeping: true }, cycling: { sleeping: true } }, wilderness_hut: { hiking: { sleeping: true }, cycling: { sleeping: true } }, viewpoint: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, }, waterway: { waterfall: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, }, natural: { peak: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, cave_entrance: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, volcano: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, arch: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, arete: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, fumarole: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, rock: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, saddle: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, sinkhole: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, stone: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, glacier: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, spring: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, hot_spring: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, geyser: { hiking: { naturalSites: true }, cycling: { naturalSites: true }, vanlife: { naturalSites: true }, }, }, }; let _flat: any = []; Object.values(legacyOverlayDefinitions).forEach((category) => { Object.values(category).forEach((subCategory) => { _flat = [..._flat, subCategory]; }); }); type Categories = { string: Set }; export let overlayCategories: Categories = {}; _flat.forEach((obj: any) => { Object.keys(obj).forEach((catName: string) => { const catValue = obj[catName]; const previous = overlayCategories[catName] === undefined ? [] : overlayCategories[catName]; overlayCategories[catName] = new Set([ ...previous, ...Object.keys(catValue), ]); }); }); export const getVectorTileFeatureType = (feature: Feature) => { if ( ['hiking'].includes(feature.get('route')) || ['path', 'track', 'footway', 'steps'].includes(feature.get('highway')) ) { return 'way'; } if ( Object.keys(legacyOverlayDefinitions).some((tagName) => { const tagValue = feature.get(tagName); return Object.keys(legacyOverlayDefinitions[tagName]).includes(tagValue); }) ) { return 'poi'; } }; console.log({ caller: 'overlay-definitions', legacyOverlayDefinitions, _flat, overlayCategories, });