mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-22 03:36:37 +02:00
add nodes to all of a segment's ways
when - dragging a node to a way - starting a line from a way - starting an area from a way - drawing a way
This commit is contained in:
@@ -58,8 +58,9 @@ iD.behavior.Draw = function(context) {
|
||||
function click() {
|
||||
var d = datum();
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseIndex(d, d3.mouse(context.surface().node()), context);
|
||||
event.clickWay(d, choice.loc, choice.index);
|
||||
var choice = iD.geo.chooseIndex(d, d3.mouse(context.surface().node()), context),
|
||||
edge = [d.nodes[choice.index - 1], d.nodes[choice.index]];
|
||||
event.clickWay(choice.loc, edge);
|
||||
|
||||
} else if (d.type === 'node') {
|
||||
event.clickNode(d);
|
||||
|
||||
@@ -125,12 +125,11 @@ iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) {
|
||||
};
|
||||
|
||||
// Connect the way to an existing way.
|
||||
drawWay.addWay = function(way, loc, wayIndex) {
|
||||
var newNode = iD.Node({loc: loc});
|
||||
drawWay.addWay = function(loc, edge) {
|
||||
var newNode = iD.Node({ loc: loc });
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(newNode),
|
||||
iD.actions.AddVertex(way.id, newNode.id, wayIndex),
|
||||
iD.actions.AddMidpoint({ loc: loc, edge: edge}, newNode),
|
||||
ReplaceTemporaryNode(newNode),
|
||||
annotation);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ iD.modes.AddArea = function(context) {
|
||||
context.enter(iD.modes.DrawArea(context, way.id, graph));
|
||||
}
|
||||
|
||||
function startFromWay(other, loc, index) {
|
||||
function startFromWay(loc, edge) {
|
||||
var graph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way({tags: defaultTags});
|
||||
@@ -37,7 +37,7 @@ iD.modes.AddArea = function(context) {
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(other.id, node.id, index));
|
||||
iD.actions.AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
|
||||
context.enter(iD.modes.DrawArea(context, way.id, graph));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ iD.modes.AddLine = function(context) {
|
||||
context.enter(iD.modes.DrawLine(context, way.id, 'forward', graph));
|
||||
}
|
||||
|
||||
function startFromWay(other, loc, index) {
|
||||
function startFromWay(loc, edge) {
|
||||
var graph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way();
|
||||
@@ -34,7 +34,7 @@ iD.modes.AddLine = function(context) {
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(other.id, node.id, index));
|
||||
iD.actions.AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
|
||||
context.enter(iD.modes.DrawLine(context, way.id, 'forward', graph));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ iD.modes.AddPoint = function(context) {
|
||||
context.enter(iD.modes.Select(context, [node.id], true));
|
||||
}
|
||||
|
||||
function addWay(way, loc, index) {
|
||||
function addWay(loc, edge) {
|
||||
add(loc);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,8 +107,7 @@ iD.modes.DragNode = function(context) {
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseIndex(d, d3.mouse(context.surface().node()), context);
|
||||
context.replace(
|
||||
iD.actions.MoveNode(entity.id, choice.loc),
|
||||
iD.actions.AddVertex(d.id, entity.id, choice.index),
|
||||
iD.actions.AddMidpoint({ loc: choice.loc, edge: [d.nodes[choice.index - 1], d.nodes[choice.index]] }, entity),
|
||||
connectAnnotation(d));
|
||||
|
||||
} else if (d.type === 'node' && d.id !== entity.id) {
|
||||
|
||||
Reference in New Issue
Block a user