Better handling of metadata when the data is reloaded, remove unneeded console logging

This commit is contained in:
Pieter Vander Vennet 2021-06-21 03:13:49 +02:00
parent d4909734a1
commit 116371c351
2 changed files with 14 additions and 6 deletions

View file

@ -27,6 +27,10 @@ export default class MetaTagging {
relations: Map<string, { role: string, relation: Relation }[]>,
layers: LayerConfig[],
includeDates = true) {
if(features === undefined || features.length === 0){
return;
}
for (const metatag of SimpleMetaTagger.metatags) {
if (metatag.includesDates && !includeDates) {
@ -49,10 +53,9 @@ export default class MetaTagging {
allKnownFeatures.features.addCallbackAndRun(newFeatures => {
const featuresPerLayer = new Map<string, any[]>();
for (const feature of (newFeatures.concat(features))) {
const allFeatures = Array.from(new Set(features.concat(newFeatures)))
for (const feature of allFeatures) {
const key = feature.feature._matching_layer_id;
if (!featuresPerLayer.has(key)) {
@ -87,6 +90,7 @@ export default class MetaTagging {
}
private static errorPrintCount = 0;
private static createRetaggingFunc(layer: LayerConfig):
((params: Params, feature: any) => void) {
@ -119,7 +123,13 @@ export default class MetaTagging {
}
feature.properties[key] = result;
} catch (e) {
console.error("Could not calculate a metatag defined by " + code + " due to " + e + ". This is code defined in the theme. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e)
if(MetaTagging. errorPrintCount < 50){
console.error("Could not calculate a metatag defined by " + code + " due to " + e + ". This is code defined in the theme. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e)
MetaTagging. errorPrintCount ++;
if(MetaTagging. errorPrintCount == 50){
console.error("Got 50 errors calculating this metatagging - stopping output now")
}
}
}
}

View file

@ -363,8 +363,6 @@ export class OsmWay extends OsmObject {
let latSum = 0
let lonSum = 0
console.log("element is", element, "nodes are", allNodes)
const nodeDict = new Map<number, OsmNode>()
for (const node of allNodes) {
nodeDict.set(node.id, node)