minor refactoring
This commit is contained in:
parent
126c104bb3
commit
19e434facb
18 changed files with 138 additions and 115 deletions
|
|
@ -230,6 +230,13 @@ public final class NodesCache
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* make sure the given node is non-hollow,
|
||||
* which means it contains not just the id,
|
||||
* but also the actual data
|
||||
*
|
||||
* @return true if successfull, false if node is still hollow
|
||||
*/
|
||||
public boolean obtainNonHollowNode( OsmNode node )
|
||||
{
|
||||
if ( !node.isHollow() )
|
||||
|
|
@ -255,6 +262,19 @@ public final class NodesCache
|
|||
return !node.isHollow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* make sure all link targets of the given node are non-hollow
|
||||
*/
|
||||
public void expandHollowLinkTargets( OsmNode n )
|
||||
{
|
||||
for( OsmLink link = n.firstlink; link != null; link = link.getNext( n ) )
|
||||
{
|
||||
obtainNonHollowNode( link.getTarget( n ) );
|
||||
}
|
||||
}
|
||||
|
||||
private OsmFile fileForSegment( int lonDegree, int latDegree ) throws Exception
|
||||
{
|
||||
int lonMod5 = lonDegree % 5;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package btools.mapaccess;
|
|||
import btools.codec.MicroCache;
|
||||
import btools.codec.MicroCache2;
|
||||
import btools.util.ByteArrayUnifier;
|
||||
import btools.util.CheapRulerSingleton;
|
||||
import btools.util.CheapRuler;
|
||||
import btools.util.IByteArrayUnifier;
|
||||
|
||||
public class OsmNode extends OsmLink implements OsmPos
|
||||
|
|
@ -102,7 +102,7 @@ public class OsmNode extends OsmLink implements OsmPos
|
|||
|
||||
public final int calcDistance( OsmPos p )
|
||||
{
|
||||
return (int)(CheapRulerSingleton.distance(ilon, ilat, p.getILon(), p.getILat()) + 1.0 );
|
||||
return (int)(CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat()) + 1.0 );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
|
|
|||
|
|
@ -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