use start direction (provided by locus) as turncost bias

This commit is contained in:
Arndt 2016-10-14 19:18:21 +02:00
parent 372673be7a
commit fdf06cbdd0
5 changed files with 34 additions and 1 deletions

View file

@ -90,6 +90,9 @@ final class OsmPath implements OsmLinkHolder
this.link = link;
targetNode = link.getTarget( null );
selev = targetNode.getSElev();
originLon = -1;
originLat = -1;
}
OsmPath( OsmPath origin, OsmLink link, OsmTrack refTrack, boolean detailMode, RoutingContext rc )
@ -217,6 +220,9 @@ final class OsmPath implements OsmLinkHolder
cost = 0;
ehbd = 0;
ehbu = 0;
lon0 = -1; // reset turncost-pipe
lat0 = -1;
if ( recordTransferNodes )
{
if ( rc.wayfraction > 0. )
@ -237,8 +243,20 @@ final class OsmPath implements OsmLinkHolder
}
linkdisttotal += dist;
// apply a start-direction if appropriate (by faking the origin position)
if ( lon0 == -1 && lat0 == -1 )
{
double coslat = Math.cos( ( lat1 - 90000000 ) * 0.00000001234134 );
if ( rc.startDirectionValid && coslat > 0. )
{
double dir = rc.startDirection.intValue() / 57.29578;
lon0 = lon1 - (int) ( 1000. * Math.sin( dir ) / coslat );
lat0 = lat1 - (int) ( 1000. * Math.cos( dir ) );
}
}
// *** penalty for turning angles
if ( !isTrafficBackbone && origin.originElement != null )
if ( !isTrafficBackbone && lon0 != -1 && lat0 != -1 )
{
// penalty proportional to direction change
double cos = rc.calcCosAngle( lon0, lat0, lon1, lat1, lon2, lat2 );

View file

@ -115,6 +115,9 @@ public final class RoutingContext
public List<OsmNodeNamed> nogopoints = null;
private List<OsmNodeNamed> keepnogopoints = null;
public Integer startDirection;
public boolean startDirectionValid;
private double coslat;
public boolean nogomatch = false;
public boolean isEndpoint = false;

View file

@ -760,6 +760,11 @@ public class RoutingEngine extends Thread
if ( start1 == null || start2 == null ) return null;
if ( routingContext.startDirectionValid = ( fastPartialRecalc && routingContext.startDirection != null ) )
{
logInfo( "using start direction " + routingContext.startDirection );
}
OsmPath startPath1 = getStartPath( start1, start2, startWp, endPos, sameSegmentSearch );
OsmPath startPath2 = getStartPath( start2, start1, startWp, endPos, sameSegmentSearch );

View file

@ -60,6 +60,12 @@ public class BRouterWorker
rc.turnInstructionMode = 2;
}
}
if ( params.containsKey( "direction" ) )
{
rc.startDirection = Integer.valueOf( params.getInt( "direction" ) );
}
if ( nogoList != null )
{
rc.prepareNogoPoints( nogoList );

View file

@ -156,6 +156,7 @@ public class BRouter
}
}
c.memoryclass = (int) ( Runtime.getRuntime().maxMemory() / 1024 / 1024 );
// c.startDirection= Integer.valueOf( 150 );
return c;
}
}