Prevent using ways in the wrong direction

This commit is contained in:
Mattéo Delabre 2020-01-13 15:01:07 +01:00
parent d42e3ed3ed
commit b3de2e25f1
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 10 additions and 4 deletions

View File

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