From b3de2e25f1953f3c30ae86dbedc94f4948738760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Mon, 13 Jan 2020 15:01:07 +0100 Subject: [PATCH] Prevent using ways in the wrong direction --- back/data.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/back/data.js b/back/data.js index c0a306b..176879f 100644 --- a/back/data.js +++ b/back/data.js @@ -78,7 +78,11 @@ out body qt; for (let id of rawWays) { - const {type, nodes} = elements[id]; + const {type, nodes, tags} = elements[id]; + const canGoBackward = ( + tags.oneway !== 'yes' + || parseInt(tags['lanes:psv:backward'], 10) > 0 + ); if (type === 'way' && nodes.length >= 1) { @@ -93,14 +97,16 @@ out body qt; { if (!nodeNeighbors.has(node)) { - nodeNeighbors.set(node, new Set([previousNode])); + nodeNeighbors.set(node, new Set()); } - else + + nodeNeighbors.get(previousNode).add(node); + + if (canGoBackward) { nodeNeighbors.get(node).add(previousNode); } - nodeNeighbors.get(previousNode).add(node); previousNode = node; } }