forked from MapComplete/MapComplete
		
	Fix metatagging
This commit is contained in:
		
							parent
							
								
									923dafe5d0
								
							
						
					
					
						commit
						05e0986a51
					
				
					 2 changed files with 5 additions and 6 deletions
				
			
		| 
						 | 
					@ -45,6 +45,7 @@ class OverlapFunc implements ExtraFunction {
 | 
				
			||||||
        return (...layerIds: string[]) => {
 | 
					        return (...layerIds: string[]) => {
 | 
				
			||||||
            const result: { feat: any, overlap: number }[] = []
 | 
					            const result: { feat: any, overlap: number }[] = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            console.log("Calculating overlap")
 | 
				
			||||||
            const bbox = BBox.get(feat)
 | 
					            const bbox = BBox.get(feat)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (const layerId of layerIds) {
 | 
					            for (const layerId of layerIds) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,7 +117,6 @@ export default class MetaTagging {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const calculateAndAssign: ((feat: any) => boolean) = (feat) => {
 | 
					            const calculateAndAssign: ((feat: any) => boolean) = (feat) => {
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    let oldValue = isStrict ? feat.properties[key] : undefined
 | 
					 | 
				
			||||||
                    let result = new Function("feat", "return " + code + ";")(feat);
 | 
					                    let result = new Function("feat", "return " + code + ";")(feat);
 | 
				
			||||||
                    if (result === "") {
 | 
					                    if (result === "") {
 | 
				
			||||||
                        result === undefined
 | 
					                        result === undefined
 | 
				
			||||||
| 
						 | 
					@ -128,7 +127,7 @@ export default class MetaTagging {
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    delete feat.properties[key]
 | 
					                    delete feat.properties[key]
 | 
				
			||||||
                    feat.properties[key] = result;
 | 
					                    feat.properties[key] = result;
 | 
				
			||||||
                    return result === oldValue;
 | 
					                    return result;
 | 
				
			||||||
                }catch(e){
 | 
					                }catch(e){
 | 
				
			||||||
                    if (MetaTagging.errorPrintCount < MetaTagging.stopErrorOutputAt) {
 | 
					                    if (MetaTagging.errorPrintCount < MetaTagging.stopErrorOutputAt) {
 | 
				
			||||||
                        console.warn("Could not calculate a " + (isStrict ? "strict " : "") + " calculated tag for key " + key + " defined by " + code + " (in layer" + layerId + ") due to \n" + e + "\n. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e, e.stack)
 | 
					                        console.warn("Could not calculate a " + (isStrict ? "strict " : "") + " calculated tag for key " + key + " defined by " + code + " (in layer" + layerId + ") due to \n" + e + "\n. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e, e.stack)
 | 
				
			||||||
| 
						 | 
					@ -137,7 +136,7 @@ export default class MetaTagging {
 | 
				
			||||||
                            console.error("Got ", MetaTagging.stopErrorOutputAt, " errors calculating this metatagging - stopping output now")
 | 
					                            console.error("Got ", MetaTagging.stopErrorOutputAt, " errors calculating this metatagging - stopping output now")
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return false;
 | 
					                    return undefined;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } 
 | 
					            } 
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
| 
						 | 
					@ -154,11 +153,10 @@ export default class MetaTagging {
 | 
				
			||||||
                    configurable: true,
 | 
					                    configurable: true,
 | 
				
			||||||
                    enumerable: false, // By setting this as not enumerable, the localTileSaver will _not_ calculate this
 | 
					                    enumerable: false, // By setting this as not enumerable, the localTileSaver will _not_ calculate this
 | 
				
			||||||
                    get: function () {
 | 
					                    get: function () {
 | 
				
			||||||
                        calculateAndAssign(feature)
 | 
					                        return calculateAndAssign(feature)
 | 
				
			||||||
                        return feature.properties[key]
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                return true
 | 
					                return undefined
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue