| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  | import FeatureSource from "./FeatureSource"; | 
					
						
							|  |  |  | import {UIEventSource} from "../UIEventSource"; | 
					
						
							|  |  |  | import State from "../../State"; | 
					
						
							|  |  |  | import Hash from "../Web/Hash"; | 
					
						
							|  |  |  | import MetaTagging from "../MetaTagging"; | 
					
						
							| 
									
										
										
										
											2021-04-22 13:30:00 +02:00
										 |  |  | import ExtractRelations from "../Osm/ExtractRelations"; | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class MetaTaggingFeatureSource implements FeatureSource { | 
					
						
							| 
									
										
										
										
											2021-04-23 12:55:38 +02:00
										 |  |  |     public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{feature: any; freshness: Date}[]>(undefined); | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     public readonly name; | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  |      | 
					
						
							|  |  |  |     constructor(source: FeatureSource) { | 
					
						
							|  |  |  |         const self = this; | 
					
						
							| 
									
										
										
										
											2021-04-23 12:55:38 +02:00
										 |  |  |         this.name = "MetaTagging of "+source.name | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  |         source.features.addCallbackAndRun((featuresFreshness: { feature: any, freshness: Date }[]) => { | 
					
						
							|  |  |  |                 if (featuresFreshness === undefined) { | 
					
						
							|  |  |  |                     return; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 featuresFreshness.forEach(featureFresh => { | 
					
						
							|  |  |  |                     const feature = featureFresh.feature; | 
					
						
							| 
									
										
										
										
											2021-04-17 23:36:46 +02:00
										 |  |  |                      | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  |                     if (Hash.hash.data === feature.properties.id) { | 
					
						
							|  |  |  |                         State.state.selectedElement.setData(feature); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-22 13:30:00 +02:00
										 |  |  |                 MetaTagging.addMetatags(featuresFreshness, State.state.knownRelations.data, State.state.layoutToUse.data.layers); | 
					
						
							| 
									
										
										
										
											2021-03-25 15:19:44 +01:00
										 |  |  |                 self.features.setData(featuresFreshness); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  | } |