2021-04-10 03:50:44 +02:00
|
|
|
import * as known_layers from "../assets/generated/known_layers_and_themes.json"
|
|
|
|
import {Utils} from "../Utils";
|
2021-08-07 23:11:34 +02:00
|
|
|
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
2021-11-08 02:36:01 +01:00
|
|
|
import BaseUIElement from "../UI/BaseUIElement";
|
|
|
|
import Combine from "../UI/Base/Combine";
|
|
|
|
import Title from "../UI/Base/Title";
|
|
|
|
import List from "../UI/Base/List";
|
|
|
|
import {AllKnownLayouts} from "./AllKnownLayouts";
|
|
|
|
import {isNullOrUndefined} from "util";
|
|
|
|
import {Layer} from "leaflet";
|
2020-10-27 01:01:34 +01:00
|
|
|
|
2021-02-26 17:22:24 +01:00
|
|
|
export default class AllKnownLayers {
|
2020-10-27 01:01:34 +01:00
|
|
|
|
2021-01-06 02:52:38 +01:00
|
|
|
|
|
|
|
// Must be below the list...
|
2021-02-26 17:22:24 +01:00
|
|
|
public static sharedLayers: Map<string, LayerConfig> = AllKnownLayers.getSharedLayers();
|
|
|
|
public static sharedLayersJson: Map<string, any> = AllKnownLayers.getSharedLayersJson();
|
2021-07-03 22:00:36 +02:00
|
|
|
|
2021-11-08 02:36:01 +01:00
|
|
|
|
|
|
|
public static added_by_default: string[] = ["gps_location", "home_location"]
|
|
|
|
public static no_include: string[] = [ "conflation", "left_right_style"]
|
|
|
|
/**
|
|
|
|
* Layer IDs of layers which have special properties through built-in hooks
|
|
|
|
*/
|
|
|
|
public static priviliged_layers: string[] = [...AllKnownLayers.added_by_default, "type_node",...AllKnownLayers.no_include]
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-06 02:52:38 +01:00
|
|
|
private static getSharedLayers(): Map<string, LayerConfig> {
|
2020-10-27 01:01:34 +01:00
|
|
|
const sharedLayers = new Map<string, LayerConfig>();
|
2021-04-10 03:50:44 +02:00
|
|
|
for (const layer of known_layers.layers) {
|
|
|
|
try {
|
2021-10-11 23:52:17 +02:00
|
|
|
// @ts-ignore
|
2021-09-13 01:21:47 +02:00
|
|
|
const parsed = new LayerConfig(layer, "shared_layers")
|
2021-04-10 03:50:44 +02:00
|
|
|
sharedLayers.set(layer.id, parsed);
|
|
|
|
} catch (e) {
|
|
|
|
if (!Utils.runningFromConsole) {
|
|
|
|
console.error("CRITICAL: Could not parse a layer configuration!", layer.id, " due to", e)
|
|
|
|
}
|
|
|
|
}
|
2021-01-06 02:52:38 +01:00
|
|
|
}
|
2021-05-17 00:31:10 +02:00
|
|
|
|
|
|
|
for (const layout of known_layers.themes) {
|
2021-05-17 00:18:21 +02:00
|
|
|
for (const layer of layout.layers) {
|
2021-05-17 00:31:10 +02:00
|
|
|
if (typeof layer === "string") {
|
2021-05-17 00:18:21 +02:00
|
|
|
continue;
|
|
|
|
}
|
2021-05-19 19:39:55 +02:00
|
|
|
if (layer.builtin !== undefined) {
|
2021-05-17 17:10:54 +02:00
|
|
|
// This is a builtin layer of which stuff is overridden - skip
|
|
|
|
continue;
|
|
|
|
}
|
2021-05-17 00:31:10 +02:00
|
|
|
try {
|
2021-09-13 01:21:47 +02:00
|
|
|
const parsed = new LayerConfig(layer, "shared_layer_in_theme")
|
2021-05-17 00:31:10 +02:00
|
|
|
sharedLayers.set(layer.id, parsed);
|
|
|
|
sharedLayers[layer.id] = parsed;
|
|
|
|
} catch (e) {
|
2021-05-19 19:39:55 +02:00
|
|
|
if (!Utils.runningFromConsole) {
|
|
|
|
console.error("Could not parse a layer in theme ", layout.id, "due to", e)
|
|
|
|
}
|
2021-05-17 00:31:10 +02:00
|
|
|
}
|
2021-05-17 00:18:21 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-17 00:31:10 +02:00
|
|
|
|
2021-01-06 02:52:38 +01:00
|
|
|
return sharedLayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static getSharedLayersJson(): Map<string, any> {
|
|
|
|
const sharedLayers = new Map<string, any>();
|
2021-04-10 03:50:44 +02:00
|
|
|
for (const layer of known_layers.layers) {
|
2020-10-27 01:01:34 +01:00
|
|
|
sharedLayers.set(layer.id, layer);
|
|
|
|
sharedLayers[layer.id] = layer;
|
|
|
|
}
|
|
|
|
return sharedLayers;
|
|
|
|
}
|
2021-01-06 02:52:38 +01:00
|
|
|
|
2020-12-27 14:23:45 +01:00
|
|
|
}
|