[OSM-talk] JOSM and flipping the direction of segments

Simon Hewison simon at zymurgy.org
Tue Jun 13 12:49:33 BST 2006


Until the enhancement request for JOSM to be able to flip the direction of 
segments happens, I've written a little work-around script in perl.

It works like this:

Turn on the direction arrows in JOSM to see where segments are obviously the 
wrong way around (motorway carriageways, etc)

Select all the segments that you want flipped

Create a new way from those segments, DO NOT UPLOAD TO SERVER.
Name the way "Wrong Way"
Save map to local file.
Run perl script on local file to produce another output file.
Perl script looks at all segments in way called "Wrong Way", and flips them, 
and flags them as modified. It then removes this temporary way and saves it.
Discard the data layer in JOSM, and load in the output file from perl 
script. Segments previously selected should have been flipped.
Upload changes to server.

If anyone wants a copy of the script, let me know. It's not pretty, but it 
does the job. I guess that something similar could be used to do other 
processing that I can't yet think of yet.

Of course, I really shouldn't have written it in Perl, I should have learned 
Java properly, and added the functionality to JOSM, and passed the patches 
to Imi, but I'm being lazy.

It's nice to be able to turn the segments around in the applet, but that 
doesn't show you which way they're facing yet, and JOSM does.

-- 
Simon Hewison




More information about the talk mailing list