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);
})
MetaTagging.addMetatags(features);
console.log("ALL FEATURES", features);
})
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) {
let noPassthroughts = true;
for (const layer of layers) {
if (layer.layerDef.passAllFeatures) {
noPassthroughts = false;
break;
}
}
this.features = upstream.features.map(features => {
const newFeatures: { feature: any, freshness: Date }[] = [];
if(features === undefined){
return newFeatures;
}
for (const f of features) {
if (f.feature._matching_layer_id) {
// Already matched previously
// We simply add it
newFeatures.push(f);
return;
continue;
}

View file

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

View file

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

View file

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