diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index 0878975f3..0e1cc607f 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 }[]>; + public features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{feature: any; freshness: Date}[]>([]); public readonly name = "FeaturePipeline" @@ -83,7 +83,8 @@ export default class FeaturePipeline implements FeatureSource { selectedElement, merged )); - this.features = source.features; + + source.features.syncWith(this.features) } } \ No newline at end of file diff --git a/Logic/FeatureSource/MetaTaggingFeatureSource.ts b/Logic/FeatureSource/MetaTaggingFeatureSource.ts index e269977ab..d6602069a 100644 --- a/Logic/FeatureSource/MetaTaggingFeatureSource.ts +++ b/Logic/FeatureSource/MetaTaggingFeatureSource.ts @@ -4,6 +4,7 @@ import State from "../../State"; import Hash from "../Web/Hash"; import MetaTagging from "../MetaTagging"; import ExtractRelations from "../Osm/ExtractRelations"; +import FeatureSourceMerger from "./FeatureSourceMerger"; export default class MetaTaggingFeatureSource implements FeatureSource { public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>(undefined); @@ -14,6 +15,10 @@ export default class MetaTaggingFeatureSource implements FeatureSource { const self = this; this.name = "MetaTagging of " + source.name + if(allFeaturesSource.features === undefined){ + throw ("Initialize the featuresource fully first!"+allFeaturesSource.name) + } + function update() { const featuresFreshness = source.features.data if (featuresFreshness === undefined) { diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 635e72166..ee13c3c10 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -3,7 +3,6 @@ import SimpleMetaTagger from "./SimpleMetaTagger"; import {ExtraFunction} from "./ExtraFunction"; import {Relation} from "./Osm/ExtractRelations"; import FeatureSource from "./FeatureSource/FeatureSource"; -import State from "../State"; interface Params { @@ -48,32 +47,43 @@ export default class MetaTagging { layerFuncs.set(layer.id, this.createRetaggingFunc(layer)); } - const featuresPerLayer = new Map(); - for (const feature of (allKnownFeatures.features?.data ?? features ?? [])) { + allKnownFeatures.features.addCallbackAndRun(newFeatures => { - const key = feature.feature._matching_layer_id; - if (!featuresPerLayer.has(key)) { - featuresPerLayer.set(key, []) - } - featuresPerLayer.get(key).push(feature.feature) - } - for (const feature of features) { - // @ts-ignore - const key = feature.feature._matching_layer_id; - const f = layerFuncs.get(key); - if (f === undefined) { - continue; - } - - try { - f({featuresPerLayer: featuresPerLayer, memberships: relations}, feature.feature) - } catch (e) { - console.error(e) + + const featuresPerLayer = new Map(); + for (const feature of (newFeatures.concat(features))) { + + const key = feature.feature._matching_layer_id; + if (!featuresPerLayer.has(key)) { + featuresPerLayer.set(key, []) + } + featuresPerLayer.get(key).push(feature.feature) } - } + for (const feature of features) { + // @ts-ignore + const key = feature.feature._matching_layer_id; + const f = layerFuncs.get(key); + if (f === undefined) { + continue; + } + try { + f({featuresPerLayer: featuresPerLayer, memberships: relations}, feature.feature) + } catch (e) { + console.error(e) + } + + } + + + + + + + }) + } @@ -105,7 +115,7 @@ export default class MetaTagging { } if (typeof result !== "string") { // Make sure it is a string! - result = "" + result; + result = JSON.stringify(result); } feature.properties[key] = result; } catch (e) {