From 6d7b135b223874852ddcf18420e12118a8ff5a7d Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 7 Dec 2012 14:03:03 -0500 Subject: [PATCH] Push more on split_way --- js/id/actions/split_way.js | 32 ++++++++++++++++++++++++-------- js/id/graph/history.js | 2 +- js/id/id.js | 1 + 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/js/id/actions/split_way.js b/js/id/actions/split_way.js index d9081bb9d..55623ce5e 100644 --- a/js/id/actions/split_way.js +++ b/js/id/actions/split_way.js @@ -1,16 +1,32 @@ // https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as iD.actions.SplitWay = function(nodeId) { return function(graph) { + 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'); + + // splitting ways at intersections TODO + if (parents.length !== 1) return graph; + + var way = parents[0]; + + 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'); + + var parentRelations = graph.parentRelations(way); + + parentRelations.forEach(function(relation) { + console.log(relation); + if (relation.tags.type === 'restriction') { + console.log(relation); + } }); + return graph; }; }; diff --git a/js/id/graph/history.js b/js/id/graph/history.js index eec93f3e8..b4f75d847 100644 --- a/js/id/graph/history.js +++ b/js/id/graph/history.js @@ -3,7 +3,7 @@ iD.History = function() { dispatch = d3.dispatch('change'); function perform(actions) { - actions = Array.prototype.slice.call(actions) + actions = Array.prototype.slice.call(actions); var annotation; diff --git a/js/id/id.js b/js/id/id.js index bd314bed8..2dff2a791 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -1,6 +1,7 @@ window.iD = function(container) { var connection = iD.Connection() .url('http://api06.dev.openstreetmap.org'), + // .url('http://www.openstreetmap.org'), history = iD.History(), map = iD.Map() .connection(connection)