Merge branch 'develop' into theme/infrastructure

This commit is contained in:
Robin van der Linde 2025-07-27 22:26:24 +02:00
commit bbd7135157
66 changed files with 1961 additions and 798 deletions

View file

@ -96,7 +96,7 @@ class HandleErrors extends Script {
" is identical to previously seen changeset, not writing to file"
)*/
} else {
const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.layout}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.theme}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
${changeset}`
writeFileSync(path, changesetWithMsg, "utf8")
createdChangesets.add(changeset)
@ -115,14 +115,13 @@ ${changeset}`
console.log("Written refused", path)
}
}
private readonly osmConnection = new OsmConnection()
private readonly downloader = new OsmObjectDownloader(this.osmConnection.Backend(), undefined)
async main(args: string[]): Promise<void> {
const osmConnection = new OsmConnection()
const downloader = new OsmObjectDownloader(osmConnection.Backend(), undefined)
const path = args[0]
async fixForFile(path: string){
const lines = readFileSync(path, "utf8").split("\n")
const osmConnection = this.osmConnection
const downloader = this.downloader
const createdChangesets = new Set<string>()
const refusedFiles: Set<string> = new Set<string>()
refusedFiles.add("[]")
@ -143,7 +142,7 @@ ${changeset}`
try {
const parsed: ErrorMessage = JSON.parse(line)
const e = parsed.message
if (e.layout === "grb") {
if (e.theme === "grb") {
console.log("Skipping GRB ")
continue
}
@ -182,6 +181,18 @@ ${changeset}`
}
}
}
async main(args: string[]): Promise<void> {
if(args[0] === undefined){
console.log("Please specify the error file to handle")
return
}
for (const path of args) {
await this.fixForFile(path)
}
}
}
new HandleErrors().run()

View file

@ -0,0 +1,58 @@
import { readFileSync, writeFileSync } from "fs"
import Script from "../Script"
import { parse } from "papaparse"
import { FeatureCollection, Point } from "geojson"
class ZHVcsv2GeoJson extends Script {
constructor() {
super("Converts a CSV file with ZHV data to GeoJSON format. Usage: csv-file output-file")
}
async main(args: string[]): Promise<void> {
const csvFile = args[0]
const outputFile = args[1]
if (!csvFile || !outputFile) {
console.error("Usage: csv-file output-file")
return
}
// Read the CSV file and parse it using PapaParse
const text = readFileSync(csvFile, "utf-8")
const parsed = parse(text, {
header: true,
dynamicTyping: false,
})
console.log(`Parsed ${parsed.data.length} rows from ${csvFile}`)
console.log(`First row:`, parsed.data[0])
// Drop all rows that do not have a valid latitude and longitude
parsed.data = parsed.data.filter((row: any) => {
return row["Latitude"] && row["Longitude"]
})
// Convert the parsed data to GeoJSON format
const geoJson: FeatureCollection<Point> = {
type: "FeatureCollection",
features: parsed.data.map((row: any) => ({
type: "Feature",
geometry: {
type: "Point",
coordinates: [
parseFloat(row["Longitude"].replace(",", ".")),
parseFloat(row["Latitude"].replace(",", ".")),
],
},
properties: row,
})),
}
console.log(`First feature:`, geoJson.features[0])
// Write the GeoJSON output to the specified file
writeFileSync(outputFile, JSON.stringify(geoJson), "utf-8")
}
}
new ZHVcsv2GeoJson().run()