| 
									
										
										
										
											2021-01-03 03:09:52 +01:00
										 |  |  | import {UIEventSource} from "../UIEventSource"; | 
					
						
							|  |  |  | import Loc from "../../Models/Loc"; | 
					
						
							| 
									
										
										
										
											2021-03-29 02:04:42 +02:00
										 |  |  | import {Or} from "../Tags/Or"; | 
					
						
							| 
									
										
										
										
											2021-01-03 03:09:52 +01:00
										 |  |  | import {Overpass} from "../Osm/Overpass"; | 
					
						
							|  |  |  | import Bounds from "../../Models/Bounds"; | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | import FeatureSource, {FeatureSourceState} from "../FeatureSource/FeatureSource"; | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  | import {Utils} from "../../Utils"; | 
					
						
							| 
									
										
										
										
											2021-03-29 02:04:42 +02:00
										 |  |  | import {TagsFilter} from "../Tags/TagsFilter"; | 
					
						
							| 
									
										
										
										
											2021-05-10 23:51:03 +02:00
										 |  |  | import SimpleMetaTagger from "../SimpleMetaTagger"; | 
					
						
							| 
									
										
										
										
											2021-08-07 23:11:34 +02:00
										 |  |  | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | import RelationsTracker from "../Osm/RelationsTracker"; | 
					
						
							| 
									
										
										
										
											2021-01-03 03:09:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | export default class OverpassFeatureSource implements FeatureSource, FeatureSourceState { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 02:25:30 +02:00
										 |  |  |     public readonly name = "OverpassFeatureSource" | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The last loaded features of the geojson | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     public readonly features: UIEventSource<{ feature: any, freshness: Date }[]> = new UIEventSource<any[]>(undefined); | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |     public readonly sufficientlyZoomed: UIEventSource<boolean>; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     public readonly runningQuery: UIEventSource<boolean> = new UIEventSource<boolean>(false); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     public readonly timeout: UIEventSource<number> = new UIEventSource<number>(0); | 
					
						
							| 
									
										
										
										
											2021-09-10 01:18:51 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |     public readonly relationsTracker: RelationsTracker; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     private readonly retries: UIEventSource<number> = new UIEventSource<number>(0); | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |      * The previous bounds for which the query has been run at the given zoom level | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Note that some layers only activate on a certain zoom level. | 
					
						
							|  |  |  |      * If the map location changes, we check for each layer if it is loaded: | 
					
						
							|  |  |  |      * we start checking the bounds at the first zoom level the layer might operate. If in bounds - no reload needed, otherwise we continue walking down | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |     private readonly _previousBounds: Map<number, Bounds[]> = new Map<number, Bounds[]>(); | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |     private readonly state: { | 
					
						
							|  |  |  |         readonly locationControl: UIEventSource<Loc>, | 
					
						
							|  |  |  |         readonly layoutToUse: UIEventSource<LayoutConfig>, | 
					
						
							|  |  |  |         readonly leafletMap: any, | 
					
						
							|  |  |  |         readonly overpassUrl: UIEventSource<string>; | 
					
						
							|  |  |  |         readonly overpassTimeout: UIEventSource<number>; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * The most important layer should go first, as that one gets first pick for the questions | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |     constructor( | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         state: { | 
					
						
							|  |  |  |             readonly locationControl: UIEventSource<Loc>, | 
					
						
							|  |  |  |             readonly layoutToUse: UIEventSource<LayoutConfig>, | 
					
						
							|  |  |  |             readonly leafletMap: any, | 
					
						
							|  |  |  |             readonly overpassUrl: UIEventSource<string>; | 
					
						
							|  |  |  |             readonly overpassTimeout: UIEventSource<number>; | 
					
						
							|  |  |  |             readonly overpassMaxZoom: UIEventSource<number> | 
					
						
							|  |  |  |         }) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.state = state | 
					
						
							|  |  |  |         this.relationsTracker = new RelationsTracker() | 
					
						
							|  |  |  |         const location = state.locationControl | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         const self = this; | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |         this.sufficientlyZoomed = location.map(location => { | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                 if (location?.zoom === undefined) { | 
					
						
							| 
									
										
										
										
											2020-09-18 00:31:54 +02:00
										 |  |  |                     return false; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 let minzoom = Math.min(...state.layoutToUse.data.layers.map(layer => layer.minzoom ?? 18)); | 
					
						
							|  |  |  |                 if (location.zoom < minzoom) { | 
					
						
							| 
									
										
										
										
											2021-09-10 01:18:51 +02:00
										 |  |  |                     return false; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 const maxZoom = state.overpassMaxZoom.data | 
					
						
							|  |  |  |                 if (maxZoom !== undefined && location.zoom > maxZoom) { | 
					
						
							| 
									
										
										
										
											2021-09-10 01:18:51 +02:00
										 |  |  |                     return false; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-10 01:18:51 +02:00
										 |  |  |                 return true; | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |             }, [state.layoutToUse] | 
					
						
							| 
									
										
										
										
											2020-08-30 01:13:18 +02:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |         for (let i = 0; i < 25; i++) { | 
					
						
							|  |  |  |             // This update removes all data on all layers -> erase the map on lower levels too
 | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |             this._previousBounds.set(i, []); | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         state.layoutToUse.addCallback(() => { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |             self.update() | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |         location.addCallback(() => { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |             self.update() | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         state.leafletMap.addCallbackAndRunD(_ => { | 
					
						
							| 
									
										
										
										
											2021-09-03 13:48:04 +02:00
										 |  |  |             self.update(); | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public ForceRefresh() { | 
					
						
							|  |  |  |         for (let i = 0; i < 25; i++) { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |             this._previousBounds.set(i, []); | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |         this.update(); | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |     private GetFilter(): Overpass { | 
					
						
							|  |  |  |         let filters: TagsFilter[] = []; | 
					
						
							|  |  |  |         let extraScripts: string[] = []; | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         for (const layer of this.state.layoutToUse.data.layers) { | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |             if (typeof (layer) === "string") { | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |                 throw "A layer was not expanded!" | 
					
						
							| 
									
										
										
										
											2020-09-02 11:37:34 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |             if (this.state.locationControl.data.zoom < layer.minzoom) { | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |             if (layer.doNotDownload) { | 
					
						
							| 
									
										
										
										
											2020-11-17 02:22:48 +01:00
										 |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-04-23 12:55:38 +02:00
										 |  |  |             if (layer.source.geojsonSource !== undefined) { | 
					
						
							| 
									
										
										
										
											2021-03-21 01:32:21 +01:00
										 |  |  |                 // Not our responsibility to download this layer!
 | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |             // Check if data for this layer has already been loaded
 | 
					
						
							|  |  |  |             let previouslyLoaded = false; | 
					
						
							|  |  |  |             for (let z = layer.minzoom; z < 25 && !previouslyLoaded; z++) { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |                 const previousLoadedBounds = this._previousBounds.get(z); | 
					
						
							| 
									
										
										
										
											2020-08-31 02:59:47 +02:00
										 |  |  |                 if (previousLoadedBounds === undefined) { | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |                     continue; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 for (const previousLoadedBound of previousLoadedBounds) { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |                     previouslyLoaded = previouslyLoaded || this.IsInBounds(previousLoadedBound); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                     if (previouslyLoaded) { | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |                         break; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (previouslyLoaded) { | 
					
						
							| 
									
										
										
										
											2020-08-26 20:11:43 +02:00
										 |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |             if (layer.source.overpassScript !== undefined) { | 
					
						
							|  |  |  |                 extraScripts.push(layer.source.overpassScript) | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 filters.push(layer.source.osmTags); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |         filters = Utils.NoNull(filters) | 
					
						
							|  |  |  |         extraScripts = Utils.NoNull(extraScripts) | 
					
						
							|  |  |  |         if (filters.length + extraScripts.length === 0) { | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         return new Overpass(new Or(filters), extraScripts, this.state.overpassUrl, this.state.overpassTimeout, this.relationsTracker); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |     private update(): void { | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         if (this.runningQuery.data) { | 
					
						
							| 
									
										
										
										
											2021-04-21 01:25:00 +02:00
										 |  |  |             console.log("Still running a query, not updating"); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-04-23 12:55:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (this.timeout.data > 0) { | 
					
						
							| 
									
										
										
										
											2021-04-21 01:25:00 +02:00
										 |  |  |             console.log("Still in timeout - not updating") | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-30 00:59:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         const bounds = this.state.leafletMap.data?.getBounds()?.pad(this.state.layoutToUse.data.widenFactor); | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |         if (bounds === undefined) { | 
					
						
							| 
									
										
										
										
											2021-09-03 13:48:04 +02:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         const n = Math.min(90, bounds.getNorth()); | 
					
						
							|  |  |  |         const e = Math.min(180, bounds.getEast()); | 
					
						
							| 
									
										
										
										
											2021-09-18 02:28:17 +02:00
										 |  |  |         const s = Math.max(-90, bounds.getSouth()); | 
					
						
							|  |  |  |         const w = Math.max(-180, bounds.getWest()); | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |         const queryBounds = {north: n, east: e, south: s, west: w}; | 
					
						
							| 
									
										
										
										
											2020-07-30 00:59:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         const z = Math.floor(this.state.locationControl.data.zoom ?? 0); | 
					
						
							| 
									
										
										
										
											2020-07-31 16:17:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         const self = this; | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |         const overpass = this.GetFilter(); | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |         if (overpass === undefined) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         this.runningQuery.setData(true); | 
					
						
							| 
									
										
										
										
											2020-08-28 03:16:21 +02:00
										 |  |  |         overpass.queryGeoJson(queryBounds, | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |             function (data, date) { | 
					
						
							|  |  |  |                 self._previousBounds.get(z).push(queryBounds); | 
					
						
							|  |  |  |                 self.retries.setData(0); | 
					
						
							| 
									
										
										
										
											2021-05-10 23:51:03 +02:00
										 |  |  |                 const features = data.features.map(f => ({feature: f, freshness: date})); | 
					
						
							|  |  |  |                 SimpleMetaTagger.objectMetaInfo.addMetaTags(features) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 try{ | 
					
						
							|  |  |  |                     self.features.setData(features); | 
					
						
							|  |  |  |                 }catch(e){ | 
					
						
							|  |  |  |                     console.error("Got the overpass response, but could not process it: ", e, e.stack) | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |                 self.runningQuery.setData(false); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             }, | 
					
						
							|  |  |  |             function (reason) { | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |                 self.retries.data++; | 
					
						
							|  |  |  |                 self.ForceRefresh(); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                 self.timeout.setData(self.retries.data * 5); | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 console.error(`QUERY FAILED (retrying in ${5 * self.retries.data} sec) due to ${reason}`); | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |                 self.retries.ping(); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                 self.runningQuery.setData(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function countDown() { | 
					
						
							|  |  |  |                     window?.setTimeout( | 
					
						
							|  |  |  |                         function () { | 
					
						
							|  |  |  |                             if (self.timeout.data > 1) { | 
					
						
							|  |  |  |                                 self.timeout.setData(self.timeout.data - 1); | 
					
						
							|  |  |  |                                 window.setTimeout( | 
					
						
							|  |  |  |                                     countDown, | 
					
						
							|  |  |  |                                     1000 | 
					
						
							|  |  |  |                                 ) | 
					
						
							|  |  |  |                             } else { | 
					
						
							|  |  |  |                                 self.timeout.setData(0); | 
					
						
							|  |  |  |                                 self.update() | 
					
						
							|  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  |                         }, 1000 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                     ) | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-03-20 23:45:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |                 countDown(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-03 00:19:42 +01:00
										 |  |  |     private IsInBounds(bounds: Bounds): boolean { | 
					
						
							|  |  |  |         if (this._previousBounds === undefined) { | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |         const b = this.state.leafletMap.data.getBounds(); | 
					
						
							| 
									
										
										
										
											2020-08-30 01:13:18 +02:00
										 |  |  |         return b.getSouth() >= bounds.south && | 
					
						
							|  |  |  |             b.getNorth() <= bounds.north && | 
					
						
							|  |  |  |             b.getEast() <= bounds.east && | 
					
						
							|  |  |  |             b.getWest() >= bounds.west; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | } |