Test copying tags to the split way

This commit is contained in:
John Firebaugh
2013-01-18 10:35:15 -08:00
parent faecda854e
commit ce6e11a8a0
3 changed files with 19 additions and 6 deletions
+4 -5
View File
@@ -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);
+1 -1
View File
@@ -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();
+14
View File
@@ -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