forked from MapComplete/MapComplete
		
	Use merged-source instead of way-handled-source when calculating contained objects in the meta-tagging
This commit is contained in:
		
							parent
							
								
									fb0490ec27
								
							
						
					
					
						commit
						f723349e40
					
				
					 3 changed files with 16 additions and 14 deletions
				
			
		|  | @ -16,7 +16,7 @@ import RegisteringFeatureSource from "./RegisteringFeatureSource"; | |||
| 
 | ||||
| export default class FeaturePipeline implements FeatureSource { | ||||
| 
 | ||||
|     public features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{feature: any; freshness: Date}[]>([]); | ||||
|     public features: UIEventSource<{ feature: any; freshness: Date }[]> ; | ||||
| 
 | ||||
|     public readonly name = "FeaturePipeline" | ||||
| 
 | ||||
|  | @ -28,6 +28,8 @@ export default class FeaturePipeline implements FeatureSource { | |||
|                 locationControl: UIEventSource<Loc>, | ||||
|                 selectedElement: UIEventSource<any>) { | ||||
| 
 | ||||
|         const allLoadedFeatures = new UIEventSource<{ feature: any; freshness: Date }[]>([]) | ||||
|          | ||||
|         // 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)
 | ||||
| 
 | ||||
|  | @ -35,7 +37,7 @@ export default class FeaturePipeline implements FeatureSource { | |||
|         const amendedOverpassSource = | ||||
|             new RememberingSource( | ||||
|                 new LocalStorageSaver( | ||||
|                     new MetaTaggingFeatureSource(this, | ||||
|                     new MetaTaggingFeatureSource(allLoadedFeatures, | ||||
|                         new FeatureDuplicatorPerLayer(flayers, | ||||
|                             new RegisteringFeatureSource( | ||||
|                                 updater) | ||||
|  | @ -46,7 +48,7 @@ export default class FeaturePipeline implements FeatureSource { | |||
|             .map(geojsonSource => { | ||||
|                 let source = new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers, geojsonSource)); | ||||
|                 if(!geojsonSource.isOsmCache){ | ||||
|                     source = new MetaTaggingFeatureSource(this, source, updater.features); | ||||
|                     source = new MetaTaggingFeatureSource(allLoadedFeatures, source, updater.features); | ||||
|                 } | ||||
|                 return source | ||||
|             }); | ||||
|  | @ -55,18 +57,17 @@ export default class FeaturePipeline implements FeatureSource { | |||
|             new RememberingSource(new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout)) | ||||
|             )); | ||||
| 
 | ||||
|         newPoints = new MetaTaggingFeatureSource(this, | ||||
|         newPoints = new MetaTaggingFeatureSource(allLoadedFeatures, | ||||
|             new FeatureDuplicatorPerLayer(flayers, | ||||
|                 new RegisteringFeatureSource(newPoints))); | ||||
| 
 | ||||
|         const amendedOsmApiSource = new RememberingSource( | ||||
|             new MetaTaggingFeatureSource(this, | ||||
|             new MetaTaggingFeatureSource(allLoadedFeatures, | ||||
|                 new FeatureDuplicatorPerLayer(flayers, | ||||
| 
 | ||||
|                     new RegisteringFeatureSource(fromOsmApi)))); | ||||
| 
 | ||||
|         const merged = | ||||
| 
 | ||||
|             new FeatureSourceMerger([ | ||||
|                 amendedOverpassSource, | ||||
|                 amendedOsmApiSource, | ||||
|  | @ -75,6 +76,8 @@ export default class FeaturePipeline implements FeatureSource { | |||
|                 ...geojsonSources | ||||
|             ]); | ||||
| 
 | ||||
|         merged.features.syncWith(allLoadedFeatures) | ||||
|          | ||||
|         const source = | ||||
|             new WayHandlingApplyingFeatureSource(flayers, | ||||
|                 new FilteringFeatureSource( | ||||
|  | @ -83,8 +86,7 @@ export default class FeaturePipeline implements FeatureSource { | |||
|                     selectedElement, | ||||
|                     merged | ||||
|                 )); | ||||
|          | ||||
|         source.features.syncWith(this.features) | ||||
|         this.features = source.features; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -15,12 +15,12 @@ export default class MetaTaggingFeatureSource implements FeatureSource { | |||
|      * @param source: the source of features that should get their metatag and which should be exported again | ||||
|      * @param updateTrigger | ||||
|      */ | ||||
|     constructor(allFeaturesSource: FeatureSource, source: FeatureSource, updateTrigger?: UIEventSource<any>) { | ||||
|     constructor(allFeaturesSource: UIEventSource<{ feature: any; freshness: Date }[]>, source: FeatureSource, updateTrigger?: UIEventSource<any>) { | ||||
|         const self = this; | ||||
|         this.name = "MetaTagging of " + source.name | ||||
| 
 | ||||
|         if(allFeaturesSource.features === undefined){ | ||||
|             throw ("Initialize the featuresource fully first!"+allFeaturesSource.name) | ||||
|         if(allFeaturesSource === undefined){ | ||||
|             throw ("UIEVentSource is undefined") | ||||
|         } | ||||
|          | ||||
|         function update() { | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import LayerConfig from "../Customizations/JSON/LayerConfig"; | |||
| import SimpleMetaTagger from "./SimpleMetaTagger"; | ||||
| import {ExtraFunction} from "./ExtraFunction"; | ||||
| import {Relation} from "./Osm/ExtractRelations"; | ||||
| import FeatureSource from "./FeatureSource/FeatureSource"; | ||||
| import {UIEventSource} from "./UIEventSource"; | ||||
| 
 | ||||
| 
 | ||||
| interface Params { | ||||
|  | @ -23,7 +23,7 @@ export default class MetaTagging { | |||
|      * The features are a list of geojson-features, with a "properties"-field and geometry | ||||
|      */ | ||||
|     static addMetatags(features: { feature: any; freshness: Date }[], | ||||
|                        allKnownFeatures: FeatureSource, | ||||
|                        allKnownFeatures: UIEventSource<{ feature: any; freshness: Date }[]>, | ||||
|                        relations: Map<string, { role: string, relation: Relation }[]>, | ||||
|                        layers: LayerConfig[], | ||||
|                        includeDates = true) { | ||||
|  | @ -51,7 +51,7 @@ export default class MetaTagging { | |||
|             layerFuncs.set(layer.id, this.createRetaggingFunc(layer)); | ||||
|         } | ||||
| 
 | ||||
|         allKnownFeatures.features.addCallbackAndRun(newFeatures => { | ||||
|         allKnownFeatures.addCallbackAndRun(newFeatures => { | ||||
| 
 | ||||
|             const featuresPerLayer = new Map<string, any[]>(); | ||||
|             const allFeatures = Array.from(new Set(features.concat(newFeatures))) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue