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