| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import BaseLayer from "../../Models/BaseLayer" | 
					
						
							|  |  |  | import { ImmutableStore, Store, UIEventSource } from "../UIEventSource" | 
					
						
							|  |  |  | import Loc from "../../Models/Loc" | 
					
						
							| 
									
										
										
										
											2020-09-25 21:58:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-15 14:52:11 +02:00
										 |  |  | export interface AvailableBaseLayersObj { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     readonly osmCarto: BaseLayer | 
					
						
							|  |  |  |     layerOverview: BaseLayer[] | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 |  |  |     AvailableLayersAt(location: Store<Loc>): Store<BaseLayer[]> | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     SelectBestLayerAccordingTo( | 
					
						
							|  |  |  |         location: Store<Loc>, | 
					
						
							|  |  |  |         preferedCategory: Store<string | string[]> | 
					
						
							|  |  |  |     ): Store<BaseLayer> | 
					
						
							| 
									
										
										
										
											2021-10-15 14:52:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-25 21:58:29 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Calculates which layers are available at the current location | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |  * Changes the basemap | 
					
						
							| 
									
										
										
										
											2020-09-25 21:58:29 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | export default class AvailableBaseLayers { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     public static layerOverview: BaseLayer[] | 
					
						
							|  |  |  |     public static osmCarto: BaseLayer | 
					
						
							| 
									
										
										
										
											2021-10-15 14:52:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private static implementation: AvailableBaseLayersObj | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 |  |  |     static AvailableLayersAt(location: Store<Loc>): Store<BaseLayer[]> { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         return ( | 
					
						
							|  |  |  |             AvailableBaseLayers.implementation?.AvailableLayersAt(location) ?? | 
					
						
							|  |  |  |             new ImmutableStore<BaseLayer[]>([]) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2020-09-25 21:58:29 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     static SelectBestLayerAccordingTo( | 
					
						
							|  |  |  |         location: Store<Loc>, | 
					
						
							|  |  |  |         preferedCategory: UIEventSource<string | string[]> | 
					
						
							|  |  |  |     ): Store<BaseLayer> { | 
					
						
							|  |  |  |         return ( | 
					
						
							|  |  |  |             AvailableBaseLayers.implementation?.SelectBestLayerAccordingTo( | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 preferedCategory | 
					
						
							|  |  |  |             ) ?? new ImmutableStore<BaseLayer>(undefined) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2020-09-27 22:48:43 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-27 23:37:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |     public static implement(backend: AvailableBaseLayersObj) { | 
					
						
							| 
									
										
										
										
											2021-10-15 14:52:11 +02:00
										 |  |  |         AvailableBaseLayers.layerOverview = backend.layerOverview | 
					
						
							|  |  |  |         AvailableBaseLayers.osmCarto = backend.osmCarto | 
					
						
							|  |  |  |         AvailableBaseLayers.implementation = backend | 
					
						
							| 
									
										
										
										
											2020-09-25 21:58:29 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |