mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 08:39:56 +02:00
Push more on split_way
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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,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)
|
||||
|
||||
Reference in New Issue
Block a user