forked from MapComplete/MapComplete
Fix metatagging and calculated tags in heterogenous data settings
This commit is contained in:
parent
93296d5378
commit
d547b9f968
14 changed files with 374 additions and 246 deletions
|
@ -6,28 +6,38 @@ import MetaTagging from "../MetaTagging";
|
|||
import ExtractRelations from "../Osm/ExtractRelations";
|
||||
|
||||
export default class MetaTaggingFeatureSource implements FeatureSource {
|
||||
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{feature: any; freshness: Date}[]>(undefined);
|
||||
|
||||
public readonly name;
|
||||
|
||||
constructor(source: FeatureSource) {
|
||||
const self = this;
|
||||
this.name = "MetaTagging of "+source.name
|
||||
source.features.addCallbackAndRun((featuresFreshness: { feature: any, freshness: Date }[]) => {
|
||||
if (featuresFreshness === undefined) {
|
||||
return;
|
||||
}
|
||||
featuresFreshness.forEach(featureFresh => {
|
||||
const feature = featureFresh.feature;
|
||||
|
||||
if (Hash.hash.data === feature.properties.id) {
|
||||
State.state.selectedElement.setData(feature);
|
||||
}
|
||||
})
|
||||
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>(undefined);
|
||||
|
||||
MetaTagging.addMetatags(featuresFreshness, State.state.knownRelations.data, State.state.layoutToUse.data.layers);
|
||||
self.features.setData(featuresFreshness);
|
||||
});
|
||||
public readonly name;
|
||||
|
||||
constructor(allFeaturesSource: FeatureSource, source: FeatureSource, updateTrigger?: UIEventSource<any>) {
|
||||
const self = this;
|
||||
this.name = "MetaTagging of " + source.name
|
||||
|
||||
function update() {
|
||||
const featuresFreshness = source.features.data
|
||||
if (featuresFreshness === undefined) {
|
||||
return;
|
||||
}
|
||||
featuresFreshness.forEach(featureFresh => {
|
||||
const feature = featureFresh.feature;
|
||||
|
||||
if (Hash.hash.data === feature.properties.id) {
|
||||
State.state.selectedElement.setData(feature);
|
||||
}
|
||||
})
|
||||
|
||||
MetaTagging.addMetatags(featuresFreshness,
|
||||
allFeaturesSource,
|
||||
State.state.knownRelations.data, State.state.layoutToUse.data.layers);
|
||||
self.features.setData(featuresFreshness);
|
||||
}
|
||||
|
||||
source.features.addCallbackAndRun(_ => update());
|
||||
updateTrigger?.addCallback(_ => {
|
||||
console.debug("Updating because of external call")
|
||||
update();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue