| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | import FilteringFeatureSource from "../FeatureSource/FilteringFeatureSource"; | 
					
						
							|  |  |  | import FeatureSourceMerger from "../FeatureSource/FeatureSourceMerger"; | 
					
						
							|  |  |  | import RememberingSource from "../FeatureSource/RememberingSource"; | 
					
						
							|  |  |  | import WayHandlingApplyingFeatureSource from "../FeatureSource/WayHandlingApplyingFeatureSource"; | 
					
						
							|  |  |  | import NoOverlapSource from "../FeatureSource/NoOverlapSource"; | 
					
						
							|  |  |  | import FeatureDuplicatorPerLayer from "../FeatureSource/FeatureDuplicatorPerLayer"; | 
					
						
							|  |  |  | import FeatureSource from "../FeatureSource/FeatureSource"; | 
					
						
							|  |  |  | import {UIEventSource} from "../UIEventSource"; | 
					
						
							|  |  |  | import LocalStorageSaver from "./LocalStorageSaver"; | 
					
						
							|  |  |  | import LayerConfig from "../../Customizations/JSON/LayerConfig"; | 
					
						
							|  |  |  | import LocalStorageSource from "./LocalStorageSource"; | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  | import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  | import Loc from "../../Models/Loc"; | 
					
						
							| 
									
										
										
										
											2021-03-21 01:32:21 +01:00
										 |  |  | import GeoJsonSource from "./GeoJsonSource"; | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class FeaturePipeline implements FeatureSource { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public features: UIEventSource<{ feature: any; freshness: Date }[]>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     constructor(flayers: UIEventSource<{ isDisplayed: UIEventSource<boolean>, layerDef: LayerConfig }[]>, | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  |                 updater: FeatureSource, | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  |                 layout: UIEventSource<LayoutConfig>, | 
					
						
							|  |  |  |                 newPoints: FeatureSource, | 
					
						
							|  |  |  |                 locationControl: UIEventSource<Loc>) { | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const amendedOverpassSource = | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  |             new RememberingSource( | 
					
						
							|  |  |  |                 new WayHandlingApplyingFeatureSource(flayers, | 
					
						
							|  |  |  |                     new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, | 
					
						
							|  |  |  |                         new LocalStorageSaver(updater, layout))) | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-21 01:32:21 +01:00
										 |  |  |         const geojsonSources: GeoJsonSource [] = [] | 
					
						
							|  |  |  |         for (const flayer of flayers.data) { | 
					
						
							|  |  |  |             const sourceUrl = flayer.layerDef.source.geojsonSource | 
					
						
							|  |  |  |             if (sourceUrl !== undefined) { | 
					
						
							|  |  |  |                 geojsonSources.push(new WayHandlingApplyingFeatureSource(flayers,  | 
					
						
							|  |  |  |                     new GeoJsonSource(flayer.layerDef.id, sourceUrl))) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  |         const amendedLocalStorageSource = | 
					
						
							|  |  |  |             new RememberingSource( | 
					
						
							|  |  |  |                 new WayHandlingApplyingFeatureSource(flayers, | 
					
						
							|  |  |  |                     new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout))) | 
					
						
							|  |  |  |                 )); | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  |         newPoints = new FeatureDuplicatorPerLayer(flayers, newPoints); | 
					
						
							| 
									
										
										
										
											2021-03-21 01:32:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |         const merged = new FeatureSourceMerger([ | 
					
						
							|  |  |  |             amendedOverpassSource, | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  |             amendedLocalStorageSource, | 
					
						
							| 
									
										
										
										
											2021-03-21 01:32:21 +01:00
										 |  |  |             newPoints, | 
					
						
							|  |  |  |             ...geojsonSources | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |         ]); | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |         const source = | 
					
						
							|  |  |  |             new FilteringFeatureSource( | 
					
						
							|  |  |  |                 flayers, | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  |                 locationControl, | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |                 merged | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |         this.features = source.features; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |