systemed/iD — pull request #1845 by paulmach (2013-09-25 21:13:49+00:00)
Title: Improve Circularize Action

This is meant to fix https://github.com/systemed/iD/issues/1254 along with some other improvements.

The goals of this algorithm include:
* Don't move nodes connected to other ways much as those have special locations. Just make their connections circular. This is basically https://github.com/systemed/iD/issues/1254
* Reset circular order of points. Sometimes there are beautiful circles with 30+ points, but someone moved a point connected to another way and it creates a sharp turn in the circle. Until it gets fix, here is an example http://www.openstreetmap.org/edit?editor=id#map=23/47.67776/-122.36867

The code is kind of complicated and I anticipate all sorts of comments, but here is the gist. Key nodes are those connected to other ways. First, these key nodes are projected onto the circle. Then nodes between these key nodes are evenly spaced between. Nodes are added between if necessary to maintain the maxAngle condition. Note that this does not evenly space all the nodes of the circle, just those between key points. Also if you want more points than the default, you can create some more and recircularize.

What does P2 do? Every existing node in the way is projected onto the circle and nodes are added between these existing nodes at 20 degree intervals if necessary.

This code worked for me in a lot of cases, but I would appreciate some testing along with any feedback.