Fixing adding multiple points

This commit is contained in:
pietervdvn 2021-01-04 22:59:11 +01:00
parent 32bc1433b4
commit baf41cb79d
6 changed files with 20 additions and 25 deletions

View file

@ -419,7 +419,6 @@ export class InitUiElements {
State.state.allElements.addElement(feature); State.state.allElements.addElement(feature);
}) })
MetaTagging.addMetatags(features); MetaTagging.addMetatags(features);
console.log("ALL FEATURES", features);
}) })
new ShowDataLayer(source.features, State.state.leafletMap, new ShowDataLayer(source.features, State.state.leafletMap,

View file

@ -13,27 +13,18 @@ export default class FeatureDuplicatorPerLayer implements FeatureSource {
constructor(layers: { layerDef: LayerConfig }[], upstream: FeatureSource) { constructor(layers: { layerDef: LayerConfig }[], upstream: FeatureSource) {
let noPassthroughts = true;
for (const layer of layers) {
if (layer.layerDef.passAllFeatures) {
noPassthroughts = false;
break;
}
}
this.features = upstream.features.map(features => { this.features = upstream.features.map(features => {
const newFeatures: { feature: any, freshness: Date }[] = []; const newFeatures: { feature: any, freshness: Date }[] = [];
if(features === undefined){ if(features === undefined){
return newFeatures; return newFeatures;
} }
for (const f of features) { for (const f of features) {
if (f.feature._matching_layer_id) { if (f.feature._matching_layer_id) {
// Already matched previously // Already matched previously
// We simply add it // We simply add it
newFeatures.push(f); newFeatures.push(f);
return; continue;
} }

View file

@ -17,6 +17,9 @@ export default class FeatureSourceMerger implements FeatureSource {
private Update() { private Update() {
let all = {}; // Mapping 'id' -> {feature, freshness} let all = {}; // Mapping 'id' -> {feature, freshness}
for (const source of this._sources) { for (const source of this._sources) {
if(source?.features?.data === undefined){
continue;
}
for (const f of source.features.data) { for (const f of source.features.data) {
const id = f.feature.properties.id+f.feature.geometry.type+f.feature._matching_layer_id; const id = f.feature.properties.id+f.feature.geometry.type+f.feature._matching_layer_id;
const oldV = all[id]; const oldV = all[id];

View file

@ -4,20 +4,23 @@
import FeatureSource from "./FeatureSource"; import FeatureSource from "./FeatureSource";
import {UIEventSource} from "../UIEventSource"; import {UIEventSource} from "../UIEventSource";
export default class RememberingSource implements FeatureSource{ export default class RememberingSource implements FeatureSource {
features: UIEventSource<{feature: any, freshness: Date}[]> = new UIEventSource<{feature: any, freshness: Date}[]>([]); features: UIEventSource<{ feature: any, freshness: Date }[]>;
constructor(source: FeatureSource) { constructor(source: FeatureSource) {
const self = this; const self = this;
source.features.addCallbackAndRun(features => { const empty = [];
if(features === undefined){ this.features = source.features.map(features => {
return; const oldFeatures = self.features?.data ?? empty;
if (features === undefined) {
return oldFeatures;
} }
const ids = new Set<string>( features.map(f => f.feature.properties.id+f.feature.geometry.type));
const newList = features.concat( // Then new ids
self.features.data.filter(old => !ids.has(old.feature.properties.id+old.feature.geometry.type)) const ids = new Set<string>(features.map(f => f.feature.properties.id + f.feature.geometry.type));
) // the old data
self.features.setData(newList); const oldData = oldFeatures.filter(old => !ids.has(old.feature.properties.id + old.feature.geometry.type))
return [...features, ...oldData];
}) })
} }

View file

@ -1,7 +1,7 @@
import { Utils } from "../Utils"; import { Utils } from "../Utils";
export default class Constants { export default class Constants {
public static vNumber = "0.2.7-rc3"; public static vNumber = "0.2.7-rc4";
// The user journey states thresholds when a new feature gets unlocked // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -32,7 +32,6 @@ export default class ShowDataLayer {
} }
function update() { function update() {
console.log("UPDATING!")
if (features.data === undefined) { if (features.data === undefined) {
return; return;
} }