mapcomplete/Customizations/AllKnownLayers.ts

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-10-27 01:01:34 +01:00
import LayerConfig from "./JSON/LayerConfig";
2021-04-10 03:50:44 +02:00
import * as known_layers from "../assets/generated/known_layers_and_themes.json"
import {Utils} from "../Utils";
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();
2020-10-27 01:01:34 +01:00
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 {
const parsed = new LayerConfig(layer, "shared_layers")
sharedLayers.set(layer.id, parsed);
sharedLayers[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
}
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
}