Preparing a refactoring for overlay definitions

This commit is contained in:
Eric van der Vlist 2023-06-06 16:03:14 +02:00
parent 00fdc5577c
commit 7cb02012c0
5 changed files with 25 additions and 25 deletions

View File

@ -113,7 +113,7 @@ $ npx cap run --target RFCN20NEZ4R android
vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
{
caller: 'overlay-definitions',
overlayDefinitions: {
legacyOverlayDefinitions: {
amenity: {
bar: [Object],
fast_food: [Object],
@ -224,7 +224,7 @@ vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
}
}
{
overlayDefinitions: {
legacyOverlayDefinitions: {
amenity: {
bar: [Object],
fast_food: [Object],

View File

@ -1,9 +1,9 @@
import { overlayDefinitions } from './src/components/overlays/overlay-definitions';
import { legacyOverlayDefinitions } from './src/components/overlays/overlay-definitions';
let filters: any[] = ['any'];
Object.keys(overlayDefinitions).forEach((key) => {
const definition = overlayDefinitions[key];
Object.keys(legacyOverlayDefinitions).forEach((key) => {
const definition = legacyOverlayDefinitions[key];
let filter: any[] = ['in', key];
Object.keys(definition).forEach((subKey) => {
filter = [...filter, subKey];
@ -20,10 +20,10 @@ let overlays = {};
for (const category of categories) {
console.log({ caller: 'onetimer / category', category });
overlays[category] = {};
for (const tag of Object.keys(overlayDefinitions)) {
for (const tag of Object.keys(legacyOverlayDefinitions)) {
overlays[category][tag] = {};
for (const tagValue of Object.keys(overlayDefinitions[tag] || {})) {
const def = overlayDefinitions[tag][tagValue];
for (const tagValue of Object.keys(legacyOverlayDefinitions[tag] || {})) {
const def = legacyOverlayDefinitions[tag][tagValue];
if (!!def[category]) {
overlays[category][tag][tagValue] = def[category];
}
@ -39,7 +39,7 @@ console.log({
// End of one timer
console.log({
overlayDefinitions,
legacyOverlayDefinitions,
filters,
json: JSON.stringify(filters),
overlays: JSON.stringify(overlays),

View File

@ -26,7 +26,7 @@ import { Feature } from 'ol';
import {
overlayCategories,
overlayDefinitions,
legacyOverlayDefinitions,
} from '../overlays/overlay-definitions';
import { cloneDeep } from 'lodash';
@ -129,7 +129,7 @@ const defaultOverlays: Overlays = {
// type OverlayDefinition = Record<string, FeatureTypes>;
// type OverlayDefinitions = Record<string, OverlayDefinition>;
// export const overlayDefinitions: OverlayDefinitions = {
// export const legacyOverlayDefinitions: OverlayDefinitions = {
// none: {},
// hiking: {
// none: {},
@ -216,8 +216,8 @@ export const currentOverlayHighlightedDefinition = () =>
export const getAllPoiTypes = () => {
let result = new Set();
Object.keys(overlayDefinitions).forEach((tagName) => {
const tag = overlayDefinitions[tagName];
Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
const tag = legacyOverlayDefinitions[tagName];
result = new Set([...result, ...Object.keys(tag)]);
});
return [...result];
@ -225,9 +225,9 @@ export const getAllPoiTypes = () => {
export const highlightedTags = () => {
let result = {};
Object.keys(overlayDefinitions).forEach((tagName) => {
Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
let tagValues = [];
const tag = overlayDefinitions[tagName];
const tag = legacyOverlayDefinitions[tagName];
Object.keys(tag).forEach((tagValue) => {
const catDef = tag[tagValue];
Object.keys(catDef).forEach((catName) => {
@ -255,9 +255,9 @@ export const highlightedTags = () => {
// createEffect(() => {
// highlightedTags = {};
// Object.keys(overlayDefinitions).forEach((tagName) => {
// Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
// let tagValues = [];
// const tag = overlayDefinitions[tagName];
// const tag = legacyOverlayDefinitions[tagName];
// Object.keys(tag).forEach((tagValue) => {
// const catDef = tag[tagValue];
// Object.keys(catDef).forEach((catName) => {
@ -320,9 +320,9 @@ export const isHighlighted = (feature: Feature) => {
export const getTagValue = (feature: Feature) => {
let result = false;
Object.keys(overlayDefinitions).every((tagName) => {
Object.keys(legacyOverlayDefinitions).every((tagName) => {
const value = feature.get(tagName);
const tagValues = overlayDefinitions[tagName];
const tagValues = legacyOverlayDefinitions[tagName];
if (value !== undefined && Object.keys(tagValues).includes(value)) {
// console.log({

View File

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

View File

@ -1,7 +1,7 @@
import { indexOf } from 'lodash';
import { Feature } from 'ol';
export const overlayDefinitions = {
export const legacyOverlayDefinitions = {
amenity: {
bar: {
hiking: { drinking: true },
@ -300,7 +300,7 @@ export const overlayDefinitions = {
};
let _flat: any = [];
Object.values(overlayDefinitions).forEach((category) => {
Object.values(legacyOverlayDefinitions).forEach((category) => {
Object.values(category).forEach((subCategory) => {
_flat = [..._flat, subCategory];
});
@ -332,9 +332,9 @@ export const getVectorTileFeatureType = (feature: Feature) => {
return 'way';
}
if (
Object.keys(overlayDefinitions).some((tagName) => {
Object.keys(legacyOverlayDefinitions).some((tagName) => {
const tagValue = feature.get(tagName);
return Object.keys(overlayDefinitions[tagName]).includes(tagValue);
return Object.keys(legacyOverlayDefinitions[tagName]).includes(tagValue);
})
) {
return 'poi';
@ -343,7 +343,7 @@ export const getVectorTileFeatureType = (feature: Feature) => {
console.log({
caller: 'overlay-definitions',
overlayDefinitions,
legacyOverlayDefinitions,
_flat,
overlayCategories,
});