From 2bead588fbe3e7dc79c19d969132851a7602e801 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 4 Dec 2021 12:20:24 +0100 Subject: [PATCH 1/4] Do not show quickswitch if background map switching is disabled --- Logic/State/FeatureSwitchState.ts | 4 ++-- UI/BigComponents/FilterView.ts | 2 +- UI/BigComponents/LeftControls.ts | 9 ++++++++- UI/DefaultGuiState.ts | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Logic/State/FeatureSwitchState.ts b/Logic/State/FeatureSwitchState.ts index 32aca82949..6dc25429b2 100644 --- a/Logic/State/FeatureSwitchState.ts +++ b/Logic/State/FeatureSwitchState.ts @@ -16,7 +16,7 @@ export default class FeatureSwitchState { public readonly featureSwitchUserbadge: UIEventSource; public readonly featureSwitchSearch: UIEventSource; - public readonly featureSwitchBackgroundSlection: UIEventSource; + public readonly featureSwitchBackgroundSelection: UIEventSource; public readonly featureSwitchAddNew: UIEventSource; public readonly featureSwitchWelcomeMessage: UIEventSource; public readonly featureSwitchIframePopoutEnabled: UIEventSource; @@ -72,7 +72,7 @@ export default class FeatureSwitchState { (layoutToUse) => layoutToUse?.enableSearch ?? true, "Disables/Enables the search bar" ); - this.featureSwitchBackgroundSlection = featSw( + this.featureSwitchBackgroundSelection = featSw( "fs-background", (layoutToUse) => layoutToUse?.enableBackgroundLayerSelection ?? true, "Disables/Enables the background layer control" diff --git a/UI/BigComponents/FilterView.ts b/UI/BigComponents/FilterView.ts index 3bbfccb905..8842897145 100644 --- a/UI/BigComponents/FilterView.ts +++ b/UI/BigComponents/FilterView.ts @@ -20,7 +20,7 @@ export default class FilterView extends VariableUiElement { const backgroundSelector = new Toggle( new BackgroundSelector(), undefined, - State.state.featureSwitchBackgroundSlection + State.state.featureSwitchBackgroundSelection ) super( filteredLayer.map((filteredLayers) => { diff --git a/UI/BigComponents/LeftControls.ts b/UI/BigComponents/LeftControls.ts index ef367abaac..0082f60c70 100644 --- a/UI/BigComponents/LeftControls.ts +++ b/UI/BigComponents/LeftControls.ts @@ -19,6 +19,7 @@ import BackgroundMapSwitch from "./BackgroundMapSwitch"; export default class LeftControls extends Combine { constructor(state: { + featureSwitchBackgroundSelection: UIEventSource; layoutToUse: LayoutConfig, featurePipeline: FeaturePipeline, currentBounds: UIEventSource, @@ -74,10 +75,16 @@ export default class LeftControls extends Combine { undefined, state.featureSwitchFilter ); + + const mapSwitch = new Toggle( + new BackgroundMapSwitch(state, state.backgroundLayer), + undefined, + state.featureSwitchBackgroundSelection + ) super([filterButton, downloadButtonn, - new BackgroundMapSwitch(state, state.backgroundLayer) + mapSwitch ]) this.SetClass("flex flex-col") diff --git a/UI/DefaultGuiState.ts b/UI/DefaultGuiState.ts index 537eb4b70b..1df1891db9 100644 --- a/UI/DefaultGuiState.ts +++ b/UI/DefaultGuiState.ts @@ -18,7 +18,7 @@ export class DefaultGuiState { this.welcomeMessageOpenedTab = UIEventSource.asFloat(QueryParameters.GetQueryParameter( "tab", "0", - `The tab that is shown in the welcome-message. 0 = the explanation of the theme,1 = OSM-credits, 2 = sharescreen, 3 = more themes, 4 = about mapcomplete (user must be logged in and have >${Constants.userJourney.mapCompleteHelpUnlock} changesets)` + `The tab that is shown in the welcome-message.` )); this.welcomeMessageIsOpened = QueryParameters.GetBooleanQueryParameter( "welcome-control-toggle", From df453821c8fc8f1e3244d6a000edd2b0675ae092 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 4 Dec 2021 21:44:18 +0100 Subject: [PATCH 2/4] Generate an overview of all layers --- Customizations/AllKnownLayouts.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index 4d0c394428..ba59b0b04b 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -39,15 +39,23 @@ export class AllKnownLayouts { throw "Priviliged layer definition not found: " + id } } + const allLayers: LayerConfig[] = Array.from(AllKnownLayers.sharedLayers.values()) + .filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0) + + const builtinLayerIds: Set = new Set() + allLayers.forEach(l => builtinLayerIds.add(l.id)) const themesPerLayer = new Map() for (const layout of Array.from(AllKnownLayouts.allKnownLayouts.values())) { - if(layout.hideFromOverview){ + if (layout.hideFromOverview) { continue } for (const layer of layout.layers) { + if (!builtinLayerIds.has(layer.id)) { + continue + } if (!themesPerLayer.has(layer.id)) { themesPerLayer.set(layer.id, []) } @@ -57,8 +65,9 @@ export class AllKnownLayouts { let popularLayerCutoff = 2; - const popupalLayers = allLayers.filter((layer) => themesPerLayer.get(layer.id)?.length >= 2) - .filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0) + const popuparLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length >= 2) + + const unpopularLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length < 2) return new Combine([ new Title("Special and other useful layers", 1), @@ -68,10 +77,15 @@ export class AllKnownLayouts { ...AllKnownLayers.priviliged_layers .map(id => AllKnownLayers.sharedLayers.get(id)) .map((l) => l.GenerateDocumentation(themesPerLayer.get(l.id), AllKnownLayers.added_by_default.indexOf(l.id) >= 0, AllKnownLayers.no_include.indexOf(l.id) < 0)), - new Title("Frequently reused layers", 1), - "The following layers are used by at least "+popularLayerCutoff+" mapcomplete themes and might be interesting for your custom theme too", - new List(popupalLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")), - ...popupalLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id))) + new Title("Normal layers", 1), + "The following layers are included in MapComplete", + new Title("Frequently reused layers", 2), + "The following layers are used by at least " + popularLayerCutoff + " mapcomplete themes and might be interesting for your custom theme too", + new List(popuparLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")), + ...popuparLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id))), + new List(unpopularLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")), + ...unpopularLayers.map(layer => layer.GenerateDocumentation(themesPerLayer.get(layer.id)) + ) ]) From 2dc6d4658f2754605b1e16bf7f35fae2233e1dcb Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 4 Dec 2021 21:44:32 +0100 Subject: [PATCH 3/4] Add documentation on all layers --- Docs/BuiltinLayers.md | 1445 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1443 insertions(+), 2 deletions(-) diff --git a/Docs/BuiltinLayers.md b/Docs/BuiltinLayers.md index 7ce567ec04..770e9fc1a5 100644 --- a/Docs/BuiltinLayers.md +++ b/Docs/BuiltinLayers.md @@ -14,7 +14,9 @@ + [type_node](#type_node) + [conflation](#conflation) + [left_right_style](#left_right_style) -1. [Frequently reused layers](#frequently-reused-layers) + + [split_point](#split_point) +1. [Normal layers](#normal-layers) + - [Frequently reused layers](#frequently-reused-layers) + [bicycle_library](#bicycle_library) * [Themes using this layer](#themes-using-this-layer) + [drinking_water](#drinking_water) @@ -25,6 +27,114 @@ * [Themes using this layer](#themes-using-this-layer) + [all_streets](#all_streets) * [Themes using this layer](#themes-using-this-layer) + + [ambulancestation](#ambulancestation) + * [Themes using this layer](#themes-using-this-layer) + + [artwork](#artwork) + * [Themes using this layer](#themes-using-this-layer) + + [barrier](#barrier) + * [Themes using this layer](#themes-using-this-layer) + + [bench](#bench) + * [Themes using this layer](#themes-using-this-layer) + + [bench_at_pt](#bench_at_pt) + * [Themes using this layer](#themes-using-this-layer) + + [bicycle_tube_vending_machine](#bicycle_tube_vending_machine) + * [Themes using this layer](#themes-using-this-layer) + + [bike_cafe](#bike_cafe) + * [Themes using this layer](#themes-using-this-layer) + + [bike_cleaning](#bike_cleaning) + * [Themes using this layer](#themes-using-this-layer) + + [bike_parking](#bike_parking) + * [Themes using this layer](#themes-using-this-layer) + + [bike_repair_station](#bike_repair_station) + * [Themes using this layer](#themes-using-this-layer) + + [bike_shop](#bike_shop) + * [Themes using this layer](#themes-using-this-layer) + + [bike_themed_object](#bike_themed_object) + * [Themes using this layer](#themes-using-this-layer) + + [binocular](#binocular) + * [Themes using this layer](#themes-using-this-layer) + + [birdhide](#birdhide) + * [Themes using this layer](#themes-using-this-layer) + + [cafe_pub](#cafe_pub) + * [Themes using this layer](#themes-using-this-layer) + + [charging_station](#charging_station) + * [Themes using this layer](#themes-using-this-layer) + + [crossings](#crossings) + * [Themes using this layer](#themes-using-this-layer) + + [cycleways_and_roads](#cycleways_and_roads) + * [Themes using this layer](#themes-using-this-layer) + + [defibrillator](#defibrillator) + * [Themes using this layer](#themes-using-this-layer) + + [direction](#direction) + * [Themes using this layer](#themes-using-this-layer) + + [etymology](#etymology) + * [Themes using this layer](#themes-using-this-layer) + + [extinguisher](#extinguisher) + * [Themes using this layer](#themes-using-this-layer) + + [fire_station](#fire_station) + * [Themes using this layer](#themes-using-this-layer) + + [ghost_bike](#ghost_bike) + * [Themes using this layer](#themes-using-this-layer) + + [hydrant](#hydrant) + * [Themes using this layer](#themes-using-this-layer) + + [information_board](#information_board) + * [Themes using this layer](#themes-using-this-layer) + + [nature_reserve](#nature_reserve) + * [Themes using this layer](#themes-using-this-layer) + + [observation_tower](#observation_tower) + * [Themes using this layer](#themes-using-this-layer) + + [parking](#parking) + * [Themes using this layer](#themes-using-this-layer) + + [picnic_table](#picnic_table) + * [Themes using this layer](#themes-using-this-layer) + + [playground](#playground) + * [Themes using this layer](#themes-using-this-layer) + + [public_bookcase](#public_bookcase) + * [Themes using this layer](#themes-using-this-layer) + + [shops](#shops) + * [Themes using this layer](#themes-using-this-layer) + + [sport_pitch](#sport_pitch) + * [Themes using this layer](#themes-using-this-layer) + + [street_lamps](#street_lamps) + * [Themes using this layer](#themes-using-this-layer) + + [surveillance_camera](#surveillance_camera) + * [Themes using this layer](#themes-using-this-layer) + + [toilet](#toilet) + * [Themes using this layer](#themes-using-this-layer) + + [tree_node](#tree_node) + * [Themes using this layer](#themes-using-this-layer) + + [waste_basket](#waste_basket) + * [Themes using this layer](#themes-using-this-layer) + + [caravansites](#caravansites) + * [Themes using this layer](#themes-using-this-layer) + + [dumpstations](#dumpstations) + * [Themes using this layer](#themes-using-this-layer) + + [climbing_club](#climbing_club) + * [Themes using this layer](#themes-using-this-layer) + + [climbing_gym](#climbing_gym) + * [Themes using this layer](#themes-using-this-layer) + + [climbing_route](#climbing_route) + * [Themes using this layer](#themes-using-this-layer) + + [climbing](#climbing) + * [Themes using this layer](#themes-using-this-layer) + + [maybe_climbing](#maybe_climbing) + * [Themes using this layer](#themes-using-this-layer) + + [fietsstraat](#fietsstraat) + * [Themes using this layer](#themes-using-this-layer) + + [toekomstige_fietsstraat](#toekomstige_fietsstraat) + * [Themes using this layer](#themes-using-this-layer) + + [facadegardens](#facadegardens) + * [Themes using this layer](#themes-using-this-layer) + + [hackerspaces](#hackerspaces) + * [Themes using this layer](#themes-using-this-layer) + + [windturbine](#windturbine) + * [Themes using this layer](#themes-using-this-layer) + + [postboxes](#postboxes) + * [Themes using this layer](#themes-using-this-layer) + + [postoffices](#postoffices) + * [Themes using this layer](#themes-using-this-layer) + + [lit_streets](#lit_streets) + * [Themes using this layer](#themes-using-this-layer) MapComplete has a few data layers available in the theme which have special properties through builtin-hooks. Furthermore, there are some normal layers (which are built from normal Theme-config files) but are so general that they get a mention here. @@ -40,6 +150,7 @@ - [type_node](#type_node) - [conflation](#conflation) - [left_right_style](#left_right_style) + - [split_point](#split_point) ### gps_location @@ -141,8 +252,26 @@ Special meta-style which will show one single line, either on the left or on the - This layer can **not** be included in a theme. It is solely used by [special renderings](SpecialRenderings.md) showing a minimap with custom data. +### split_point + + + +Layer rendering the little scissors for the minimap in the 'splitRoadWizard' + +[Go to the source code](../assets/layers/split_point/split_point.json) + + + + - This layer can **not** be included in a theme. It is solely used by [special renderings](SpecialRenderings.md) showing a minimap with custom data. + + + Normal layers +=============== + + The following layers are included in MapComplete + Frequently reused layers -========================== +-------------------------- The following layers are used by at least 2 mapcomplete themes and might be interesting for your custom theme too @@ -273,4 +402,1316 @@ A map, meant for tourists which is permanently installed in the public space - [street_lighting](https://mapcomplete.osm.be/street_lighting) + - [ambulancestation](#ambulancestation) + - [artwork](#artwork) + - [barrier](#barrier) + - [bench](#bench) + - [bench_at_pt](#bench_at_pt) + - [bicycle_tube_vending_machine](#bicycle_tube_vending_machine) + - [bike_cafe](#bike_cafe) + - [bike_cleaning](#bike_cleaning) + - [bike_parking](#bike_parking) + - [bike_repair_station](#bike_repair_station) + - [bike_shop](#bike_shop) + - [bike_themed_object](#bike_themed_object) + - [binocular](#binocular) + - [birdhide](#birdhide) + - [cafe_pub](#cafe_pub) + - [charging_station](#charging_station) + - [crossings](#crossings) + - [cycleways_and_roads](#cycleways_and_roads) + - [defibrillator](#defibrillator) + - [direction](#direction) + - [etymology](#etymology) + - [extinguisher](#extinguisher) + - [fire_station](#fire_station) + - [ghost_bike](#ghost_bike) + - [hydrant](#hydrant) + - [information_board](#information_board) + - [nature_reserve](#nature_reserve) + - [observation_tower](#observation_tower) + - [parking](#parking) + - [picnic_table](#picnic_table) + - [playground](#playground) + - [public_bookcase](#public_bookcase) + - [shops](#shops) + - [sport_pitch](#sport_pitch) + - [street_lamps](#street_lamps) + - [surveillance_camera](#surveillance_camera) + - [toilet](#toilet) + - [tree_node](#tree_node) + - [waste_basket](#waste_basket) + - [caravansites](#caravansites) + - [dumpstations](#dumpstations) + - [climbing_club](#climbing_club) + - [climbing_gym](#climbing_gym) + - [climbing_route](#climbing_route) + - [climbing](#climbing) + - [maybe_climbing](#maybe_climbing) + - [fietsstraat](#fietsstraat) + - [toekomstige_fietsstraat](#toekomstige_fietsstraat) + - [facadegardens](#facadegardens) + - [hackerspaces](#hackerspaces) + - [windturbine](#windturbine) + - [postboxes](#postboxes) + - [postoffices](#postoffices) + - [lit_streets](#lit_streets) + + +### ambulancestation + + + +An ambulance station is an area for storage of ambulance vehicles, medical equipment, personal protective equipment, and other medical supplies. + +[Go to the source code](../assets/layers/ambulancestation/ambulancestation.json) + + + + + + + + +#### Themes using this layer + + + + + + - [hailhydrant](https://mapcomplete.osm.be/hailhydrant) + + +### artwork + + + +Diverse pieces of artwork + +[Go to the source code](../assets/layers/artwork/artwork.json) + + + + + + + + +#### Themes using this layer + + + + + + - [artwork](https://mapcomplete.osm.be/artwork) + + +### barrier + + + +Obstacles while cycling, such as bollards and cycle barriers + +[Go to the source code](../assets/layers/barrier/barrier.json) + + + + - This layer needs [cycleways_and_roads](#cycleways_and_roads) to be loaded in order to function. + + + + +#### Themes using this layer + + + + + + - [cycle_infra](https://mapcomplete.osm.be/cycle_infra) + + +### bench + + + +[Go to the source code](../assets/layers/bench/bench.json) + + + + + + + + +#### Themes using this layer + + + + + + - [benches](https://mapcomplete.osm.be/benches) + + +### bench_at_pt + + + +[Go to the source code](../assets/layers/bench_at_pt/bench_at_pt.json) + + + + + + + + +#### Themes using this layer + + + + + + - [benches](https://mapcomplete.osm.be/benches) + + +### bicycle_tube_vending_machine + + + +[Go to the source code](../assets/layers/bicycle_tube_vending_machine/bicycle_tube_vending_machine.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_cafe + + + +[Go to the source code](../assets/layers/bike_cafe/bike_cafe.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_cleaning + + + +[Go to the source code](../assets/layers/bike_cleaning/bike_cleaning.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_parking + + + +[Go to the source code](../assets/layers/bike_parking/bike_parking.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_repair_station + + + +[Go to the source code](../assets/layers/bike_repair_station/bike_repair_station.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_shop + + + +A shop specifically selling bicycles or related items + +[Go to the source code](../assets/layers/bike_shop/bike_shop.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### bike_themed_object + + + +[Go to the source code](../assets/layers/bike_themed_object/bike_themed_object.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclofix](https://mapcomplete.osm.be/cyclofix) + + +### binocular + + + +Binoculas + +[Go to the source code](../assets/layers/binocular/binocular.json) + + + + + + + + +#### Themes using this layer + + + + + + - [binoculars](https://mapcomplete.osm.be/binoculars) + + +### birdhide + + + +Een vogelkijkhut + +[Go to the source code](../assets/layers/birdhide/birdhide.json) + + + + + + + + +#### Themes using this layer + + + + + + - [nature](https://mapcomplete.osm.be/nature) + + +### cafe_pub + + + +[Go to the source code](../assets/layers/cafe_pub/cafe_pub.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cafes_and_pubs](https://mapcomplete.osm.be/cafes_and_pubs) + + +### charging_station + + + +A charging station + +[Go to the source code](../assets/layers/charging_station/charging_station.json) + + + + + + + + +#### Themes using this layer + + + + + + - [charging_stations](https://mapcomplete.osm.be/charging_stations) + + +### crossings + + + +Crossings for pedestrians and cyclists + +[Go to the source code](../assets/layers/crossings/crossings.json) + + + + - This layer needs [cycleways_and_roads](#cycleways_and_roads) to be loaded in order to function. + + + + +#### Themes using this layer + + + + + + - [cycle_infra](https://mapcomplete.osm.be/cycle_infra) + + +### cycleways_and_roads + + + +[Go to the source code](../assets/layers/cycleways_and_roads/cycleways_and_roads.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cycle_infra](https://mapcomplete.osm.be/cycle_infra) + + +### defibrillator + + + +[Go to the source code](../assets/layers/defibrillator/defibrillator.json) + + + + + + + + +#### Themes using this layer + + + + + + - [aed](https://mapcomplete.osm.be/aed) + + +### direction + + + +This layer visualizes directions + +[Go to the source code](../assets/layers/direction/direction.json) + + + + - Not clickable by default. If you import this layer in your theme, override `title` to make this clickable + + + + +#### Themes using this layer + + + + + + - [surveillance](https://mapcomplete.osm.be/surveillance) + + +### etymology + + + +All objects which have an etymology known + +[Go to the source code](../assets/layers/etymology/etymology.json) + + + + + + + + +#### Themes using this layer + + + + + + - [etymology](https://mapcomplete.osm.be/etymology) + + +### extinguisher + + + +Map layer to show fire hydrants. + +[Go to the source code](../assets/layers/extinguisher/extinguisher.json) + + + + + + + + +#### Themes using this layer + + + + + + - [hailhydrant](https://mapcomplete.osm.be/hailhydrant) + + +### fire_station + + + +Map layer to show fire stations. + +[Go to the source code](../assets/layers/fire_station/fire_station.json) + + + + + + + + +#### Themes using this layer + + + + + + - [hailhydrant](https://mapcomplete.osm.be/hailhydrant) + + +### ghost_bike + + + +[Go to the source code](../assets/layers/ghost_bike/ghost_bike.json) + + + + + + + + +#### Themes using this layer + + + + + + - [ghostbikes](https://mapcomplete.osm.be/ghostbikes) + + +### hydrant + + + +Map layer to show fire hydrants. + +[Go to the source code](../assets/layers/hydrant/hydrant.json) + + + + + + + + +#### Themes using this layer + + + + + + - [hailhydrant](https://mapcomplete.osm.be/hailhydrant) + + +### information_board + + + +[Go to the source code](../assets/layers/information_board/information_board.json) + + + + + + + + +#### Themes using this layer + + + + + + - [nature](https://mapcomplete.osm.be/nature) + + +### nature_reserve + + + +Een natuurgebied is een gebied waar actief ruimte gemaakt word voor de natuur. Typisch zijn deze in beheer van Natuurpunt of het Agentschap Natuur en Bos of zijn deze erkend door de overheid. + +[Go to the source code](../assets/layers/nature_reserve/nature_reserve.json) + + + + + + + + +#### Themes using this layer + + + + + + - [nature](https://mapcomplete.osm.be/nature) + + +### observation_tower + + + +Towers with a panoramic view + +[Go to the source code](../assets/layers/observation_tower/observation_tower.json) + + + + + + + + +#### Themes using this layer + + + + + + - [observation_towers](https://mapcomplete.osm.be/observation_towers) + + +### parking + + + +A layer showing car parkings + +[Go to the source code](../assets/layers/parking/parking.json) + + + + + + + + +#### Themes using this layer + + + + + + - [parkings](https://mapcomplete.osm.be/parkings) + + +### picnic_table + + + +The layer showing picnic tables + +[Go to the source code](../assets/layers/picnic_table/picnic_table.json) + + + + + + + + +#### Themes using this layer + + + + + + - [benches](https://mapcomplete.osm.be/benches) + + +### playground + + + +Playgrounds + +[Go to the source code](../assets/layers/playground/playground.json) + + + + + + + + +#### Themes using this layer + + + + + + - [playgrounds](https://mapcomplete.osm.be/playgrounds) + + +### public_bookcase + + + +A streetside cabinet with books, accessible to anyone + +[Go to the source code](../assets/layers/public_bookcase/public_bookcase.json) + + + + + + + + +#### Themes using this layer + + + + + + - [bookcases](https://mapcomplete.osm.be/bookcases) + + +### shops + + + +A shop + +[Go to the source code](../assets/layers/shops/shops.json) + + + + + + + + +#### Themes using this layer + + + + + + - [shops](https://mapcomplete.osm.be/shops) + + +### sport_pitch + + + +A sport pitch + +[Go to the source code](../assets/layers/sport_pitch/sport_pitch.json) + + + + + + + + +#### Themes using this layer + + + + + + - [sport_pitches](https://mapcomplete.osm.be/sport_pitches) + + +### street_lamps + + + +[Go to the source code](../assets/layers/street_lamps/street_lamps.json) + + + + + + + + +#### Themes using this layer + + + + + + - [street_lighting](https://mapcomplete.osm.be/street_lighting) + + +### surveillance_camera + + + +[Go to the source code](../assets/layers/surveillance_camera/surveillance_camera.json) + + + + + + + + +#### Themes using this layer + + + + + + - [surveillance](https://mapcomplete.osm.be/surveillance) + + +### toilet + + + +[Go to the source code](../assets/layers/toilet/toilet.json) + + + + + + + + +#### Themes using this layer + + + + + + - [toilets](https://mapcomplete.osm.be/toilets) + + +### tree_node + + + +[Go to the source code](../assets/layers/tree_node/tree_node.json) + + + + + + + + +#### Themes using this layer + + + + + + - [trees](https://mapcomplete.osm.be/trees) + + +### waste_basket + + + +This is a public waste basket, thrash can, where you can throw away your thrash. + +[Go to the source code](../assets/layers/waste_basket/waste_basket.json) + + + + + + + + +#### Themes using this layer + + + + + + - [waste_basket](https://mapcomplete.osm.be/waste_basket) + + +### caravansites + + + +camper sites + +[Go to the source code](../assets/layers/caravansites/caravansites.json) + + + + + + + + +#### Themes using this layer + + + + + + - [campersite](https://mapcomplete.osm.be/campersite) + + +### dumpstations + + + +Sanitary dump stations + +[Go to the source code](../assets/layers/dumpstations/dumpstations.json) + + + + + + + + +#### Themes using this layer + + + + + + - [campersite](https://mapcomplete.osm.be/campersite) + + +### climbing_club + + + +A climbing club or organisations + +[Go to the source code](../assets/layers/climbing_club/climbing_club.json) + + + + + + + + +#### Themes using this layer + + + + + + - [climbing](https://mapcomplete.osm.be/climbing) + + +### climbing_gym + + + +A climbing gym + +[Go to the source code](../assets/layers/climbing_gym/climbing_gym.json) + + + + + + + + +#### Themes using this layer + + + + + + - [climbing](https://mapcomplete.osm.be/climbing) + + +### climbing_route + + + +[Go to the source code](../assets/layers/climbing_route/climbing_route.json) + + + + + + + + +#### Themes using this layer + + + + + + - [climbing](https://mapcomplete.osm.be/climbing) + + +### climbing + + + +A climbing opportunity + +[Go to the source code](../assets/layers/climbing/climbing.json) + + + + + + + + +#### Themes using this layer + + + + + + - [climbing](https://mapcomplete.osm.be/climbing) + + +### maybe_climbing + + + +A climbing opportunity? + +[Go to the source code](../assets/layers/maybe_climbing/maybe_climbing.json) + + + + + + + + +#### Themes using this layer + + + + + + - [climbing](https://mapcomplete.osm.be/climbing) + + +### fietsstraat + + + +A cyclestreet is a street where motorized traffic is not allowed to overtake a cyclist + +[Go to the source code](../assets/layers/fietsstraat/fietsstraat.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclestreets](https://mapcomplete.osm.be/cyclestreets) + + +### toekomstige_fietsstraat + + + +This street will become a cyclestreet soon + +[Go to the source code](../assets/layers/toekomstige_fietsstraat/toekomstige_fietsstraat.json) + + + + + + + + +#### Themes using this layer + + + + + + - [cyclestreets](https://mapcomplete.osm.be/cyclestreets) + + +### facadegardens + + + +Facade gardens + +[Go to the source code](../assets/layers/facadegardens/facadegardens.json) + + + + + + + + +#### Themes using this layer + + + + + + - [facadegardens](https://mapcomplete.osm.be/facadegardens) + + +### hackerspaces + + + +Hackerspace + +[Go to the source code](../assets/layers/hackerspaces/hackerspaces.json) + + + + + + + + +#### Themes using this layer + + + + + + - [hackerspaces](https://mapcomplete.osm.be/hackerspaces) + + +### windturbine + + + +[Go to the source code](../assets/layers/windturbine/windturbine.json) + + + + + + + + +#### Themes using this layer + + + + + + - [openwindpowermap](https://mapcomplete.osm.be/openwindpowermap) + + +### postboxes + + + +The layer showing postboxes. + +[Go to the source code](../assets/layers/postboxes/postboxes.json) + + + + + + + + +#### Themes using this layer + + + + + + - [postboxes](https://mapcomplete.osm.be/postboxes) + + +### postoffices + + + +A layer showing post offices. + +[Go to the source code](../assets/layers/postoffices/postoffices.json) + + + + + + + + +#### Themes using this layer + + + + + + - [postboxes](https://mapcomplete.osm.be/postboxes) + + +### lit_streets + + + +[Go to the source code](../assets/layers/lit_streets/lit_streets.json) + + + + - Not rendered on the map by default. If you want to rendering this on the map, override `mapRenderings` + + + + +#### Themes using this layer + + + + + + - [street_lighting](https://mapcomplete.osm.be/street_lighting) + + This document is autogenerated from AllKnownLayers.ts \ No newline at end of file From 62f280feae86719d938d7193f3e75d53da942a0e Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 4 Dec 2021 21:49:17 +0100 Subject: [PATCH 4/4] First version of automatic dependency injection --- Models/ThemeConfig/LayerConfig.ts | 63 ++++++++++++++++++++---------- Models/ThemeConfig/LayoutConfig.ts | 38 ++++++++++++++---- Models/ThemeConfig/PresetConfig.ts | 12 +++--- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index 34245bd7b7..1128ecb943 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -1,7 +1,7 @@ import {Translation} from "../../UI/i18n/Translation"; import SourceConfig from "./SourceConfig"; import TagRenderingConfig from "./TagRenderingConfig"; -import PresetConfig from "./PresetConfig"; +import PresetConfig, {PreciseInput} from "./PresetConfig"; import {LayerConfigJson} from "./Json/LayerConfigJson"; import Translations from "../../UI/i18n/Translations"; import {TagUtils} from "../../Logic/Tags/TagUtils"; @@ -26,19 +26,19 @@ import * as icons from "../../assets/tagRenderings/icons.json" export default class LayerConfig extends WithContextLoader { - id: string; - name: Translation; - description: Translation; - source: SourceConfig; - calculatedTags: [string, string][]; - doNotDownload: boolean; - passAllFeatures: boolean; - isShown: TagRenderingConfig; - minzoom: number; - minzoomVisible: number; - maxzoom: number; - title?: TagRenderingConfig; - titleIcons: TagRenderingConfig[]; + public readonly id: string; + public readonly name: Translation; + public readonly description: Translation; + public readonly source: SourceConfig; + public readonly calculatedTags: [string, string][]; + public readonly doNotDownload: boolean; + public readonly passAllFeatures: boolean; + public readonly isShown: TagRenderingConfig; + public readonly minzoom: number; + public readonly minzoomVisible: number; + public readonly maxzoom: number; + public readonly title?: TagRenderingConfig; + public readonly titleIcons: TagRenderingConfig[]; public readonly mapRendering: PointRenderingConfig[] public readonly lineRendering: LineRenderingConfig[] @@ -52,10 +52,10 @@ export default class LayerConfig extends WithContextLoader { */ public readonly maxAgeOfCache: number - presets: PresetConfig[]; + public readonly presets: PresetConfig[]; - tagRenderings: TagRenderingConfig[]; - filters: FilterConfig[]; + public readonly tagRenderings: TagRenderingConfig[]; + public readonly filters: FilterConfig[]; constructor( json: LayerConfigJson, @@ -151,8 +151,7 @@ export default class LayerConfig extends WithContextLoader { throw "Presets should be a list of items (at " + context + ")" } this.presets = (json.presets ?? []).map((pr, i) => { - - let preciseInput: any = { + let preciseInput: PreciseInput = { preferredBackground: ["photo"], snapToLayers: undefined, maxSnapDistance: undefined @@ -163,6 +162,7 @@ export default class LayerConfig extends WithContextLoader { preferredBackground: undefined } } + let snapToLayers: string[]; if (typeof pr.preciseInput.snapToLayer === "string") { snapToLayers = [pr.preciseInput.snapToLayer] @@ -178,7 +178,7 @@ export default class LayerConfig extends WithContextLoader { } preciseInput = { preferredBackground: preferredBackground, - snapToLayers: snapToLayers, + snapToLayers, maxSnapDistance: pr.preciseInput.maxSnapDistance ?? 10 } } @@ -439,6 +439,10 @@ export default class LayerConfig extends WithContextLoader { ] } + for (const dep of Array.from(this.getDependencies())) { + extraProps.push(new Combine(["This layer will automatically load ", new Link(dep, "#"+dep)," into the layout as it depends on it."])) + } + return new Combine([ new Title(this.id, 3), this.description, @@ -478,4 +482,23 @@ export default class LayerConfig extends WithContextLoader { public isLeftRightSensitive(): boolean { return this.lineRendering.some(lr => lr.leftRightSensitive) } + + /** + * Returns a set of all other layer-ids that this layer needs to function. + * E.g. if this layers does snap to another layer in the preset, this other layer id will be mentioned + */ + public getDependencies(): Set{ + const deps = new Set() + + for (const preset of this.presets ?? []) { + if(preset.preciseInput?.snapToLayers === undefined){ + continue + } + preset.preciseInput?.snapToLayers?.forEach(id => { + deps.add(id); + }) + } + + return deps + } } \ No newline at end of file diff --git a/Models/ThemeConfig/LayoutConfig.ts b/Models/ThemeConfig/LayoutConfig.ts index 61efd85203..09c71c8243 100644 --- a/Models/ThemeConfig/LayoutConfig.ts +++ b/Models/ThemeConfig/LayoutConfig.ts @@ -166,7 +166,7 @@ export default class LayoutConfig { return } else { const shared = AllKnownLayers.sharedLayers.get(layer) - if(shared === undefined){ + if (shared === undefined) { throw `Shared layer ${layer} not found (at ${context}.layers[${i}])` } result.push(shared) @@ -212,15 +212,39 @@ export default class LayoutConfig { }) }); - + // Some special layers which are always included by default for (const defaultLayer of AllKnownLayers.added_by_default) { - if(result.some(l => l?.id === defaultLayer)){ + if (result.some(l => l?.id === defaultLayer)) { continue; // Already added } - result.push(AllKnownLayers.sharedLayers.get(defaultLayer)) + const sharedLayer = AllKnownLayers.sharedLayers.get(defaultLayer) + if (sharedLayer !== undefined) { + result.push(sharedLayer) + } } + + let unmetDependencies: { dependency: string, layer: string }[] = [] + do { + const dependencies: { dependency: string, layer: string }[] = [].concat(...result.map(l => Array.from(l.getDependencies()).map(d => ({ + dependency: d, + layer: l.id + })))) + const loadedLayers = new Set(result.map(r => r.id)) + unmetDependencies = dependencies.filter(dep => !loadedLayers.has(dep.dependency)) + for (const unmetDependency of unmetDependencies) { + + console.log("Recursively loading unmet dependency ", unmetDependency.dependency, "(needed by " + unmetDependency.layer + ")") + const dep = AllKnownLayers.sharedLayers.get(unmetDependency.dependency) + if (dep === undefined) { + throw "The layer '" + unmetDependency.layer + "' needs '" + unmetDependency.dependency + "' to be loaded, but it could not be found as builtin layer (at " + context + ")" + } + result.unshift(dep) + unmetDependencies = unmetDependencies.filter(d => d.dependency !== unmetDependency.dependency) + } + + } while (unmetDependencies.length > 0) return {layers: result, extractAllNodes: exportAllNodes} } @@ -300,9 +324,9 @@ export default class LayoutConfig { public isLeftRightSensitive() { return this.layers.some(l => l.isLeftRightSensitive()) } - - public getMatchingLayer(tags: any) : LayerConfig | undefined{ - if(tags === undefined){ + + public getMatchingLayer(tags: any): LayerConfig | undefined { + if (tags === undefined) { return undefined } for (const layer of this.layers) { diff --git a/Models/ThemeConfig/PresetConfig.ts b/Models/ThemeConfig/PresetConfig.ts index 9f198289bb..da823fcd28 100644 --- a/Models/ThemeConfig/PresetConfig.ts +++ b/Models/ThemeConfig/PresetConfig.ts @@ -1,6 +1,12 @@ import {Translation} from "../../UI/i18n/Translation"; import {Tag} from "../../Logic/Tags/Tag"; +export interface PreciseInput { + preferredBackground?: string[], + snapToLayers?: string[], + maxSnapDistance?: number +} + export default interface PresetConfig { title: Translation, tags: Tag[], @@ -8,9 +14,5 @@ export default interface PresetConfig { /** * If precise input is set, then an extra map is shown in which the user can drag the map to the precise location */ - preciseInput?: { - preferredBackground?: string[], - snapToLayers?: string[], - maxSnapDistance?: number - } + preciseInput?: PreciseInput } \ No newline at end of file