import BaseLayer from "../../Models/BaseLayer" import { ImmutableStore, Store, UIEventSource } from "../UIEventSource" import Loc from "../../Models/Loc" export interface AvailableBaseLayersObj { readonly osmCarto: BaseLayer layerOverview: BaseLayer[] AvailableLayersAt(location: Store): Store SelectBestLayerAccordingTo( location: Store, preferedCategory: Store ): Store } /** * Calculates which layers are available at the current location * Changes the basemap */ export default class AvailableBaseLayers { public static layerOverview: BaseLayer[] public static osmCarto: BaseLayer private static implementation: AvailableBaseLayersObj static AvailableLayersAt(location: Store): Store { return ( AvailableBaseLayers.implementation?.AvailableLayersAt(location) ?? new ImmutableStore([]) ) } static SelectBestLayerAccordingTo( location: Store, preferedCategory: UIEventSource ): Store { return ( AvailableBaseLayers.implementation?.SelectBestLayerAccordingTo( location, preferedCategory ) ?? new ImmutableStore(undefined) ) } public static implement(backend: AvailableBaseLayersObj) { AvailableBaseLayers.layerOverview = backend.layerOverview AvailableBaseLayers.osmCarto = backend.osmCarto AvailableBaseLayers.implementation = backend } }