diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index 0e1cc607f..2235c87bf 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -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, selectedElement: UIEventSource) { + 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; } } \ No newline at end of file diff --git a/Logic/FeatureSource/MetaTaggingFeatureSource.ts b/Logic/FeatureSource/MetaTaggingFeatureSource.ts index 726f4d606..3ee9efc9f 100644 --- a/Logic/FeatureSource/MetaTaggingFeatureSource.ts +++ b/Logic/FeatureSource/MetaTaggingFeatureSource.ts @@ -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) { + constructor(allFeaturesSource: UIEventSource<{ feature: any; freshness: Date }[]>, source: FeatureSource, updateTrigger?: UIEventSource) { 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() { diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 052cb30ee..86de5d25f 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -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, 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(); const allFeatures = Array.from(new Set(features.concat(newFeatures)))