systemed/iD — pull request #1861 by paulmach (2013-09-29 20:45:52+00:00)
Title: Limit squaring to near square or near straight nodes

This is in regards to https://github.com/systemed/iD/issues/1733 where it was suggested to only try to square or straighten nodes if they are within +-7 degrees of straight or right. I'll let whoever is in charge of UX to decide if they want this, but I think a touch up is what people expect out of this action, otherwise it's useless for a lot of shapes.

A couple other things: it only actually moves nodes that moved, so 45degree nodes will not appear in the change log, and the action is disabled if no nodes fit the criteria, ie you've selected a roundabout.

The key addition is the `filterDotProduct` function. Most of the other changes are a slight refactor to reuse code between `action` and `disabled`.

Also, I lowered epsilon to 1e-4 from 1e-8. I noticed that "straight" nodes were not getting removed because they weren't straight enough. I think 1e-4 is pretty straight and it worked good in my "real world" testing. I recommend this change even if you reject the other stuff. Maybe someone could make the change and I'll rebase.

The main location I used for testing is http://www.openstreetmap.org/edit#map=16/52.0739/-1.8204 and that is how I came up with 7 degrees.