This commit is contained in:
Eric van der Vlist 2023-06-09 16:59:53 +02:00
parent 64b01bd7a5
commit 861717ee18
4 changed files with 3 additions and 372 deletions

View File

@ -21,7 +21,6 @@ import { createDefaultStyle } from 'ol/style/Style';
import osmIcons from './osm-icons';
import { getZoomInteger } from '../map/Map';
import {
getHighlightedTagValue,
getTagType,
isHighlightedTagType,
} from '../map-tile-provider/MapTileProvider';

View File

@ -26,7 +26,6 @@ import { Feature } from 'ol';
import {
overlayDefinitions,
legacyOverlayDefinitions,
osmTags,
OsmTag,
} from '../overlays/overlay-definitions';
@ -156,65 +155,6 @@ const currentOverlayHighlightedKey = () =>
? currentOverlay().highlighted
: 'none';
export const highlightedTags = () => {
let result = {};
Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
let tagValues = [];
const tag = legacyOverlayDefinitions[tagName];
Object.keys(tag).forEach((tagValue) => {
const catDef = tag[tagValue];
Object.keys(catDef).forEach((catName) => {
if (catName === currentOverlayKey()) {
const catValue = catDef[catName];
if (catValue[currentOverlay()?.highlighted]) {
tagValues = [...tagValues, tagValue];
}
}
});
});
if (tagValues.length > 0) {
result[tagName] = tagValues;
}
});
// console.log({
// caller: 'MapTileProviders / highlightedTags',
// result,
// currentOverlayKey: currentOverlayKey(),
// currentOverlay: currentOverlay(),
// });
return result;
};
// createEffect(() => {
// highlightedTags = {};
// Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
// let tagValues = [];
// const tag = legacyOverlayDefinitions[tagName];
// Object.keys(tag).forEach((tagValue) => {
// const catDef = tag[tagValue];
// Object.keys(catDef).forEach((catName) => {
// if (catName === currentOverlayKey()) {
// const catValue = catDef[catName];
// if (catValue[currentOverlay()?.highlighted]) {
// tagValues = [...tagValues, tagValue];
// }
// }
// });
// });
// if (tagValues.length > 0) {
// highlightedTags[tagName] = tagValues;
// }
// });
// console.log({
// caller: 'MapTileProviders / createEffect',
// highlightedTags,
// currentOverlayKey: currentOverlayKey(),
// currentOverlay: currentOverlay(),
// });
// });
export const getTagType = (feature: Feature) => {
for (const tagType of Object.keys(osmTags)) {
const tag: OsmTag = osmTags[tagType];

View File

@ -1,6 +1 @@
import {
legacyOverlayDefinitions,
overlayDefinitions,
OsmTag,
osmTags,
} from './overlay-definitions';
import { overlayDefinitions, OsmTag, osmTags } from './overlay-definitions';

View File

@ -1,5 +1,6 @@
import { indexOf } from 'lodash';
import { Feature } from 'ol';
import { getTagType } from '../map-tile-provider/MapTileProvider';
export interface OsmTag {
name: string;
@ -270,304 +271,6 @@ export const overlayDefinitions = {
},
};
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 },
},
},
};
export const getVectorTileFeatureType = (feature: Feature) => {
if (
['hiking'].includes(feature.get('route')) ||
@ -575,18 +278,12 @@ export const getVectorTileFeatureType = (feature: Feature) => {
) {
return 'way';
}
if (
Object.keys(legacyOverlayDefinitions).some((tagName) => {
const tagValue = feature.get(tagName);
return Object.keys(legacyOverlayDefinitions[tagName]).includes(tagValue);
})
) {
if (getTagType(feature)) {
return 'poi';
}
};
console.log({
caller: 'overlay-definitions',
legacyOverlayDefinitions,
overlayDefinitions,
});