mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Continue with splitWay
This commit is contained in:
@@ -13,17 +13,32 @@ iD.actions.SplitWay = function(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);
|
||||
var newWay = iD.Way({ tags: _.clone(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');
|
||||
|
||||
var parentRelations = graph.parentRelations(way);
|
||||
var parentRelations = graph.parentRelations(way.id);
|
||||
|
||||
function isVia(x) { return x.role = 'via'; }
|
||||
function isSelf(x) { return x.id = way.id; }
|
||||
|
||||
parentRelations.forEach(function(relation) {
|
||||
console.log(relation);
|
||||
if (relation.tags.type === 'restriction') {
|
||||
console.log(relation);
|
||||
var via = _.find(relation.members, isVia);
|
||||
var ownrole = _.find(relation.members, isSelf).role;
|
||||
if (via && !_.contains(newWay.nodes, via.id)) {
|
||||
// the new way doesn't contain the node that's important
|
||||
// to the turn restriction, so we don't need to worry
|
||||
// about adding it to the turn restriction.
|
||||
} else {
|
||||
graph = graph.replace(iD.actions.AddRelationMember(relation.id, {
|
||||
role: ownrole,
|
||||
id: newWay.id,
|
||||
type: 'way'
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user