Merge develop
This commit is contained in:
commit
7c5170da15
193 changed files with 4011 additions and 4462 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)
|
||||
|
|
|
@ -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