forked from MapComplete/MapComplete
More validation and fixes
This commit is contained in:
parent
f10e7f008f
commit
4766f8bbde
13 changed files with 192 additions and 207 deletions
|
@ -1,90 +1,35 @@
|
|||
import * as drinkingWater from "../assets/layers/drinking_water/drinking_water.json";
|
||||
import * as ghostbikes from "../assets/layers/ghost_bike/ghost_bike.json"
|
||||
import * as viewpoint from "../assets/layers/viewpoint/viewpoint.json"
|
||||
import * as bike_parking from "../assets/layers/bike_parking/bike_parking.json"
|
||||
import * as bike_repair_station from "../assets/layers/bike_repair_station/bike_repair_station.json"
|
||||
import * as birdhides from "../assets/layers/bird_hide/birdhides.json"
|
||||
import * as nature_reserve from "../assets/layers/nature_reserve/nature_reserve.json"
|
||||
import * as bike_cafes from "../assets/layers/bike_cafe/bike_cafes.json"
|
||||
import * as bike_monitoring_station from "../assets/layers/bike_monitoring_station/bike_monitoring_station.json"
|
||||
import * as cycling_themed_objects from "../assets/layers/cycling_themed_object/cycling_themed_objects.json"
|
||||
import * as bike_shops from "../assets/layers/bike_shop/bike_shop.json"
|
||||
import * as bike_cleaning from "../assets/layers/bike_cleaning/bike_cleaning.json"
|
||||
import * as bicycle_library from "../assets/layers/bicycle_library/bicycle_library.json"
|
||||
import * as bicycle_tube_vending_machine from "../assets/layers/bicycle_tube_vending_machine/bicycle_tube_vending_machine.json"
|
||||
import * as maps from "../assets/layers/maps/maps.json"
|
||||
import * as information_boards from "../assets/layers/information_board/information_board.json"
|
||||
import * as direction from "../assets/layers/direction/direction.json"
|
||||
import * as surveillance_camera from "../assets/layers/surveillance_cameras/surveillance_cameras.json"
|
||||
import * as toilets from "../assets/layers/toilets/toilets.json"
|
||||
import * as bookcases from "../assets/layers/public_bookcases/public_bookcases.json"
|
||||
import * as tree_nodes from "../assets/layers/trees/tree_nodes.json"
|
||||
import * as benches from "../assets/layers/benches/benches.json"
|
||||
import * as benches_at_pt from "../assets/layers/benches/benches_at_pt.json"
|
||||
import * as picnic_tables from "../assets/layers/benches/picnic_tables.json"
|
||||
import * as play_forest from "../assets/layers/play_forest/play_forest.json"
|
||||
import * as playground from "../assets/layers/playground/playground.json"
|
||||
import * as sport_pitch from "../assets/layers/sport_pitch/sport_pitch.json"
|
||||
import * as slow_roads from "../assets/layers/slow_roads/slow_roads.json"
|
||||
import LayerConfig from "./JSON/LayerConfig";
|
||||
import {LayerConfigJson} from "./JSON/LayerConfigJson";
|
||||
import * as grass_in_parks from "../assets/layers/village_green/grass_in_parks.json"
|
||||
import * as village_green from "../assets/layers/village_green/village_green.json"
|
||||
import * as known_layers from "../assets/generated/known_layers_and_themes.json"
|
||||
import {Utils} from "../Utils";
|
||||
|
||||
export default class AllKnownLayers {
|
||||
|
||||
|
||||
private static sharedLayersListRaw : LayerConfigJson[] = [
|
||||
drinkingWater,
|
||||
ghostbikes,
|
||||
viewpoint,
|
||||
bike_parking,
|
||||
bike_repair_station,
|
||||
bike_monitoring_station,
|
||||
birdhides,
|
||||
nature_reserve,
|
||||
bike_cafes,
|
||||
bicycle_library,
|
||||
cycling_themed_objects,
|
||||
bike_shops,
|
||||
bike_cleaning,
|
||||
bicycle_tube_vending_machine,
|
||||
maps,
|
||||
direction,
|
||||
information_boards,
|
||||
toilets,
|
||||
bookcases,
|
||||
surveillance_camera,
|
||||
tree_nodes,
|
||||
benches,
|
||||
benches_at_pt,
|
||||
picnic_tables,
|
||||
play_forest,
|
||||
playground,
|
||||
sport_pitch,
|
||||
slow_roads,
|
||||
grass_in_parks,
|
||||
village_green
|
||||
];
|
||||
|
||||
// Must be below the list...
|
||||
public static sharedLayers: Map<string, LayerConfig> = AllKnownLayers.getSharedLayers();
|
||||
public static sharedLayersJson: Map<string, any> = AllKnownLayers.getSharedLayersJson();
|
||||
|
||||
private static sharedLayersListRaw: LayerConfigJson[] = known_layers.layers;
|
||||
|
||||
private static getSharedLayers(): Map<string, LayerConfig> {
|
||||
const sharedLayers = new Map<string, LayerConfig>();
|
||||
for (const layer of AllKnownLayers.sharedLayersListRaw) {
|
||||
const parsed = new LayerConfig(layer, "shared_layers")
|
||||
sharedLayers.set(layer.id, parsed);
|
||||
sharedLayers[layer.id] = parsed;
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sharedLayers;
|
||||
}
|
||||
|
||||
private static getSharedLayersJson(): Map<string, any> {
|
||||
const sharedLayers = new Map<string, any>();
|
||||
for (const layer of AllKnownLayers.sharedLayersListRaw) {
|
||||
for (const layer of known_layers.layers) {
|
||||
sharedLayers.set(layer.id, layer);
|
||||
sharedLayers[layer.id] = layer;
|
||||
}
|
||||
|
|
|
@ -1,74 +1,29 @@
|
|||
import * as bookcases from "../assets/themes/bookcases/Bookcases.json";
|
||||
import * as aed from "../assets/themes/aed/aed.json";
|
||||
import * as toilets from "../assets/themes/toilets/toilets.json";
|
||||
import * as artworks from "../assets/themes/artwork/artwork.json";
|
||||
import * as cyclestreets from "../assets/themes/cyclestreets/cyclestreets.json";
|
||||
import * as ghostbikes from "../assets/themes/ghostbikes/ghostbikes.json"
|
||||
import * as cyclofix from "../assets/themes/cyclofix/cyclofix.json"
|
||||
import * as buurtnatuur from "../assets/themes/buurtnatuur/buurtnatuur.json"
|
||||
import * as nature from "../assets/themes/nature/nature.json"
|
||||
import * as maps from "../assets/themes/maps/maps.json"
|
||||
import * as shops from "../assets/themes/shops/shops.json"
|
||||
import * as bike_monitoring_stations from "../assets/themes/bike_monitoring_station/bike_monitoring_stations.json"
|
||||
import * as fritures from "../assets/themes/fritures/fritures.json"
|
||||
import * as benches from "../assets/themes/benches/benches.json";
|
||||
import * as charging_stations from "../assets/themes/charging_stations/charging_stations.json"
|
||||
import * as widths from "../assets/themes/widths/width.json"
|
||||
import * as drinking_water from "../assets/themes/drinking_water/drinking_water.json"
|
||||
import * as climbing from "../assets/themes/climbing/climbing.json"
|
||||
import * as surveillance_cameras from "../assets/themes/surveillance_cameras/surveillance_cameras.json"
|
||||
import * as trees from "../assets/themes/trees/trees.json"
|
||||
import * as personal from "../assets/themes/personalLayout/personalLayout.json"
|
||||
import * as playgrounds from "../assets/themes/playgrounds/playgrounds.json"
|
||||
import * as bicycle_lib from "../assets/themes/bicycle_library/bicycle_library.json"
|
||||
import * as campersites from "../assets/themes/campersites/campersites.json"
|
||||
import * as play_forests from "../assets/themes/play_forests/play_forests.json"
|
||||
import * as speelplekken from "../assets/themes/speelplekken/speelplekken.json"
|
||||
import * as sport_pitches from "../assets/themes/sport_pitches/sport_pitches.json"
|
||||
import * as grb from "../assets/themes/grb.json"
|
||||
import * as facadegardens from "../assets/themes/facadegardens/facadegardens.json"
|
||||
import LayerConfig from "./JSON/LayerConfig";
|
||||
import LayoutConfig from "./JSON/LayoutConfig";
|
||||
import AllKnownLayers from "./AllKnownLayers";
|
||||
import * as known_themes from "../assets/generated/known_layers_and_themes.json"
|
||||
import {LayoutConfigJson} from "./JSON/LayoutConfigJson";
|
||||
|
||||
export class AllKnownLayouts {
|
||||
|
||||
public static allLayers: Map<string, LayerConfig> = undefined;
|
||||
public static layoutsList: LayoutConfig[] = [
|
||||
new LayoutConfig(personal),
|
||||
AllKnownLayouts.GenerateCycloFix(),
|
||||
new LayoutConfig(aed),
|
||||
new LayoutConfig(bookcases),
|
||||
new LayoutConfig(toilets),
|
||||
new LayoutConfig(artworks),
|
||||
new LayoutConfig(ghostbikes),
|
||||
new LayoutConfig(shops),
|
||||
new LayoutConfig(drinking_water),
|
||||
new LayoutConfig(nature),
|
||||
new LayoutConfig(cyclestreets),
|
||||
new LayoutConfig(bicycle_lib),
|
||||
new LayoutConfig(maps),
|
||||
new LayoutConfig(fritures),
|
||||
new LayoutConfig(benches),
|
||||
new LayoutConfig(charging_stations),
|
||||
new LayoutConfig(widths),
|
||||
new LayoutConfig(buurtnatuur),
|
||||
new LayoutConfig(bike_monitoring_stations),
|
||||
new LayoutConfig(surveillance_cameras),
|
||||
new LayoutConfig(climbing),
|
||||
new LayoutConfig(playgrounds),
|
||||
new LayoutConfig(trees),
|
||||
new LayoutConfig(campersites),
|
||||
new LayoutConfig(play_forests),
|
||||
new LayoutConfig(speelplekken),
|
||||
new LayoutConfig(sport_pitches),
|
||||
new LayoutConfig(grb),
|
||||
new LayoutConfig(facadegardens)
|
||||
];
|
||||
public static allSets: Map<string, LayoutConfig> = AllKnownLayouts.AllLayouts();
|
||||
|
||||
private static GenerateCycloFix(): LayoutConfig {
|
||||
const layout = new LayoutConfig(cyclofix)
|
||||
public static allKnownLayouts: Map<string, LayoutConfig> = AllKnownLayouts.AllLayouts();
|
||||
public static layoutsList: LayoutConfig[] = AllKnownLayouts.GenerateOrderedList(AllKnownLayouts.allKnownLayouts);
|
||||
|
||||
private static GenerateOrderedList(allKnownLayouts: Map<string, LayoutConfig>): LayoutConfig[] {
|
||||
const keys = ["personal", "cyclofix", "bookcases", "toilets", "aed"]
|
||||
const list = []
|
||||
for (const key of keys) {
|
||||
list.push(allKnownLayouts.get(key))
|
||||
}
|
||||
allKnownLayouts.forEach((layout, key) => {
|
||||
if (keys.indexOf(key) < 0) {
|
||||
list.push(layout)
|
||||
}
|
||||
})
|
||||
return list;
|
||||
}
|
||||
|
||||
private static AddGhostBikes(layout: LayoutConfig): LayoutConfig {
|
||||
const now = new Date();
|
||||
const m = now.getMonth() + 1;
|
||||
const day = new Date().getDate() + 1;
|
||||
|
@ -86,8 +41,15 @@ export class AllKnownLayouts {
|
|||
}
|
||||
|
||||
private static AllLayouts(): Map<string, LayoutConfig> {
|
||||
this.allLayers = new Map<string, LayerConfig>();
|
||||
for (const layout of this.layoutsList) {
|
||||
const dict: Map<string, LayoutConfig> = new Map();
|
||||
for (const layoutConfigJson of known_themes.themes) {
|
||||
const layout = new LayoutConfig(layoutConfigJson, true)
|
||||
|
||||
if (layout.id === "cyclofix") {
|
||||
AllKnownLayouts.AddGhostBikes(layout)
|
||||
}
|
||||
dict.set(layout.id, layout)
|
||||
|
||||
for (let i = 0; i < layout.layers.length; i++) {
|
||||
let layer = layout.layers[i];
|
||||
if (typeof (layer) === "string") {
|
||||
|
@ -98,20 +60,9 @@ export class AllKnownLayouts {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.allLayers[layer.id] !== undefined) {
|
||||
continue;
|
||||
}
|
||||
this.allLayers[layer.id] = layer;
|
||||
this.allLayers[layer.id.toLowerCase()] = layer;
|
||||
}
|
||||
}
|
||||
|
||||
const allSets: Map<string, LayoutConfig> = new Map();
|
||||
for (const layout of this.layoutsList) {
|
||||
allSets[layout.id] = layout;
|
||||
allSets[layout.id.toLowerCase()] = layout;
|
||||
}
|
||||
return allSets;
|
||||
return dict;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import {TagRenderingConfigJson} from "./TagRenderingConfigJson";
|
|||
import {Translation} from "../../UI/i18n/Translation";
|
||||
import Img from "../../UI/Base/Img";
|
||||
import Svg from "../../Svg";
|
||||
|
||||
import {Utils} from "../../Utils";
|
||||
import Combine from "../../UI/Base/Combine";
|
||||
import {VariableUiElement} from "../../UI/Base/VariableUIElement";
|
||||
|
@ -18,7 +19,6 @@ import SourceConfig from "./SourceConfig";
|
|||
import {TagsFilter} from "../../Logic/Tags/TagsFilter";
|
||||
import {Tag} from "../../Logic/Tags/Tag";
|
||||
import SubstitutingTag from "../../Logic/Tags/SubstitutingTag";
|
||||
|
||||
export default class LayerConfig {
|
||||
|
||||
|
||||
|
|
|
@ -90,6 +90,9 @@ export default class TagRenderingConfig {
|
|||
this.multiAnswer = json.multiAnswer ?? false
|
||||
if (json.mappings) {
|
||||
|
||||
if(!Array.isArray(json.mappings)){
|
||||
throw "Tagrendering has a 'mappings'-object, but expected a list ("+context+")"
|
||||
}
|
||||
|
||||
this.mappings = json.mappings.map((mapping, i) => {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue