Skip to content

Commit

Permalink
add nodes to all of a segment's ways
Browse files Browse the repository at this point in the history
when
- dragging a node to a way
- starting a line from a way
- starting an area from a way
- drawing a way
  • Loading branch information
ansis committed Apr 4, 2013
1 parent 4944592 commit acdc1b3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions js/id/behavior/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions js/id/behavior/draw_way.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions js/id/modes/add_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand All @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions js/id/modes/add_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion js/id/modes/add_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions js/id/modes/drag_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit acdc1b3

Please sign in to comment.