Push more on split_way

This commit is contained in:
Tom MacWright
2012-12-07 14:03:03 -05:00
parent 0e00998bc4
commit 6d7b135b22
3 changed files with 26 additions and 9 deletions
+24 -8
View File
@@ -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;
};
};
+1 -1
View File
@@ -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;
+1
View File
@@ -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)