From d940200ef0e1c5cdad1630ca6cdfa5b27218a79e Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 16 Feb 2018 13:27:23 -0500 Subject: [PATCH] osmInferRestriction can just take a turn, instead of from/to This is better because it makes explicit that osmInferRestriction needs an actual turn now (from/to with vertex, etc) --- modules/actions/restrict_turn.js | 2 +- modules/osm/intersection.js | 16 ++++++++-------- modules/ui/fields/restrictions.js | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/actions/restrict_turn.js b/modules/actions/restrict_turn.js index 60284c381..50490012d 100644 --- a/modules/actions/restrict_turn.js +++ b/modules/actions/restrict_turn.js @@ -52,7 +52,7 @@ export function actionRestrictTurn(turn, projection, restrictionID) { id: restrictionID, tags: { type: 'restriction', - restriction: turn.restriction || osmInferRestriction(graph, turn.from, turn.to, projection) + restriction: turn.restriction || osmInferRestriction(graph, turn, projection) }, members: members })); diff --git a/modules/osm/intersection.js b/modules/osm/intersection.js index 1673bbb45..170552a70 100644 --- a/modules/osm/intersection.js +++ b/modules/osm/intersection.js @@ -604,13 +604,13 @@ export function osmIntersection(graph, startVertexId, maxDistance) { } -export function osmInferRestriction(graph, from, to, projection) { - var fromWay = graph.entity(from.way); - var fromNode = graph.entity(from.node); - var fromVertex = graph.entity(from.vertex); - var toWay = graph.entity(to.way); - var toNode = graph.entity(to.node); - var toVertex = graph.entity(to.vertex); +export function osmInferRestriction(graph, turn, projection) { + var fromWay = graph.entity(turn.from.way); + var fromNode = graph.entity(turn.from.node); + var fromVertex = graph.entity(turn.from.vertex); + var toWay = graph.entity(turn.to.way); + var toNode = graph.entity(turn.to.node); + var toVertex = graph.entity(turn.to.vertex); var fromOneWay = (fromWay.tags.oneway === 'yes'); var toOneWay = (toWay.tags.oneway === 'yes'); @@ -624,7 +624,7 @@ export function osmInferRestriction(graph, from, to, projection) { return 'no_u_turn'; if ((angle < 23 || angle > 336) && fromOneWay && toOneWay) return 'no_u_turn'; // wider tolerance for u-turn if both ways are oneway - if ((angle < 40 || angle > 319) && fromOneWay && toOneWay && from.vertex !== to.vertex) + if ((angle < 40 || angle > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) return 'no_u_turn'; // even wider tolerance for u-turn if there is a via way (from !== to) if (angle < 158) return 'no_right_turn'; diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 0550cff63..f29caccbb 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -347,7 +347,7 @@ export function uiFieldRestrictions(field, context) { } else if (datum instanceof osmTurn) { var actions; - datum.restriction = osmInferRestriction(vgraph, datum.from, datum.to, projection); + datum.restriction = osmInferRestriction(vgraph, datum, projection); if (datum.restrictionID && !datum.direct) { return; @@ -436,7 +436,7 @@ export function uiFieldRestrictions(field, context) { var fromWayID = datum.from.way; var viaWayIDs = datum.via.ways; var toWayID = datum.to.way; - var restrictionType = osmInferRestriction(vgraph, datum.from, datum.to, projection); + var restrictionType = osmInferRestriction(vgraph, datum, projection); var turnType = { 'no_left_turn': 'Left Turn',