Small (and rough) script to create some very specific changesets
This commit is contained in:
parent
7fd8361eea
commit
d29302ca84
2 changed files with 29 additions and 4 deletions
|
@ -115,6 +115,7 @@ export abstract class OsmObject {
|
|||
const rels = data.elements.map(wayInfo => {
|
||||
const rel = new OsmRelation(wayInfo.id)
|
||||
rel.LoadData(wayInfo)
|
||||
rel.SaveExtraData(wayInfo)
|
||||
return rel
|
||||
})
|
||||
relsSrc.setData(rels)
|
||||
|
@ -496,10 +497,13 @@ export class OsmRelation extends OsmObject {
|
|||
}
|
||||
|
||||
let tags = this.TagsXML();
|
||||
return ' <relation id="' + this.id + '" changeset="' + changesetId + '" ' + this.VersionXML() + '>\n' +
|
||||
members +
|
||||
tags +
|
||||
' </relation>\n';
|
||||
let cs = ""
|
||||
if(changesetId !== undefined){
|
||||
cs = `changeset="${changesetId}"`
|
||||
}
|
||||
return ` <relation id="${this.id}" ${cs} ${this.VersionXML()}>
|
||||
${members}${tags} </relation>
|
||||
`;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}))
|
Loading…
Reference in a new issue