Split only the line of a node shared by a line and an area

This commit is contained in:
John Firebaugh
2013-09-30 16:54:03 -07:00
parent dfd0854314
commit 16d3346147
2 changed files with 22 additions and 1 deletions
+5 -1
View File
@@ -147,12 +147,16 @@ iD.actions.Split = function(nodeId, newWayIds) {
action.ways = function(graph) {
var node = graph.entity(nodeId),
parents = graph.parentWays(node);
parents = graph.parentWays(node),
hasLines = _.any(parents, function(parent) { return parent.geometry(graph) === 'line'; });
return parents.filter(function(parent) {
if (wayIds && wayIds.indexOf(parent.id) === -1)
return false;
if (!wayIds && hasLines && parent.geometry(graph) !== 'line')
return false;
if (parent.isClosed()) {
return true;
}
+17
View File
@@ -305,6 +305,23 @@ describe("iD.actions.Split", function () {
]);
});
it("splits only the line of a node shared by a line and an area", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a', loc: [0,1]}),
'b': iD.Node({id: 'b', loc: [1,1]}),
'c': iD.Node({id: 'c', loc: [1,0]}),
'-': iD.Way({id: '-', nodes: ['a', 'b', 'c']}),
'=': iD.Way({id: '=', nodes: ['a', 'b', 'c', 'a'], tags: {area: 'yes'}})
});
graph = iD.actions.Split('b', ['~'])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
expect(graph.entity('~').nodes).to.eql(['b', 'c']);
expect(graph.entity('=').nodes).to.eql(['a', 'b', 'c', 'a']);
expect(graph.parentRelations(graph.entity('='))).to.have.length(0);
});
it("adds the new way to parent relations (no connections)", function () {
// Situation:
// a ---- b ---- c