mapcomplete/Logic/FeatureSource/FeaturePipeline.ts

56 lines
2.3 KiB
TypeScript
Raw Normal View History

import FilteringFeatureSource from "../FeatureSource/FilteringFeatureSource";
import FeatureSourceMerger from "../FeatureSource/FeatureSourceMerger";
import RememberingSource from "../FeatureSource/RememberingSource";
import WayHandlingApplyingFeatureSource from "../FeatureSource/WayHandlingApplyingFeatureSource";
import NoOverlapSource from "../FeatureSource/NoOverlapSource";
import FeatureDuplicatorPerLayer from "../FeatureSource/FeatureDuplicatorPerLayer";
import FeatureSource from "../FeatureSource/FeatureSource";
import {UIEventSource} from "../UIEventSource";
import LocalStorageSaver from "./LocalStorageSaver";
import LayerConfig from "../../Customizations/JSON/LayerConfig";
import LocalStorageSource from "./LocalStorageSource";
import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
2021-02-14 19:45:02 +01:00
import Loc from "../../Models/Loc";
export default class FeaturePipeline implements FeatureSource {
public features: UIEventSource<{ feature: any; freshness: Date }[]>;
constructor(flayers: UIEventSource<{ isDisplayed: UIEventSource<boolean>, layerDef: LayerConfig }[]>,
updater: FeatureSource,
2021-02-14 19:45:02 +01:00
layout: UIEventSource<LayoutConfig>,
newPoints: FeatureSource,
locationControl: UIEventSource<Loc>) {
const amendedOverpassSource =
new RememberingSource(
new WayHandlingApplyingFeatureSource(flayers,
new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers,
new LocalStorageSaver(updater, layout)))
)
);
const amendedLocalStorageSource =
new RememberingSource(
new WayHandlingApplyingFeatureSource(flayers,
new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout)))
));
2021-02-14 19:45:02 +01:00
newPoints = new FeatureDuplicatorPerLayer(flayers, newPoints);
const merged = new FeatureSourceMerger([
amendedOverpassSource,
2021-02-14 19:45:02 +01:00
amendedLocalStorageSource,
newPoints
]);
2021-02-14 19:45:02 +01:00
const source =
new FilteringFeatureSource(
flayers,
2021-02-14 19:45:02 +01:00
locationControl,
merged
);
this.features = source.features;
}
}