From 16d334614789b432b4a324f2179ef9eec1505eb2 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 30 Sep 2013 16:54:03 -0700 Subject: [PATCH] Split only the line of a node shared by a line and an area --- js/id/actions/split.js | 6 +++++- test/spec/actions/split.js | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/js/id/actions/split.js b/js/id/actions/split.js index 79cf96973..8e22348a9 100644 --- a/js/id/actions/split.js +++ b/js/id/actions/split.js @@ -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; } diff --git a/test/spec/actions/split.js b/test/spec/actions/split.js index 39f326b4c..90b054274 100644 --- a/test/spec/actions/split.js +++ b/test/spec/actions/split.js @@ -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