Merge master

This commit is contained in:
Pieter Vander Vennet 2021-08-24 12:24:11 +02:00
commit 12323739f1
122 changed files with 388561 additions and 4931 deletions

View file

@ -0,0 +1,21 @@
import ScriptUtils from "./ScriptUtils";
ScriptUtils.fixUtils()
import {appendFileSync, readFileSync, writeFileSync} from "fs";
import {OsmObject} from "../Logic/Osm/OsmObject";
ScriptUtils.erasableLog("Fixing the cycle highways...")
writeFileSync("cycleHighwayFix.osc","<osmChange version=\"0.6\" generator=\"Handmade\" copyright=\"OpenStreetMap and Contributors\"\n" +
" attribution=\"http://www.openstreetmap.org/copyright\" license=\"http://opendatacommons.org/licenses/odbl/1-0/\">\n" +
" <modify>", "utf8")
const ids = JSON.parse(readFileSync("export.geojson","utf-8")).features.map(f => f.properties["@id"])
console.log(ids)
ids.map(id => OsmObject.DownloadReferencingRelations(id).addCallbackAndRunD(relations => {
console.log(relations)
const changeparts = relations.filter(relation => relation.tags["cycle_highway"] == "yes" && relation.tags["note:state"] == undefined)
.map(relation => {
relation.tags["note:state"]="has_highway_under_construction";
return relation.ChangesetXML(undefined)
})
appendFileSync("cycleHighwayFix.osc", changeparts.join("\n"), "utf8")
return true;
}))

View file

@ -48,19 +48,22 @@ export default class ScriptUtils {
})
}
public static DownloadJSON(url): Promise<any> {
public static DownloadJSON(url, options?: {
headers: any
}): Promise<any> {
return new Promise((resolve, reject) => {
try {
const headers = options?.headers ?? {}
headers.accept = "application/json"
const urlObj = new URL(url)
https.get({
host: urlObj.host,
path: urlObj.pathname + urlObj.search,
port: urlObj.port,
headers: {
"accept": "application/json"
}
headers: headers
}, (res) => {
const parts: string[] = []
res.setEncoding('utf8');