[josm-dev] [PATCH] - OrthogonalizeAction

Hermann Schwaerzler hermann.schwaerzler at chello.at
Tue Nov 18 15:47:26 GMT 2008


hello

I am mapping a lot of buildings recently and used the "Align in
Rectangle" a lot. I was glad to hear and use the replacement
"Orthogonalize", but I found some issues.
(I sent Frederik Ramm and Harald Kucharek private mails about this but I
do not want to bother them any more as I think it's probably better to
discuss this on this list.)

I found two "problems" with the code:

1. if a building has sides that are (almost) heading to -PI/4 or +PI/4
it may happen that the function calculates a totally wrong new heading
of the building. this is due to the fact that the normalization of the
headings maps adjacent sides to different "edges" of the
normalization-range which in turn makes the calculation of the average
fail.

2. when more than one building is selected all buildings get the _same_
averaged heading. I changed the algorithm to do the following (which
seems to me to be more intuitive):
* if two additional nodes are selected _all_ ways are aligned to the
heading of the two nodes
* if only ways (no nodes) are selected every way get its own heading.


the attached patch adresses/solves these issues and does also the following:

* cosmetics: the OrthogonalizeAction.java in SVN does not use
solely tabs for indentation but those mixed with spaces. the patch
replaces all those spaces with tabs.

* in the current code the normalizations of the headings is done the
first two times to [ 0 , PI/2 ] but the second two times to
[ -PI/4 , PI/4 ]. IMO the latter one is the better way to go and the
patch changes this.

* it introduces a normalization helper-function.

hopefully the code i wrote reaches your design- and quality-criteria. :-)

hermann

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: orthogonalize_averagebug.diff
URL: <http://lists.openstreetmap.org/pipermail/josm-dev/attachments/20081118/bd514558/attachment.ksh>


More information about the josm-dev mailing list