[josm-dev] JOSM extension for orthogonalizing ways

Harald Kucharek harald.kucharek at gmx.net
Fri Oct 31 05:45:23 GMT 2008


Hi list,

as documented in this http://josm.openstreetmap.de/ticket/1621 trac 
entry, I've developed a more general approach as the current function 
"aligning nodes in a rectangle"
The new function expects an arbitrary number of ways in the selection 
that must fullfill the following criteria:
-all ways must be closed loops (last node must be equal first node in way)
-all loops must have at least 4 corners (way must consist of at least 5 
nodes)
-consecutive segments of a way must establish a direction change of more 
than 45° and less than 135°

If any of this isn't valid for the selection, the function is aborted 
with an appropriate message. These checks also make pretty sure you not 
alter an accidential selection, as an arbitrary selection usually 
violates one of the above rules.

Now the orientation of all segments is computed, normalized, so 
orientations perpendicular to each other end up as the same direction 
value and weighted by its length. The result gives the general 
orientation of the objects in the selection, like establishing one of 
the axis of a grid.

Now all segements are aligned to this grid by rotating them around their 
center. From consecutive segments a new intersection coordinate is 
computed and the node of the former corner is moved to this coordinate.

Allowing multiple ways in the selection allows to align e.g. several 
buildings.

I've written the function while I was mapping a village from Yahoo 
imagery where I usually spend my holidays.
http://www.openstreetmap.org/?lat=43.5103&lon=16.18812&zoom=16&layers=0B00FTF
Was fun to begin with a blank sheet. Next time I'm there, I'll take a 
printout of the map with me and then collect all the information to turn 
this into a real map.

Now, my question is: Is there interest by the maintainers of JOSM to put 
my function into JOSM, maybe replacing the current "aligning nodes in a 
rectangle" function of JOSM? I tried to write the code for clarity, as 
performance shouldn't be an issue with the amount of data that usually 
would be processed by such a function.

Harald




More information about the josm-dev mailing list