more clever splitting of closed ways

if a way is closed, iD needs to choose a second node to
split the way at.

This algorithm looks for a node that is both far away from
the initial node in terms of way segment length and nearby
in terms of beeline-distance. This assures that areas get
split on the most "natural" points (independent of the number
of nodes).

For example: bone-shaped areas get split across their waist-
line, circles across the diameter.
This commit is contained in:
tyr
2013-09-12 13:14:33 +02:00
committed by John Firebaugh
parent be30344cfd
commit 6afe3adfbe
3 changed files with 59 additions and 11 deletions
+8 -8
View File
@@ -259,10 +259,10 @@ describe("iD.actions.Split", function () {
// d ==== c
//
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
'c': iD.Node({id: 'c'}),
'd': iD.Node({id: 'd'}),
'a': iD.Node({id: 'a', loc: [0,1]}),
'b': iD.Node({id: 'b', loc: [1,1]}),
'c': iD.Node({id: 'c', loc: [1,0]}),
'd': iD.Node({id: 'd', loc: [0,0]}),
'-': iD.Way({id: '-', nodes: ['a', 'b', 'c', 'd', 'a']})
});
@@ -285,10 +285,10 @@ describe("iD.actions.Split", function () {
it("splits an area by converting it to a multipolygon", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
'c': iD.Node({id: 'c'}),
'd': iD.Node({id: 'd'}),
'a': iD.Node({id: 'a', loc: [0,1]}),
'b': iD.Node({id: 'b', loc: [1,1]}),
'c': iD.Node({id: 'c', loc: [1,0]}),
'd': iD.Node({id: 'd', loc: [0,0]}),
'-': iD.Way({id: '-', tags: {building: 'yes'}, nodes: ['a', 'b', 'c', 'd', 'a']})
});