minor refactoring
This commit is contained in:
parent
126c104bb3
commit
19e434facb
18 changed files with 138 additions and 115 deletions
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue