Preparing a refactoring for overlay definitions
This commit is contained in:
parent
00fdc5577c
commit
7cb02012c0
|
@ -113,7 +113,7 @@ $ npx cap run --target RFCN20NEZ4R android
|
||||||
vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
||||||
{
|
{
|
||||||
caller: 'overlay-definitions',
|
caller: 'overlay-definitions',
|
||||||
overlayDefinitions: {
|
legacyOverlayDefinitions: {
|
||||||
amenity: {
|
amenity: {
|
||||||
bar: [Object],
|
bar: [Object],
|
||||||
fast_food: [Object],
|
fast_food: [Object],
|
||||||
|
@ -224,7 +224,7 @@ vdv@nuc:~/projects/tea/dyomedea/dyomedea$ esrun helper.ts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
overlayDefinitions: {
|
legacyOverlayDefinitions: {
|
||||||
amenity: {
|
amenity: {
|
||||||
bar: [Object],
|
bar: [Object],
|
||||||
fast_food: [Object],
|
fast_food: [Object],
|
||||||
|
|
14
helper.ts
14
helper.ts
|
@ -1,9 +1,9 @@
|
||||||
import { overlayDefinitions } from './src/components/overlays/overlay-definitions';
|
import { legacyOverlayDefinitions } from './src/components/overlays/overlay-definitions';
|
||||||
|
|
||||||
let filters: any[] = ['any'];
|
let filters: any[] = ['any'];
|
||||||
|
|
||||||
Object.keys(overlayDefinitions).forEach((key) => {
|
Object.keys(legacyOverlayDefinitions).forEach((key) => {
|
||||||
const definition = overlayDefinitions[key];
|
const definition = legacyOverlayDefinitions[key];
|
||||||
let filter: any[] = ['in', key];
|
let filter: any[] = ['in', key];
|
||||||
Object.keys(definition).forEach((subKey) => {
|
Object.keys(definition).forEach((subKey) => {
|
||||||
filter = [...filter, subKey];
|
filter = [...filter, subKey];
|
||||||
|
@ -20,10 +20,10 @@ let overlays = {};
|
||||||
for (const category of categories) {
|
for (const category of categories) {
|
||||||
console.log({ caller: 'onetimer / category', category });
|
console.log({ caller: 'onetimer / category', category });
|
||||||
overlays[category] = {};
|
overlays[category] = {};
|
||||||
for (const tag of Object.keys(overlayDefinitions)) {
|
for (const tag of Object.keys(legacyOverlayDefinitions)) {
|
||||||
overlays[category][tag] = {};
|
overlays[category][tag] = {};
|
||||||
for (const tagValue of Object.keys(overlayDefinitions[tag] || {})) {
|
for (const tagValue of Object.keys(legacyOverlayDefinitions[tag] || {})) {
|
||||||
const def = overlayDefinitions[tag][tagValue];
|
const def = legacyOverlayDefinitions[tag][tagValue];
|
||||||
if (!!def[category]) {
|
if (!!def[category]) {
|
||||||
overlays[category][tag][tagValue] = def[category];
|
overlays[category][tag][tagValue] = def[category];
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ console.log({
|
||||||
// End of one timer
|
// End of one timer
|
||||||
|
|
||||||
console.log({
|
console.log({
|
||||||
overlayDefinitions,
|
legacyOverlayDefinitions,
|
||||||
filters,
|
filters,
|
||||||
json: JSON.stringify(filters),
|
json: JSON.stringify(filters),
|
||||||
overlays: JSON.stringify(overlays),
|
overlays: JSON.stringify(overlays),
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { Feature } from 'ol';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
overlayCategories,
|
overlayCategories,
|
||||||
overlayDefinitions,
|
legacyOverlayDefinitions,
|
||||||
} from '../overlays/overlay-definitions';
|
} from '../overlays/overlay-definitions';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ const defaultOverlays: Overlays = {
|
||||||
// type OverlayDefinition = Record<string, FeatureTypes>;
|
// type OverlayDefinition = Record<string, FeatureTypes>;
|
||||||
// type OverlayDefinitions = Record<string, OverlayDefinition>;
|
// type OverlayDefinitions = Record<string, OverlayDefinition>;
|
||||||
|
|
||||||
// export const overlayDefinitions: OverlayDefinitions = {
|
// export const legacyOverlayDefinitions: OverlayDefinitions = {
|
||||||
// none: {},
|
// none: {},
|
||||||
// hiking: {
|
// hiking: {
|
||||||
// none: {},
|
// none: {},
|
||||||
|
@ -216,8 +216,8 @@ export const currentOverlayHighlightedDefinition = () =>
|
||||||
|
|
||||||
export const getAllPoiTypes = () => {
|
export const getAllPoiTypes = () => {
|
||||||
let result = new Set();
|
let result = new Set();
|
||||||
Object.keys(overlayDefinitions).forEach((tagName) => {
|
Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
|
||||||
const tag = overlayDefinitions[tagName];
|
const tag = legacyOverlayDefinitions[tagName];
|
||||||
result = new Set([...result, ...Object.keys(tag)]);
|
result = new Set([...result, ...Object.keys(tag)]);
|
||||||
});
|
});
|
||||||
return [...result];
|
return [...result];
|
||||||
|
@ -225,9 +225,9 @@ export const getAllPoiTypes = () => {
|
||||||
|
|
||||||
export const highlightedTags = () => {
|
export const highlightedTags = () => {
|
||||||
let result = {};
|
let result = {};
|
||||||
Object.keys(overlayDefinitions).forEach((tagName) => {
|
Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
|
||||||
let tagValues = [];
|
let tagValues = [];
|
||||||
const tag = overlayDefinitions[tagName];
|
const tag = legacyOverlayDefinitions[tagName];
|
||||||
Object.keys(tag).forEach((tagValue) => {
|
Object.keys(tag).forEach((tagValue) => {
|
||||||
const catDef = tag[tagValue];
|
const catDef = tag[tagValue];
|
||||||
Object.keys(catDef).forEach((catName) => {
|
Object.keys(catDef).forEach((catName) => {
|
||||||
|
@ -255,9 +255,9 @@ export const highlightedTags = () => {
|
||||||
|
|
||||||
// createEffect(() => {
|
// createEffect(() => {
|
||||||
// highlightedTags = {};
|
// highlightedTags = {};
|
||||||
// Object.keys(overlayDefinitions).forEach((tagName) => {
|
// Object.keys(legacyOverlayDefinitions).forEach((tagName) => {
|
||||||
// let tagValues = [];
|
// let tagValues = [];
|
||||||
// const tag = overlayDefinitions[tagName];
|
// const tag = legacyOverlayDefinitions[tagName];
|
||||||
// Object.keys(tag).forEach((tagValue) => {
|
// Object.keys(tag).forEach((tagValue) => {
|
||||||
// const catDef = tag[tagValue];
|
// const catDef = tag[tagValue];
|
||||||
// Object.keys(catDef).forEach((catName) => {
|
// Object.keys(catDef).forEach((catName) => {
|
||||||
|
@ -320,9 +320,9 @@ export const isHighlighted = (feature: Feature) => {
|
||||||
|
|
||||||
export const getTagValue = (feature: Feature) => {
|
export const getTagValue = (feature: Feature) => {
|
||||||
let result = false;
|
let result = false;
|
||||||
Object.keys(overlayDefinitions).every((tagName) => {
|
Object.keys(legacyOverlayDefinitions).every((tagName) => {
|
||||||
const value = feature.get(tagName);
|
const value = feature.get(tagName);
|
||||||
const tagValues = overlayDefinitions[tagName];
|
const tagValues = legacyOverlayDefinitions[tagName];
|
||||||
|
|
||||||
if (value !== undefined && Object.keys(tagValues).includes(value)) {
|
if (value !== undefined && Object.keys(tagValues).includes(value)) {
|
||||||
// console.log({
|
// console.log({
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
import { overlayDefinitions, overlayCategories } from './overlay-definitions';
|
import { legacyOverlayDefinitions, overlayCategories } from './overlay-definitions';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { indexOf } from 'lodash';
|
import { indexOf } from 'lodash';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
export const overlayDefinitions = {
|
export const legacyOverlayDefinitions = {
|
||||||
amenity: {
|
amenity: {
|
||||||
bar: {
|
bar: {
|
||||||
hiking: { drinking: true },
|
hiking: { drinking: true },
|
||||||
|
@ -300,7 +300,7 @@ export const overlayDefinitions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
let _flat: any = [];
|
let _flat: any = [];
|
||||||
Object.values(overlayDefinitions).forEach((category) => {
|
Object.values(legacyOverlayDefinitions).forEach((category) => {
|
||||||
Object.values(category).forEach((subCategory) => {
|
Object.values(category).forEach((subCategory) => {
|
||||||
_flat = [..._flat, subCategory];
|
_flat = [..._flat, subCategory];
|
||||||
});
|
});
|
||||||
|
@ -332,9 +332,9 @@ export const getVectorTileFeatureType = (feature: Feature) => {
|
||||||
return 'way';
|
return 'way';
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
Object.keys(overlayDefinitions).some((tagName) => {
|
Object.keys(legacyOverlayDefinitions).some((tagName) => {
|
||||||
const tagValue = feature.get(tagName);
|
const tagValue = feature.get(tagName);
|
||||||
return Object.keys(overlayDefinitions[tagName]).includes(tagValue);
|
return Object.keys(legacyOverlayDefinitions[tagName]).includes(tagValue);
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
return 'poi';
|
return 'poi';
|
||||||
|
@ -343,7 +343,7 @@ export const getVectorTileFeatureType = (feature: Feature) => {
|
||||||
|
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'overlay-definitions',
|
caller: 'overlay-definitions',
|
||||||
overlayDefinitions,
|
legacyOverlayDefinitions,
|
||||||
_flat,
|
_flat,
|
||||||
overlayCategories,
|
overlayCategories,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue