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