minor refactoring

This commit is contained in:
Arndt Brenschede 2019-04-17 11:33:07 +02:00
parent 126c104bb3
commit 19e434facb
18 changed files with 138 additions and 115 deletions

View file

@ -28,6 +28,42 @@ public final class TurnRestriction
return ( exceptions & 2 ) != 0;
}
public static boolean isTurnForbidden( TurnRestriction first, int fromLon, int fromLat, int toLon, int toLat, boolean bikeMode, boolean carMode )
{
boolean hasAnyPositive = false;
boolean hasPositive = false;
boolean hasNegative = false;
TurnRestriction tr = first;
while (tr != null)
{
if ( ( tr.exceptBikes() && bikeMode ) || ( tr.exceptMotorcars() && carMode ) )
{
tr = tr.next;
continue;
}
if ( tr.fromLon == fromLon && tr.fromLat == fromLat )
{
if ( tr.isPositive )
{
hasAnyPositive = true;
}
if ( tr.toLon == toLon && tr.toLat == toLat )
{
if ( tr.isPositive )
{
hasPositive = true;
}
else
{
hasNegative = true;
}
}
}
tr = tr.next;
}
return !hasPositive && ( hasAnyPositive || hasNegative );
}
@Override
public String toString()
{