forked from MapComplete/MapComplete
Small tweaks, better handling in case all goes wrong
This commit is contained in:
parent
4d5a786e10
commit
127ad9c947
2 changed files with 19 additions and 10 deletions
|
@ -15,16 +15,21 @@ public readonly name = "FilteringFeatureSource"
|
|||
|
||||
const self = this;
|
||||
|
||||
console.log("INITING pipeline: ",layers)
|
||||
|
||||
function update() {
|
||||
|
||||
const layerDict = {};
|
||||
if(layers.data.length == 0){
|
||||
throw "No layers defined!"
|
||||
}
|
||||
for (const layer of layers.data) {
|
||||
layerDict[layer.layerDef.id] = layer;
|
||||
}
|
||||
|
||||
const features: { feature: any, freshness: Date }[] = upstream.features.data;
|
||||
|
||||
const missingLayers = new Set<string>();
|
||||
|
||||
const newFeatures = features.filter(f => {
|
||||
const layerId = f.feature._matching_layer_id;
|
||||
|
@ -35,7 +40,7 @@ public readonly name = "FilteringFeatureSource"
|
|||
layerDef: LayerConfig
|
||||
} = layerDict[layerId];
|
||||
if (layer === undefined) {
|
||||
console.error("No layer found with id ", layerId);
|
||||
missingLayers.add(layerId)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,6 +70,9 @@ public readonly name = "FilteringFeatureSource"
|
|||
|
||||
});
|
||||
self.features.setData(newFeatures);
|
||||
if(missingLayers.size > 0){
|
||||
console.error("Some layers were not found: ", Array.from(missingLayers))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue