mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
Rudientary splitting of ways
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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,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) {
|
||||
|
||||
Reference in New Issue
Block a user