forked from MapComplete/MapComplete
		
	Themes: validate that a background layer actually exists, fix current-view button (GRB)
This commit is contained in:
		
							parent
							
								
									eb6194bf8f
								
							
						
					
					
						commit
						fc483ed547
					
				
					 9 changed files with 62 additions and 29 deletions
				
			
		| 
						 | 
					@ -22,7 +22,8 @@
 | 
				
			||||||
  "startZoom": 9,
 | 
					  "startZoom": 9,
 | 
				
			||||||
  "startLat": 51.0249,
 | 
					  "startLat": 51.0249,
 | 
				
			||||||
  "startLon": 4.026489,
 | 
					  "startLon": 4.026489,
 | 
				
			||||||
  "defaultBackgroundId": "AGIVFlandersGRB",
 | 
					  
 | 
				
			||||||
 | 
					  "defaultBackgroundId": "osm",
 | 
				
			||||||
  "credits": [
 | 
					  "credits": [
 | 
				
			||||||
    "Pieter Vander Vennet"
 | 
					    "Pieter Vander Vennet"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@
 | 
				
			||||||
  "startZoom": 8,
 | 
					  "startZoom": 8,
 | 
				
			||||||
  "startLat": 50.642,
 | 
					  "startLat": 50.642,
 | 
				
			||||||
  "startLon": 4.482,
 | 
					  "startLon": 4.482,
 | 
				
			||||||
  "defaultBackgroundId": "AGIV",
 | 
					  "defaultBackgroundId": "photo",
 | 
				
			||||||
  "credits": [
 | 
					  "credits": [
 | 
				
			||||||
    "Midgard"
 | 
					    "Midgard"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "mapcomplete",
 | 
					  "name": "mapcomplete",
 | 
				
			||||||
  "version": "0.36.10",
 | 
					  "version": "0.36.11",
 | 
				
			||||||
  "repository": "https://github.com/pietervdvn/MapComplete",
 | 
					  "repository": "https://github.com/pietervdvn/MapComplete",
 | 
				
			||||||
  "description": "A small website to edit OSM easily",
 | 
					  "description": "A small website to edit OSM easily",
 | 
				
			||||||
  "bugs": "https://github.com/pietervdvn/MapComplete/issues",
 | 
					  "bugs": "https://github.com/pietervdvn/MapComplete/issues",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,6 +83,15 @@ export class AvailableRasterLayers {
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static allIds(): Set<string> {
 | 
				
			||||||
 | 
					        const all: string[] = []
 | 
				
			||||||
 | 
					        all.push(...AvailableRasterLayers.globalLayers.map((l) => l.properties.id))
 | 
				
			||||||
 | 
					        all.push(...AvailableRasterLayers.EditorLayerIndex.map((l) => l.properties.id))
 | 
				
			||||||
 | 
					        all.push(this.osmCarto.properties.id)
 | 
				
			||||||
 | 
					        all.push(this.maptilerDefaultLayer.properties.id)
 | 
				
			||||||
 | 
					        return new Set<string>(all)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class RasterLayerUtils {
 | 
					export class RasterLayerUtils {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,9 @@ import PresetConfig from "../PresetConfig"
 | 
				
			||||||
import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
 | 
					import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
 | 
				
			||||||
import { Translatable } from "../Json/Translatable"
 | 
					import { Translatable } from "../Json/Translatable"
 | 
				
			||||||
import { ConversionContext } from "./ConversionContext"
 | 
					import { ConversionContext } from "./ConversionContext"
 | 
				
			||||||
 | 
					import * as eli from "../../../assets/editor-layer-index.json"
 | 
				
			||||||
 | 
					import { AvailableRasterLayers } from "../../RasterLayers"
 | 
				
			||||||
 | 
					import Back from "../../../assets/svg/Back.svelte"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ValidateLanguageCompleteness extends DesugaringStep<LayoutConfig> {
 | 
					class ValidateLanguageCompleteness extends DesugaringStep<LayoutConfig> {
 | 
				
			||||||
    private readonly _languages: string[]
 | 
					    private readonly _languages: string[]
 | 
				
			||||||
| 
						 | 
					@ -124,6 +127,7 @@ export class DoesImageExist extends DesugaringStep<string> {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
 | 
					export class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
 | 
				
			||||||
 | 
					    private static readonly _availableLayers = AvailableRasterLayers.allIds()
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The paths where this layer is originally saved. Triggers some extra checks
 | 
					     * The paths where this layer is originally saved. Triggers some extra checks
 | 
				
			||||||
     * @private
 | 
					     * @private
 | 
				
			||||||
| 
						 | 
					@ -260,6 +264,19 @@ export class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
 | 
				
			||||||
                .err("The overpassURL is a string, use a list of strings instead. Wrap it with [ ]")
 | 
					                .err("The overpassURL is a string, use a list of strings instead. Wrap it with [ ]")
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (json.defaultBackgroundId) {
 | 
				
			||||||
 | 
					            const backgroundId = json.defaultBackgroundId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const isCategory =
 | 
				
			||||||
 | 
					                backgroundId === "photo" || backgroundId === "map" || backgroundId === "osmbasedmap"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!isCategory && !ValidateTheme._availableLayers.has(backgroundId)) {
 | 
				
			||||||
 | 
					                context
 | 
				
			||||||
 | 
					                    .enter("defaultBackgroundId")
 | 
				
			||||||
 | 
					                    .err("This layer ID is not known: " + backgroundId)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return json
 | 
					        return json
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1465,7 +1482,7 @@ export class ValidateLayer extends Conversion<
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (let i = 0; i < json.presets.length; i++) {
 | 
					        for (let i = 0; i < json.presets?.length; i++) {
 | 
				
			||||||
            const preset = json.presets[i]
 | 
					            const preset = json.presets[i]
 | 
				
			||||||
            if (
 | 
					            if (
 | 
				
			||||||
                preset.snapToLayer === undefined &&
 | 
					                preset.snapToLayer === undefined &&
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,7 +145,7 @@ export interface LayerConfigJson {
 | 
				
			||||||
     * There are a few extra functions available. Refer to <a>Docs/CalculatedTags.md</a> for more information
 | 
					     * There are a few extra functions available. Refer to <a>Docs/CalculatedTags.md</a> for more information
 | 
				
			||||||
     * The functions will be run in order, e.g.
 | 
					     * The functions will be run in order, e.g.
 | 
				
			||||||
     * [
 | 
					     * [
 | 
				
			||||||
 Not found...    *  "_max_overlap_m2=Math.max(...feat.overlapsWith("someOtherLayer").map(o => o.overlap))
 | 
					     *  "_max_overlap_m2=Math.max(...feat.overlapsWith("someOtherLayer").map(o => o.overlap))
 | 
				
			||||||
     *  "_max_overlap_ratio=Number(feat._max_overlap_m2)/feat.area
 | 
					     *  "_max_overlap_ratio=Number(feat._max_overlap_m2)/feat.area
 | 
				
			||||||
     * ]
 | 
					     * ]
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -314,6 +314,7 @@ export default class LayoutConfig implements LayoutInformation {
 | 
				
			||||||
                return layer
 | 
					                return layer
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        console.log("Fallthrough", this, tags)
 | 
				
			||||||
        return undefined
 | 
					        return undefined
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,13 +13,7 @@
 | 
				
			||||||
  import type { MapProperties } from "../Models/MapProperties"
 | 
					  import type { MapProperties } from "../Models/MapProperties"
 | 
				
			||||||
  import Geosearch from "./BigComponents/Geosearch.svelte"
 | 
					  import Geosearch from "./BigComponents/Geosearch.svelte"
 | 
				
			||||||
  import Translations from "./i18n/Translations"
 | 
					  import Translations from "./i18n/Translations"
 | 
				
			||||||
  import {
 | 
					  import { CogIcon, EyeIcon, HeartIcon, MenuIcon, XCircleIcon } from "@rgossiaux/svelte-heroicons/solid"
 | 
				
			||||||
    CogIcon,
 | 
					 | 
				
			||||||
    EyeIcon,
 | 
					 | 
				
			||||||
    HeartIcon,
 | 
					 | 
				
			||||||
    MenuIcon,
 | 
					 | 
				
			||||||
    XCircleIcon,
 | 
					 | 
				
			||||||
  } from "@rgossiaux/svelte-heroicons/solid"
 | 
					 | 
				
			||||||
  import Tr from "./Base/Tr.svelte"
 | 
					  import Tr from "./Base/Tr.svelte"
 | 
				
			||||||
  import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte"
 | 
					  import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte"
 | 
				
			||||||
  import FloatOver from "./Base/FloatOver.svelte"
 | 
					  import FloatOver from "./Base/FloatOver.svelte"
 | 
				
			||||||
| 
						 | 
					@ -72,8 +66,6 @@
 | 
				
			||||||
  import FilterPanel from "./BigComponents/FilterPanel.svelte"
 | 
					  import FilterPanel from "./BigComponents/FilterPanel.svelte"
 | 
				
			||||||
  import PrivacyPolicy from "./BigComponents/PrivacyPolicy.svelte"
 | 
					  import PrivacyPolicy from "./BigComponents/PrivacyPolicy.svelte"
 | 
				
			||||||
  import { BBox } from "../Logic/BBox"
 | 
					  import { BBox } from "../Logic/BBox"
 | 
				
			||||||
  import { MapLibreAdaptor } from "./Map/MapLibreAdaptor.js"
 | 
					 | 
				
			||||||
  import { QueryParameters } from "../Logic/Web/QueryParameters"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  export let state: ThemeViewState
 | 
					  export let state: ThemeViewState
 | 
				
			||||||
  let layout = state.layout
 | 
					  let layout = state.layout
 | 
				
			||||||
| 
						 | 
					@ -100,8 +92,12 @@
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let selectedLayer: Store<LayerConfig> = state.selectedElement.mapD((element) =>
 | 
					  let selectedLayer: Store<LayerConfig> = state.selectedElement.mapD((element) => {
 | 
				
			||||||
    state.layout.getMatchingLayer(element.properties)
 | 
					      if (element.properties.id.startsWith("current_view")) {
 | 
				
			||||||
 | 
					        return currentViewLayer
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return state.layout.getMatchingLayer(element.properties)
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  let currentZoom = state.mapProperties.zoom
 | 
					  let currentZoom = state.mapProperties.zoom
 | 
				
			||||||
  let showCrosshair = state.userRelatedState.showCrosshair
 | 
					  let showCrosshair = state.userRelatedState.showCrosshair
 | 
				
			||||||
| 
						 | 
					@ -109,6 +105,7 @@
 | 
				
			||||||
  let viewport: UIEventSource<HTMLDivElement> = new UIEventSource<HTMLDivElement>(undefined)
 | 
					  let viewport: UIEventSource<HTMLDivElement> = new UIEventSource<HTMLDivElement>(undefined)
 | 
				
			||||||
  let mapproperties: MapProperties = state.mapProperties
 | 
					  let mapproperties: MapProperties = state.mapProperties
 | 
				
			||||||
  state.mapProperties.installCustomKeyboardHandler(viewport)
 | 
					  state.mapProperties.installCustomKeyboardHandler(viewport)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function updateViewport() {
 | 
					  function updateViewport() {
 | 
				
			||||||
    const rect = viewport.data?.getBoundingClientRect()
 | 
					    const rect = viewport.data?.getBoundingClientRect()
 | 
				
			||||||
    if (!rect) {
 | 
					    if (!rect) {
 | 
				
			||||||
| 
						 | 
					@ -142,7 +139,7 @@
 | 
				
			||||||
  onDestroy(
 | 
					  onDestroy(
 | 
				
			||||||
    rasterLayer.addCallbackAndRunD((l) => {
 | 
					    rasterLayer.addCallbackAndRunD((l) => {
 | 
				
			||||||
      rasterLayerName = l.properties.name
 | 
					      rasterLayerName = l.properties.name
 | 
				
			||||||
    })
 | 
					    }),
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  let previewedImage = state.previewedImage
 | 
					  let previewedImage = state.previewedImage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -228,7 +225,7 @@
 | 
				
			||||||
    {#if currentViewLayer?.tagRenderings && currentViewLayer.defaultIcon()}
 | 
					    {#if currentViewLayer?.tagRenderings && currentViewLayer.defaultIcon()}
 | 
				
			||||||
      <MapControlButton
 | 
					      <MapControlButton
 | 
				
			||||||
        on:click={() => {
 | 
					        on:click={() => {
 | 
				
			||||||
          selectedElement.setData(state.currentView.features?.data?.[0])
 | 
					          state.selectedElement.setData(state.currentView.features?.data?.[0])
 | 
				
			||||||
        }}
 | 
					        }}
 | 
				
			||||||
        on:keydown={forwardEventToMap}
 | 
					        on:keydown={forwardEventToMap}
 | 
				
			||||||
      >
 | 
					      >
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue