forked from MapComplete/MapComplete
		
	Small fixes
This commit is contained in:
		
							parent
							
								
									092a627b64
								
							
						
					
					
						commit
						95f421a6ae
					
				
					 5 changed files with 17 additions and 9 deletions
				
			
		|  | @ -110,7 +110,7 @@ Some advanced functions are available on <b>feat</b> as well: | |||
|                 let closestFeature = undefined; | ||||
|                 let closestDistance = undefined; | ||||
|                 for (const otherFeature of features) { | ||||
|                     if (otherFeature == feature) { | ||||
|                     if (otherFeature == feature || otherFeature.id == feature.id) { | ||||
|                         continue; // We ignore self
 | ||||
|                     } | ||||
|                     let distance = undefined; | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ import SimpleMetaTagger from "./SimpleMetaTagger"; | |||
| import {ExtraFunction} from "./ExtraFunction"; | ||||
| import {Relation} from "./Osm/ExtractRelations"; | ||||
| import FeatureSource from "./FeatureSource/FeatureSource"; | ||||
| import State from "../State"; | ||||
| 
 | ||||
| 
 | ||||
| interface Params { | ||||
|  | @ -48,7 +49,7 @@ export default class MetaTagging { | |||
|         } | ||||
| 
 | ||||
|         const featuresPerLayer = new Map<string, any[]>(); | ||||
|         for (const feature of features) { | ||||
|         for (const feature of (allKnownFeatures.features?.data ?? features ?? [])) { | ||||
| 
 | ||||
|             const key = feature.feature._matching_layer_id; | ||||
|             if (!featuresPerLayer.has(key)) { | ||||
|  | @ -57,13 +58,14 @@ export default class MetaTagging { | |||
|             featuresPerLayer.get(key).push(feature.feature) | ||||
|         } | ||||
| 
 | ||||
|         for (const feature of (allKnownFeatures.features?.data ?? features ?? [])) { | ||||
|         for (const feature of features) { | ||||
|             // @ts-ignore
 | ||||
|             const key = feature.feature._matching_layer_id; | ||||
|             const f = layerFuncs.get(key); | ||||
|             if (f === undefined) { | ||||
|                 continue; | ||||
|             } | ||||
|             | ||||
|             try { | ||||
|                 f({featuresPerLayer: featuresPerLayer, memberships: relations}, feature.feature) | ||||
|             } catch (e) { | ||||
|  | @ -72,6 +74,7 @@ export default class MetaTagging { | |||
| 
 | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -97,10 +100,10 @@ export default class MetaTagging { | |||
|                 const f = (featuresPerLayer, feature: any) => { | ||||
|                     try { | ||||
|                         let result = func(feature); | ||||
|                         if(result === undefined || result === ""){ | ||||
|                         if (result === undefined || result === "") { | ||||
|                             return; | ||||
|                         } | ||||
|                         if(typeof result !== "string"){ | ||||
|                         if (typeof result !== "string") { | ||||
|                             // Make sure it is a string!
 | ||||
|                             result = "" + result; | ||||
|                         } | ||||
|  |  | |||
							
								
								
									
										2
									
								
								index.ts
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								index.ts
									
										
									
									
									
								
							|  | @ -106,6 +106,8 @@ if (layoutFromBase64.startsWith("http")) { | |||
|                 let parsed = data; | ||||
|                 if (typeof parsed == "string") { | ||||
|                     parsed = JSON.parse(data); | ||||
|                 }else{ | ||||
|                     data = JSON.stringify(parsed) // De wereld op zijn kop
 | ||||
|                 } | ||||
|                 // Overwrite the id to the wiki:value
 | ||||
|                 parsed.id = link; | ||||
|  |  | |||
|  | @ -4,15 +4,18 @@ import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson"; | |||
| import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson"; | ||||
| 
 | ||||
| export default class ScriptUtils { | ||||
|     public static readDirRecSync(path): string[] { | ||||
|     public static readDirRecSync(path, maxDepth = 999): string[] { | ||||
|         const result = [] | ||||
|         if(maxDepth <= 0){ | ||||
|             return [] | ||||
|         } | ||||
|         for (const entry of readdirSync(path)) { | ||||
|             const fullEntry = path + "/" + entry | ||||
|             const stats = lstatSync(fullEntry) | ||||
|             if (stats.isDirectory()) { | ||||
|                 // Subdirectory
 | ||||
|                 // @ts-ignore
 | ||||
|                 result.push(...ScriptUtils.readDirRecSync(fullEntry)) | ||||
|                 result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1)) | ||||
|             } else { | ||||
|                 result.push(fullEntry) | ||||
|             } | ||||
|  |  | |||
|  | @ -165,7 +165,7 @@ function genTranslations() { | |||
| 
 | ||||
| // Read 'lang/*.json', writes to 'assets/generated/translations.json'
 | ||||
| function compileTranslationsFromWeblate() { | ||||
|     const translations = ScriptUtils.readDirRecSync("./langs") | ||||
|     const translations = ScriptUtils.readDirRecSync("./langs", 1) | ||||
|         .filter(path => path.indexOf(".json") > 0) | ||||
| 
 | ||||
|     const allTranslations = new TranslationPart() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue