mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 16:19:48 +02:00
Split only the line of a node shared by a line and an area
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user