forked from MapComplete/MapComplete
		
	Merge branch 'develop' into RobinLinde-patch-1
This commit is contained in:
		
						commit
						d3817eba85
					
				
					 200 changed files with 4310 additions and 4650 deletions
				
			
		|  | @ -205,7 +205,7 @@ function extractHintsFrom( | |||
|             layers: AllSharedLayers.sharedLayers, | ||||
|             themes: AllKnownLayouts.allKnownLayouts, | ||||
|             validators: Validators, | ||||
|             Constants: Constants | ||||
|             Constants: Constants, | ||||
|         }) | ||||
|     } | ||||
|     return hints | ||||
|  |  | |||
|  | @ -451,6 +451,9 @@ export default class GenerateImageAnalysis extends Script { | |||
|         args = args.filter((a) => a !== "--cached") | ||||
|         const datapath = args[1] ?? "../../git/MapComplete-data/ImageLicenseInfo" | ||||
|         const imageBackupPath = args[0] | ||||
|         if(imageBackupPath === "" || imageBackupPath === undefined){ | ||||
|             throw "No imageBackup path specified" | ||||
|         } | ||||
|         await this.downloadData(datapath, cached) | ||||
| 
 | ||||
|         // await this.downloadViews(datapath)
 | ||||
|  |  | |||
|  | @ -289,15 +289,21 @@ async function generateCsp( | |||
|         apiUrls.push(...(sv.needsUrls ?? [])) | ||||
|     }) | ||||
| 
 | ||||
|     const usedSpecialVisualisations = [].concat(...layoutJson.layers.map(l => ValidationUtils.getAllSpecialVisualisations(<QuestionableTagRenderingConfigJson[]> (<LayerConfigJson>l).tagRenderings ?? []))) | ||||
|     const usedSpecialVisualisations = [].concat( | ||||
|         ...layoutJson.layers.map((l) => | ||||
|             ValidationUtils.getAllSpecialVisualisations( | ||||
|                 <QuestionableTagRenderingConfigJson[]>(<LayerConfigJson>l).tagRenderings ?? [] | ||||
|             ) | ||||
|         ) | ||||
|     ) | ||||
|     for (const usedSpecialVisualisation of usedSpecialVisualisations) { | ||||
|         if (typeof usedSpecialVisualisation === "string") { | ||||
|             continue | ||||
|         } | ||||
|         const neededUrls = usedSpecialVisualisation.func.needsUrls ?? [] | ||||
|         if (typeof neededUrls === "function") { | ||||
|             let needed: string | string[]  = neededUrls(usedSpecialVisualisation.args) | ||||
|             if(typeof needed === "string"){ | ||||
|             let needed: string | string[] = neededUrls(usedSpecialVisualisation.args) | ||||
|             if (typeof needed === "string") { | ||||
|                 needed = [needed] | ||||
|             } | ||||
|             apiUrls.push(...needed) | ||||
|  | @ -317,8 +323,8 @@ async function generateCsp( | |||
|             continue | ||||
|         } | ||||
|         try { | ||||
|             if(!connectSource.startsWith("http")){ | ||||
|             connectSource = "https://"+connectSource | ||||
|             if (!connectSource.startsWith("http")) { | ||||
|                 connectSource = "https://" + connectSource | ||||
|             } | ||||
|             const url = new URL(connectSource) | ||||
|             hosts.add("https://" + url.host) | ||||
|  | @ -349,7 +355,7 @@ async function generateCsp( | |||
|         "default-src": "'self'", | ||||
|         "child-src": "'self' blob: ", | ||||
|         "img-src": "* data:", // maplibre depends on 'data:' to load
 | ||||
|         "connect-src": "'self' "+connectSrc.join(" "), | ||||
|         "connect-src": "'self' " + connectSrc.join(" "), | ||||
|         "report-to": "https://report.mapcomplete.org/csp", | ||||
|         "worker-src": "'self' blob:", // Vite somehow loads the worker via a 'blob'
 | ||||
|         "style-src": "'self' 'unsafe-inline'", // unsafe-inline is needed to change the default background pin colours
 | ||||
|  |  | |||
|  | @ -5,45 +5,60 @@ import { GeoOperations } from "../../src/Logic/GeoOperations" | |||
| import * as os from "os" | ||||
| // vite-node scripts/velopark/compare.ts -- scripts/velopark/velopark_all_2024-02-14T12\:18\:41.772Z.geojson ~/Projecten/OSM/Fietsberaad/2024-02-02\ Fietsenstallingen_OSM_met_velopark_ref.geojson
 | ||||
| class Compare extends Script { | ||||
| 
 | ||||
|     compare(veloId: string, osmParking: Feature, veloParking: Feature): {distance: number, ref: string, osmid: string, diffs: { | ||||
|         osm: string, velopark: string, key: string | ||||
|         }[] }{ | ||||
|     compare( | ||||
|         veloId: string, | ||||
|         osmParking: Feature, | ||||
|         veloParking: Feature | ||||
|     ): { | ||||
|         distance: number | ||||
|         ref: string | ||||
|         osmid: string | ||||
|         diffs: { | ||||
|             osm: string | ||||
|             velopark: string | ||||
|             key: string | ||||
|         }[] | ||||
|     } { | ||||
|         const osmCenterpoint = GeoOperations.centerpointCoordinates(osmParking) | ||||
|         const veloparkCenterpoint = GeoOperations.centerpointCoordinates(veloParking) | ||||
|         const distance = Math.round(GeoOperations.distanceBetween(osmCenterpoint, veloparkCenterpoint)) | ||||
|         const diffs: { osm: string, velopark: string, key: string}[] = [] | ||||
|         const distance = Math.round( | ||||
|             GeoOperations.distanceBetween(osmCenterpoint, veloparkCenterpoint) | ||||
|         ) | ||||
|         const diffs: { osm: string; velopark: string; key: string }[] = [] | ||||
| 
 | ||||
|         const allKeys = new Set<string>(Object.keys(osmParking.properties).concat(Object.keys(veloParking.properties))) | ||||
|         const allKeys = new Set<string>( | ||||
|             Object.keys(osmParking.properties).concat(Object.keys(veloParking.properties)) | ||||
|         ) | ||||
|         for (const key of allKeys) { | ||||
|             if(osmParking.properties[key] === veloParking.properties[key]){ | ||||
|             if (osmParking.properties[key] === veloParking.properties[key]) { | ||||
|                 continue | ||||
|             } | ||||
|             if(Number(osmParking.properties[key]) === veloParking.properties[key]){ | ||||
|             if (Number(osmParking.properties[key]) === veloParking.properties[key]) { | ||||
|                 continue | ||||
|             } | ||||
|             if(veloParking.properties[key] === undefined){ | ||||
|             if (veloParking.properties[key] === undefined) { | ||||
|                 continue | ||||
|             } | ||||
|             diffs.push({ | ||||
|                 key, | ||||
|                 osm: osmParking.properties[key], | ||||
|                 velopark: veloParking.properties[key] | ||||
|                 velopark: veloParking.properties[key], | ||||
|             }) | ||||
|         } | ||||
|         return { | ||||
|             ref: veloId, | ||||
|             osmid: osmParking.properties["@id"], | ||||
|             distance, diffs | ||||
|             distance, | ||||
|             diffs, | ||||
|         } | ||||
|     } | ||||
|     async main(args: string[]): Promise<void> { | ||||
|         let [velopark, osm, key] = args | ||||
|         key ??= "ref:velopark" | ||||
|         const veloparkData: FeatureCollection = JSON.parse(fs.readFileSync(velopark, "utf-8")) | ||||
|         const osmData : FeatureCollection = JSON.parse(fs.readFileSync(osm, "utf-8")) | ||||
|         const osmData: FeatureCollection = JSON.parse(fs.readFileSync(osm, "utf-8")) | ||||
| 
 | ||||
|         const veloparkById : Record<string, Feature> = {} | ||||
|         const veloparkById: Record<string, Feature> = {} | ||||
|         for (const parking of veloparkData.features) { | ||||
|             veloparkById[parking.properties[key]] = parking | ||||
|         } | ||||
|  | @ -52,21 +67,20 @@ class Compare extends Script { | |||
|         for (const parking of osmData.features) { | ||||
|             const veloId = parking.properties[key] | ||||
|             const veloparking = veloparkById[veloId] | ||||
|             if(veloparking === undefined){ | ||||
|             if (veloparking === undefined) { | ||||
|                 console.error("No velopark entry found for", veloId) | ||||
|                 continue | ||||
|             } | ||||
|            diffs.push(this.compare(veloId, parking, veloparking)) | ||||
|             diffs.push(this.compare(veloId, parking, veloparking)) | ||||
|         } | ||||
| 
 | ||||
|         fs.writeFileSync("report_diff.json",JSON.stringify(diffs)) | ||||
| 
 | ||||
| 
 | ||||
|         fs.writeFileSync("report_diff.json", JSON.stringify(diffs)) | ||||
|     } | ||||
|     constructor() { | ||||
|         super("Compares a velopark geojson with OSM geojson. Usage: `compare velopark.geojson osm.geojson [key-to-compare-on]`. If key-to-compare-on is not given, `ref:velopark` will be used") | ||||
|         super( | ||||
|             "Compares a velopark geojson with OSM geojson. Usage: `compare velopark.geojson osm.geojson [key-to-compare-on]`. If key-to-compare-on is not given, `ref:velopark` will be used" | ||||
|         ) | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| new Compare().run() | ||||
|  |  | |||
|  | @ -15,9 +15,9 @@ class VeloParkToGeojson extends Script { | |||
|         ) | ||||
|     } | ||||
| 
 | ||||
|     exportTo(filename: string, features){ | ||||
|     exportTo(filename: string, features) { | ||||
|         fs.writeFileSync( | ||||
|             filename+"_" + new Date().toISOString() + ".geojson", | ||||
|             filename + "_" + new Date().toISOString() + ".geojson", | ||||
|             JSON.stringify( | ||||
|                 { | ||||
|                     type: "FeatureCollection", | ||||
|  | @ -60,7 +60,7 @@ class VeloParkToGeojson extends Script { | |||
|         for (const feature of features) { | ||||
|             Object.keys(feature.properties).forEach((k) => allProperties.add(k)) | ||||
|         } | ||||
|         this.exportTo("velopark_noncynced",features) | ||||
|         this.exportTo("velopark_noncynced", features) | ||||
|         allProperties.delete("ref:velopark") | ||||
|         for (const feature of features) { | ||||
|             allProperties.forEach((k) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue