So I’m trying to use the JOSM Scripting plugin to programmatically Split Ways IDs through my .osm.pbf file (city-scale filesize) via the Rhino Javascript.
Does anyone have any sample code or example code of how to get a split to work in the scripter?
Here is as close as I’ve come but I get an error very early in the script. I’ve looked the few examples I can find. I think my format is correct. In fact I am currently wondering if there is a bug triggered by the
var actions = require("josm/actions");
line of code.
function current_layer() {
var layers = require("josm/layers");
return layers.activeLayer;
}
//Define the function
function SplitWaysAndAssignNewIDs(){
var util = require("josm/util");
var command = require("josm/command");
var console = require("josm/scriptingconsole");
var actions = require("josm/actions");
var layer = current_layer();
if (layer == null) return;
var dataset = layer.data;
//Select my Node of Interest which is a member of a Given Way.
//I will eventually write this into a For Loop to iterate through several ways of a given highway type
var sampleNodeInWay= dataset.query("id:175494043");
//Run the Split command - This code is wrong, and I don't know how to fix it!
//I'm sorry but I cannot understand the documentation about declaring java classes in javascript
split.runOn(sampleNodeInWay);
var waySplitInHalf = dataset.query("type:way")
//Assign a New OSM ID to each half of the Way I just split
for (j = 0; j < waySplitInHalf.length; j++) {
// waySplitInHalf[j].setOsmId(999000000+j,1);
}
}
//Run the function
SplitWaysAndAssignNewIDs();
PS. Don’t worry I am NOT uploading “My Split Dataset” to OSM. This is just for a personal offline project.
Thank you kindly for your time, and thank you in advance for your reply! Best wishes.
- Dylan