openstreetmap/iD — pull request #2194 by bhousel (2014-04-10 21:04:51+00:00)
Title: Improvements to circularize action

This pull request improves a few minor things with the circularize action..

#### 1. When circularizing a way, try to add inbetween nodes to shared ways too. ####
When a way shares nodes with another way like this:
![screenshot 2014-04-10 16 00 42](https://cloud.githubusercontent.com/assets/38784/2672797/2c0bf35c-c0eb-11e3-9b07-cc75ae7cedfe.png)

If you circularize one of the ways, it leaves the key nodes connected but leaves the new in-between nodes disconnected.
![screenshot 2014-04-10 16 01 18](https://cloud.githubusercontent.com/assets/38784/2672798/2c0ca09a-c0eb-11e3-999d-5995baaecaaf.png)

This pull request will make it so that the new in-between nodes will also be added to any shared ways. (It only does this if the preexisting connected nodes are adjacent).
![screenshot 2014-04-10 16 02 26](https://cloud.githubusercontent.com/assets/38784/2672799/2c0f0baa-c0eb-11e3-8090-2b34a485af38.png)

#### 2. Coax concave ways to convex before circularizing. ####
Circularizing a very concave way can cause unexpected behavior:
![screenshot 2014-04-10 16 45 34](https://cloud.githubusercontent.com/assets/38784/2673352/8ef0d62a-c0f2-11e3-8350-6778109ce0af.png)

If some of the key nodes lie on the wrong side of the polygon's centroid, they get projected onto the wrong side of the circle, and that messes everything up:
![screenshot 2014-04-10 16 45 46](https://cloud.githubusercontent.com/assets/38784/2673351/8eee7132-c0f2-11e3-979e-5e7c3ded8eb1.png)

This pull request makes it so that circularize will check first if the polygon is concave, and if so, converts it to a convex polygon using d3.geom.hull() before doing anything else.
![screenshot 2014-04-10 16 47 54](https://cloud.githubusercontent.com/assets/38784/2673353/8ef3068e-c0f2-11e3-96e3-dfc442541e43.png)