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