2023-01-24 09:37:03 +00:00
|
|
|
import { indexOf } from 'lodash';
|
2023-01-26 15:48:59 +00:00
|
|
|
import { Feature } from 'ol';
|
2023-01-24 09:37:03 +00:00
|
|
|
|
2023-06-06 14:03:14 +00:00
|
|
|
export const legacyOverlayDefinitions = {
|
2023-01-24 09:37:03 +00:00
|
|
|
amenity: {
|
2023-05-16 17:29:00 +00:00
|
|
|
bar: {
|
|
|
|
hiking: { drinking: true },
|
|
|
|
cycling: { drinking: true },
|
|
|
|
vanlife: { drinking: true },
|
|
|
|
},
|
2023-05-16 19:46:00 +00:00
|
|
|
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 } },
|
2023-01-24 09:37:03 +00:00
|
|
|
},
|
|
|
|
shop: {
|
2023-05-16 19:46:00 +00:00
|
|
|
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 },
|
|
|
|
},
|
2023-01-24 09:37:03 +00:00
|
|
|
},
|
|
|
|
tourism: {
|
2023-05-16 19:46:00 +00:00
|
|
|
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 },
|
|
|
|
},
|
2023-01-24 09:37:03 +00:00
|
|
|
},
|
2023-06-06 13:15:10 +00:00
|
|
|
waterway: {
|
|
|
|
waterfall: {
|
|
|
|
hiking: { naturalSites: true },
|
|
|
|
cycling: { naturalSites: true },
|
|
|
|
vanlife: { naturalSites: true },
|
|
|
|
},
|
|
|
|
},
|
2023-01-24 09:37:03 +00:00
|
|
|
natural: {
|
2023-05-16 19:46:00 +00:00
|
|
|
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 },
|
|
|
|
},
|
2023-01-24 09:37:03 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let _flat: any = [];
|
2023-06-06 14:03:14 +00:00
|
|
|
Object.values(legacyOverlayDefinitions).forEach((category) => {
|
2023-01-24 09:37:03 +00:00
|
|
|
Object.values(category).forEach((subCategory) => {
|
|
|
|
_flat = [..._flat, subCategory];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
type Categories = { string: Set<string> };
|
|
|
|
|
|
|
|
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),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-01-26 15:48:59 +00:00
|
|
|
export const getVectorTileFeatureType = (feature: Feature) => {
|
2023-01-28 18:05:39 +00:00
|
|
|
if (
|
|
|
|
['hiking'].includes(feature.get('route')) ||
|
|
|
|
['path', 'track', 'footway', 'steps'].includes(feature.get('highway'))
|
|
|
|
) {
|
2023-01-26 15:48:59 +00:00
|
|
|
return 'way';
|
|
|
|
}
|
|
|
|
if (
|
2023-06-06 14:03:14 +00:00
|
|
|
Object.keys(legacyOverlayDefinitions).some((tagName) => {
|
2023-01-26 15:48:59 +00:00
|
|
|
const tagValue = feature.get(tagName);
|
2023-06-06 14:03:14 +00:00
|
|
|
return Object.keys(legacyOverlayDefinitions[tagName]).includes(tagValue);
|
2023-01-26 15:48:59 +00:00
|
|
|
})
|
|
|
|
) {
|
|
|
|
return 'poi';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-01-24 09:37:03 +00:00
|
|
|
console.log({
|
|
|
|
caller: 'overlay-definitions',
|
2023-06-06 14:03:14 +00:00
|
|
|
legacyOverlayDefinitions,
|
2023-01-24 09:37:03 +00:00
|
|
|
_flat,
|
|
|
|
overlayCategories,
|
|
|
|
});
|