mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Test copying tags to the split way
This commit is contained in:
@@ -7,17 +7,16 @@ iD.actions.SplitWay = function(nodeId) {
|
||||
// splitting ways at intersections TODO
|
||||
if (parents.length !== 1) return graph;
|
||||
|
||||
var way = parents[0];
|
||||
|
||||
var idx = _.indexOf(way.nodes, nodeId);
|
||||
var way = parents[0],
|
||||
idx = _.indexOf(way.nodes, nodeId);
|
||||
|
||||
// Create a 'b' way that contains all of the tags in the second
|
||||
// half of this way
|
||||
var newWay = iD.Way({ tags: _.clone(way.tags), nodes: way.nodes.slice(idx) });
|
||||
var newWay = iD.Way({tags: way.tags, nodes: way.nodes.slice(idx)});
|
||||
graph = graph.replace(newWay);
|
||||
|
||||
// Reduce the original way to only contain the first set of nodes
|
||||
graph = graph.replace(way.update({ nodes: way.nodes.slice(0, idx + 1) }), 'changed way direction');
|
||||
graph = graph.replace(way.update({nodes: way.nodes.slice(0, idx + 1)}));
|
||||
|
||||
var parentRelations = graph.parentRelations(way);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ iD.modes.Select = function (entity) {
|
||||
}).on('splitWay', function(d) {
|
||||
mode.history.perform(
|
||||
iD.actions.SplitWay(d.id),
|
||||
'split a way on a node');
|
||||
'split a way');
|
||||
|
||||
}).on('remove', function() {
|
||||
remove();
|
||||
|
||||
@@ -28,6 +28,20 @@ describe("iD.actions.SplitWay", function () {
|
||||
expect(waysB[1]).to.equal(waysC[0]);
|
||||
});
|
||||
|
||||
it("copies tags to the new way", function () {
|
||||
var a = iD.Node(),
|
||||
b = iD.Node(),
|
||||
c = iD.Node(),
|
||||
tags = {highway: 'residential'},
|
||||
way = iD.Way({nodes: [a.id, b.id, c.id], tags: tags}),
|
||||
graph = iD.Graph([a, b, c, way]);
|
||||
|
||||
graph = iD.actions.SplitWay(b.id)(graph);
|
||||
|
||||
expect(graph.parentWays(a)[0].tags).to.eql(tags);
|
||||
expect(graph.parentWays(c)[0].tags).to.eql(tags);
|
||||
});
|
||||
|
||||
it("moves restriction relations to the new way", function () {
|
||||
// Situation:
|
||||
// a ==== b ==== c ---- d
|
||||
|
||||
Reference in New Issue
Block a user