forked from MapComplete/MapComplete
Add better relation support
This commit is contained in:
parent
7b47af8978
commit
12afdcab75
18 changed files with 2637 additions and 2386 deletions
|
@ -12,6 +12,7 @@ import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
|
|||
import Loc from "../../Models/Loc";
|
||||
import GeoJsonSource from "./GeoJsonSource";
|
||||
import MetaTaggingFeatureSource from "./MetaTaggingFeatureSource";
|
||||
import RegisteringFeatureSource from "./RegisteringFeatureSource";
|
||||
|
||||
export default class FeaturePipeline implements FeatureSource {
|
||||
|
||||
|
@ -24,33 +25,38 @@ export default class FeaturePipeline implements FeatureSource {
|
|||
locationControl: UIEventSource<Loc>) {
|
||||
|
||||
const amendedOverpassSource =
|
||||
new RememberingSource(new FeatureDuplicatorPerLayer(flayers,
|
||||
new LocalStorageSaver(updater, layout))
|
||||
);
|
||||
new RememberingSource(
|
||||
new LocalStorageSaver(
|
||||
new MetaTaggingFeatureSource( // first we metatag, then we save to get the metatags into storage too
|
||||
new RegisteringFeatureSource(
|
||||
new FeatureDuplicatorPerLayer(flayers,
|
||||
updater)
|
||||
)), layout));
|
||||
|
||||
const geojsonSources: GeoJsonSource [] = []
|
||||
for (const flayer of flayers.data) {
|
||||
const sourceUrl = flayer.layerDef.source.geojsonSource
|
||||
if (sourceUrl !== undefined) {
|
||||
geojsonSources.push(
|
||||
new GeoJsonSource(flayer.layerDef.id, sourceUrl))
|
||||
geojsonSources.push(new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers,
|
||||
new GeoJsonSource(flayer.layerDef.id, sourceUrl))))
|
||||
}
|
||||
}
|
||||
|
||||
const amendedLocalStorageSource =
|
||||
new RememberingSource(new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout))
|
||||
);
|
||||
new RememberingSource(new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout))
|
||||
));
|
||||
|
||||
newPoints = new FeatureDuplicatorPerLayer(flayers, newPoints);
|
||||
newPoints = new MetaTaggingFeatureSource(new FeatureDuplicatorPerLayer(flayers,
|
||||
new RegisteringFeatureSource(newPoints)));
|
||||
|
||||
const merged =
|
||||
new MetaTaggingFeatureSource(
|
||||
new FeatureSourceMerger([
|
||||
amendedOverpassSource,
|
||||
amendedLocalStorageSource,
|
||||
newPoints,
|
||||
...geojsonSources
|
||||
]));
|
||||
|
||||
new FeatureSourceMerger([
|
||||
amendedOverpassSource,
|
||||
amendedLocalStorageSource,
|
||||
newPoints,
|
||||
...geojsonSources
|
||||
]);
|
||||
|
||||
const source =
|
||||
new WayHandlingApplyingFeatureSource(flayers,
|
||||
|
|
|
@ -16,10 +16,6 @@ export default class MetaTaggingFeatureSource implements FeatureSource {
|
|||
featuresFreshness.forEach(featureFresh => {
|
||||
const feature = featureFresh.feature;
|
||||
|
||||
if(!State.state.allElements.has(feature.properties.id)){
|
||||
State.state.allElements.addOrGetElement(feature)
|
||||
}
|
||||
|
||||
if (Hash.hash.data === feature.properties.id) {
|
||||
State.state.selectedElement.setData(feature);
|
||||
}
|
||||
|
|
19
Logic/FeatureSource/RegisteringFeatureSource.ts
Normal file
19
Logic/FeatureSource/RegisteringFeatureSource.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import FeatureSource from "./FeatureSource";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import State from "../../State";
|
||||
|
||||
export default class RegisteringFeatureSource implements FeatureSource {
|
||||
features: UIEventSource<{ feature: any; freshness: Date }[]>;
|
||||
|
||||
constructor(source: FeatureSource) {
|
||||
this.features = source.features;
|
||||
this.features.addCallbackAndRun(features => {
|
||||
for (const feature of features ?? []) {
|
||||
if (!State.state.allElements.has(feature.feature.properties.id)) {
|
||||
State.state.allElements.addOrGetElement(feature.feature)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue