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)
This commit is contained in:
Bryan Housel
2018-02-16 13:27:23 -05:00
parent b84b64c79c
commit d940200ef0
3 changed files with 11 additions and 11 deletions

View File

@@ -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
}));

View File

@@ -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';

View File

@@ -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',