Rudientary splitting of ways

This commit is contained in:
Tom MacWright
2012-12-07 11:03:15 -05:00
parent 618f5cc486
commit f74b29d93a
3 changed files with 18 additions and 4 deletions
+12 -3
View File
@@ -1,7 +1,16 @@
// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as
iD.actions.SplitWay = function(nodeId, wayId) {
iD.actions.SplitWay = function(nodeId) {
return function(graph) {
var way = graph.entity(wayId);
return graph.replace(way.update({nodes: nodes}), 'changed way direction');
var parents = graph.parentWays(nodeId);
parents.forEach(function(way) {
var idx = _.indexOf(way.nodes, nodeId);
// Create a 'b' way that contains all of the tags in the second
// half of this way
var b = iD.Way({ tags: _.clone(way.tags), nodes: way.nodes.slice(idx) });
graph = graph.replace(b);
// 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');
});
return graph;
};
};
+5
View File
@@ -71,6 +71,11 @@ iD.modes.Select = function (entity) {
iD.actions.ReverseWay(d.id),
'reversed a way');
}).on('splitWay', function(d) {
mode.history.perform(
iD.actions.SplitWay(d.id),
'split a way on a node');
}).on('remove', function() {
remove();
+1 -1
View File
@@ -1,5 +1,5 @@
iD.Inspector = function() {
var event = d3.dispatch('changeTags', 'changeWayDirection', 'update', 'remove', 'close'),
var event = d3.dispatch('changeTags', 'changeWayDirection', 'update', 'remove', 'close', 'splitWay'),
taginfo = iD.taginfo();
function drawhead(selection) {