The axis align tool was designed for tidying up hand drawn buildings so that the walls are all at evenly spaced angles.
For a given number of regularly spaced axes it finds the angle of the first axis which makes the axes fit as close as possible to the angles of the edges in the ways. It then aligns each edge onto it's closest axis.
The basic version that handles non intersecting ways which don't share nodes is committed to the master branch in git.
The fix to work with relations and for shared nodes/self intersecting ways and is in my developement repository:
in the branch dev/alignaxes
How to use¶
- Select the ways that you want to axis align (probably areas but does also work with roads).
- Select Axis Align from the Road menu or toolbar.
- It will estimate how many axes you want to use based on the selection. Change it if necessary.
- Click Ok.
- Can choose the number of axes.
- Defaults to an estimate of the rough number of axes in the selected ways.
- Makes all the edges in the selected ways line up to an axis.
- Doesn't cope well with self intersecting ways or ways which share nodes. There is a fix in my dev repository (see above).
- Can't yet select relations and align each way in the relation. There is a fix in my dev repository (see above).
I hand draw a rectilinear building in the shape of an L, but the walls aren't quite at right angles. I use the axis align tool, it guesses I want 4 axes, and makes the edges at right angles to one another.
I hand trace a large building such as a hospital (this image is of York District Hospital) using a multipolygon relation to capture the inside walls. It is largely rectilinear perhaps with some 45 degree angles (8 axes). I select the multipolygon relation and use the axis align tool, which guesses I want 8 axes, and makes the edges at multiples of 45 degrees to one another.
In the image below I've added temporary ways between nodes which should be aligned even though they aren't connected (selected on left image), such as between the inner members of the multipolygon relation. These are easily deleted after axis aligning (right image). I've also included some footways through the hospital and the access road in the axis alignment.
I use an automatic tracing tool to trace a row of detached houses. They should line up at the same angles but they are all at slightly different angles. I select them all and use the axis align tool which guesses I want 4 axes and corrects the angles (note that it won't make the actual edges line up with one another).
How it works¶
- K-Means Cluster analysis (with the clusters at fixed angles from one another) on the edge angles to find orientation of main axis (other axes at intervals of 360 degrees / number of axes).
- Estimation works by doing the cluster analysis for a range of numbers of axes (3-16) and choosing the one with the smallest variance between angles of edges and axes (weighted to favour a smaller number of axes).
- Repositions each node on the intersection of the two axes of the edges through the edge midpoints.
- Iterates multiple times if nodes are shared, and only moves nodes half way towards intersections (to allow different edges to compete), and continue until the nodes only move a tiny amount (relative to the edge lengths), or start to diverge (in which case an axis alignment is likely not possible).