Skip to content

Commit

Permalink
Simplify some "add bridge or tunnel" fix code (re: #7055)
Browse files Browse the repository at this point in the history
Add endpoint to actionSplit to get the created ways after running the action
Change "Use bridge" or "tunnel" fix labels to "Add a bridge" or "tunnel"
Add layer tags on structure feature when adding a bridge or tunnel via a fix
Select all components of the split way when adding a bridge or tunnel via a fix
Don't recommend adding a bridge to a waterway
Don't show "change layers" fixes along with "add structure" fixes
Don't split or change the tags of coincident ways when adding a bridge or tunnel
  • Loading branch information
quincylvania committed Nov 20, 2019
1 parent 5ed22cc commit 5640d78
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 120 deletions.
12 changes: 6 additions & 6 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,12 @@ en:
message: '{feature} should be part of a line or area based on its tags'
reference: "Some features shouldn't be standalone points."
fix:
add_a_bridge:
title: Add a bridge
annotation: Added a bridge.
add_a_tunnel:
title: Add a tunnel
annotation: Added a tunnel.
address_the_concern:
title: Address the concern
connect_almost_junction:
Expand Down Expand Up @@ -1601,18 +1607,12 @@ en:
upgrade_tags:
title: Upgrade the tags
annotation: Upgraded old tags.
use_bridge:
title: Use a bridge
annotation: Created bridge
use_different_layers:
title: Use different layers
use_different_layers_or_levels:
title: Use different layers or levels
use_different_levels:
title: Use different levels
use_tunnel:
title: Use a tunnel
annotation: Created tunnel
intro:
done: done
ok: OK
Expand Down
14 changes: 8 additions & 6 deletions dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,14 @@
"reference": "Some features shouldn't be standalone points."
},
"fix": {
"add_a_bridge": {
"title": "Add a bridge",
"annotation": "Added a bridge."
},
"add_a_tunnel": {
"title": "Add a tunnel",
"annotation": "Added a tunnel."
},
"address_the_concern": {
"title": "Address the concern"
},
Expand Down Expand Up @@ -2010,9 +2018,6 @@
"title": "Upgrade the tags",
"annotation": "Upgraded old tags."
},
"use_bridge_or_tunnel": {
"title": "Use a bridge or tunnel"
},
"use_different_layers": {
"title": "Use different layers"
},
Expand All @@ -2021,9 +2026,6 @@
},
"use_different_levels": {
"title": "Use different levels"
},
"use_tunnel": {
"title": "Use a tunnel"
}
}
},
Expand Down
10 changes: 9 additions & 1 deletion modules/actions/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { utilArrayIntersection, utilWrap } from '../util';
export function actionSplit(nodeId, newWayIds) {
var _wayIDs;

// The IDs of the ways actually created by running this action
var createdWayIDs = [];

// If the way is closed, we need to search for a partner node
// to split the way at.
//
Expand Down Expand Up @@ -201,18 +204,23 @@ export function actionSplit(nodeId, newWayIds) {
graph = graph.replace(wayB.update({ tags: {} }));
}

createdWayIDs.push(wayB.id);

return graph;
}


var action = function(graph) {
var candidates = action.ways(graph);
createdWayIDs = [];
for (var i = 0; i < candidates.length; i++) {
graph = split(graph, candidates[i], newWayIds && newWayIds[i]);
}
return graph;
};

action.getCreatedWayIDs = function() {
return createdWayIDs;
};

action.ways = function(graph) {
var node = graph.entity(nodeId);
Expand Down
Loading

0 comments on commit 5640d78

Please sign in to comment.