| 
									
										
										
										
											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 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-03-25 15:19:44 +01:00
										 |  |  | import MetaTaggingFeatureSource from "./MetaTaggingFeatureSource"; | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  | import RegisteringFeatureSource from "./RegisteringFeatureSource"; | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  | import {Changes} from "../Osm/Changes"; | 
					
						
							|  |  |  | import ChangeApplicator from "./ChangeApplicator"; | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class FeaturePipeline implements FeatureSource { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |     public features: UIEventSource<{ feature: any; freshness: Date }[]> ; | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |     public readonly name = "FeaturePipeline" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     constructor(flayers: UIEventSource<{ isDisplayed: UIEventSource<boolean>, layerDef: LayerConfig }[]>, | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  |                 changes: Changes, | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  |                 updater: FeatureSource, | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |                 fromOsmApi: FeatureSource, | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  |                 layout: UIEventSource<LayoutConfig>, | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |                 locationControl: UIEventSource<Loc>, | 
					
						
							|  |  |  |                 selectedElement: UIEventSource<any>) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |         const allLoadedFeatures = new UIEventSource<{ feature: any; freshness: Date }[]>([]) | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |         // first we metatag, then we save to get the metatags into storage too
 | 
					
						
							|  |  |  |         // Note that we need to register before we do metatagging (as it expects the event sources)
 | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 12:40:19 +02:00
										 |  |  |         // AT last, the metaTagging also needs to be run _after_ the duplicatorPerLayer
 | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |         const amendedOverpassSource = | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  |             new RememberingSource( | 
					
						
							|  |  |  |                 new LocalStorageSaver( | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |                     new MetaTaggingFeatureSource(allLoadedFeatures, | 
					
						
							| 
									
										
										
										
											2021-05-13 12:40:19 +02:00
										 |  |  |                         new FeatureDuplicatorPerLayer(flayers, | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |                             new RegisteringFeatureSource( | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  |                                 new ChangeApplicator( | 
					
						
							| 
									
										
										
										
											2021-07-18 21:37:14 +02:00
										 |  |  |                                     updater, changes | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  |                                 )) | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  |                         )), layout)); | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 03:30:46 +02:00
										 |  |  |         const geojsonSources: FeatureSource [] = GeoJsonSource | 
					
						
							|  |  |  |             .ConstructMultiSource(flayers.data, locationControl) | 
					
						
							| 
									
										
										
										
											2021-05-16 15:34:44 +02:00
										 |  |  |             .map(geojsonSource => { | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  |                 let source = new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers,  | 
					
						
							|  |  |  |                     new ChangeApplicator(geojsonSource, changes))); | 
					
						
							| 
									
										
										
										
											2021-05-16 15:34:44 +02:00
										 |  |  |                 if(!geojsonSource.isOsmCache){ | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |                     source = new MetaTaggingFeatureSource(allLoadedFeatures, source, updater.features); | 
					
						
							| 
									
										
										
										
											2021-05-16 15:34:44 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 return source | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 01:57:46 +01:00
										 |  |  |         const amendedLocalStorageSource = | 
					
						
							| 
									
										
										
										
											2021-07-15 20:47:28 +02:00
										 |  |  |             new RememberingSource(new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers,new ChangeApplicator( new LocalStorageSource(layout), changes)) | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  |             )); | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |         const amendedOsmApiSource = new RememberingSource( | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |             new MetaTaggingFeatureSource(allLoadedFeatures, | 
					
						
							| 
									
										
										
										
											2021-05-13 12:40:19 +02:00
										 |  |  |                 new FeatureDuplicatorPerLayer(flayers, | 
					
						
							| 
									
										
										
										
											2021-07-18 21:37:14 +02:00
										 |  |  |                     new RegisteringFeatureSource(new ChangeApplicator(fromOsmApi, changes, | 
					
						
							|  |  |  |                         { | 
					
						
							|  |  |  |                             // We lump in the new points here
 | 
					
						
							|  |  |  |                             generateNewGeometries: true  | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         ))))); | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  |         const merged = | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  |             new FeatureSourceMerger([ | 
					
						
							|  |  |  |                 amendedOverpassSource, | 
					
						
							| 
									
										
										
										
											2021-05-06 01:33:09 +02:00
										 |  |  |                 amendedOsmApiSource, | 
					
						
							| 
									
										
										
										
											2021-04-18 14:24:30 +02:00
										 |  |  |                 amendedLocalStorageSource, | 
					
						
							|  |  |  |                 ...geojsonSources | 
					
						
							|  |  |  |             ]); | 
					
						
							| 
									
										
										
										
											2021-02-14 19:45:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-21 03:25:54 +02:00
										 |  |  |         merged.features.syncWith(allLoadedFeatures) | 
					
						
							| 
									
										
										
										
											2021-06-22 12:13:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         this.features = new WayHandlingApplyingFeatureSource(flayers, | 
					
						
							|  |  |  |             new FilteringFeatureSource( | 
					
						
							|  |  |  |                 flayers, | 
					
						
							|  |  |  |                 locationControl, | 
					
						
							|  |  |  |                 selectedElement, | 
					
						
							|  |  |  |                 merged | 
					
						
							|  |  |  |             )).features; | 
					
						
							| 
									
										
										
										
											2021-01-15 00:29:07 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |