some more cleanup and performance squeezing
This commit is contained in:
parent
f70dd3c3ac
commit
12d8cae46f
16 changed files with 265 additions and 212 deletions
|
|
@ -47,7 +47,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
public int originLon;
|
||||
public int originLat;
|
||||
|
||||
// the costfactor of the segment just before this paths position
|
||||
// the classifier of the segment just before this paths position
|
||||
public float lastClassifier;
|
||||
|
||||
public MessageData message;
|
||||
|
|
@ -129,6 +129,37 @@ final class OsmPath implements OsmLinkHolder
|
|||
|
||||
MessageData msgData = recordMessageData ? new MessageData() : null;
|
||||
|
||||
// evaluate the way tags
|
||||
rc.expctxWay.evaluate( rc.inverseDirection ^ link.counterLinkWritten, description );
|
||||
|
||||
// calculate the costfactor inputs
|
||||
boolean isTrafficBackbone = cost == 0 && rc.expctxWay.getIsTrafficBackbone() > 0.f;
|
||||
float turncostbase = rc.expctxWay.getTurncost();
|
||||
float cfup = rc.expctxWay.getUphillCostfactor();
|
||||
float cfdown = rc.expctxWay.getDownhillCostfactor();
|
||||
float cf = rc.expctxWay.getCostfactor();
|
||||
cfup = cfup == 0.f ? cf : cfup;
|
||||
cfdown = cfdown == 0.f ? cf : cfdown;
|
||||
|
||||
// *** add initial cost if the classifier changed
|
||||
float newClassifier = rc.expctxWay.getInitialClassifier();
|
||||
if ( newClassifier == 0. )
|
||||
{
|
||||
newClassifier = (cfup + cfdown + cf)/3;
|
||||
}
|
||||
float classifierDiff = newClassifier - lastClassifier;
|
||||
if ( classifierDiff > 0.0005 || classifierDiff < -0.0005 )
|
||||
{
|
||||
lastClassifier = newClassifier;
|
||||
float initialcost = rc.expctxWay.getInitialcost();
|
||||
int iicost = (int)initialcost;
|
||||
if ( recordMessageData )
|
||||
{
|
||||
msgData.linkinitcost += iicost;
|
||||
}
|
||||
cost += iicost;
|
||||
}
|
||||
|
||||
OsmTransferNode transferNode = link.decodeFirsttransfer( p1 );
|
||||
OsmNode targetNode = link.targetNode;
|
||||
for(;;)
|
||||
|
|
@ -152,10 +183,8 @@ final class OsmPath implements OsmLinkHolder
|
|||
lat2 = transferNode.ilat;
|
||||
ele2 = transferNode.selev;
|
||||
}
|
||||
|
||||
boolean sameData = rc.expctxWay.evaluate( rc.inverseDirection ^ link.counterLinkWritten, description );
|
||||
|
||||
// if way description changed, store message
|
||||
// if recording, new MessageData for each section (needed for turn-instructions)
|
||||
if ( recordMessageData && msgData.wayKeyValues != null )
|
||||
{
|
||||
originElement.message = msgData;
|
||||
|
|
@ -199,18 +228,16 @@ final class OsmPath implements OsmLinkHolder
|
|||
}
|
||||
linkdisttotal += dist;
|
||||
|
||||
boolean isTrafficBackbone = cost == 0 && rc.expctxWay.getIsTrafficBackbone() > 0.f;
|
||||
|
||||
// *** penalty for turning angles
|
||||
if ( !isTrafficBackbone && origin.originElement != null )
|
||||
{
|
||||
// penalty proportional to direction change
|
||||
double cos = rc.calcCosAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
int turncost = (int)(cos * rc.expctxWay.getTurncost() + 0.2 ); // e.g. turncost=90 -> 90 degree = 90m penalty
|
||||
cost += turncost;
|
||||
int actualturncost = (int)(cos * turncostbase + 0.2 ); // e.g. turncost=90 -> 90 degree = 90m penalty
|
||||
cost += actualturncost;
|
||||
if ( recordMessageData )
|
||||
{
|
||||
msgData.linkturncost += turncost;
|
||||
msgData.linkturncost += actualturncost;
|
||||
msgData.turnangle = (float)rc.calcAngle( lon0, lat0, lon1, lat1, lon2, lat2 );
|
||||
}
|
||||
}
|
||||
|
|
@ -292,16 +319,8 @@ final class OsmPath implements OsmLinkHolder
|
|||
ehbu = 0;
|
||||
}
|
||||
|
||||
// *** penalty for distance
|
||||
float cfup = rc.expctxWay.getUphillCostfactor();
|
||||
float cfdown = rc.expctxWay.getDownhillCostfactor();
|
||||
float cf = rc.expctxWay.getCostfactor();
|
||||
|
||||
cfup = cfup == 0.f ? cf : cfup;
|
||||
cfdown = cfdown == 0.f ? cf : cfdown;
|
||||
|
||||
// get the effective costfactor (slope dependent)
|
||||
float costfactor = cfup*upweight + cf*(1.f - upweight - downweight) + cfdown*downweight;
|
||||
|
||||
if ( isTrafficBackbone )
|
||||
{
|
||||
costfactor = 0.f;
|
||||
|
|
@ -323,24 +342,6 @@ final class OsmPath implements OsmLinkHolder
|
|||
int cost2 = cost < minDist ? minDist : cost;
|
||||
traffic += dist*rc.expctxWay.getTrafficSourceDensity()*Math.pow(cost2/10000.f,rc.trafficSourceExponent);
|
||||
}
|
||||
// *** add initial cost if the classifier changed
|
||||
float newClassifier = rc.expctxWay.getInitialClassifier();
|
||||
if ( newClassifier == 0. )
|
||||
{
|
||||
newClassifier = (cfup + cfdown + cf)/3;
|
||||
}
|
||||
float classifierDiff = newClassifier - lastClassifier;
|
||||
if ( classifierDiff > 0.0005 || classifierDiff < -0.0005 )
|
||||
{
|
||||
lastClassifier = newClassifier;
|
||||
float initialcost = rc.expctxWay.getInitialcost();
|
||||
int iicost = (int)initialcost;
|
||||
if ( recordMessageData )
|
||||
{
|
||||
msgData.linkinitcost += iicost;
|
||||
}
|
||||
cost += iicost;
|
||||
}
|
||||
|
||||
if ( recordMessageData )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ public final class ProfileCache
|
|||
BExpressionMetaData meta = new BExpressionMetaData();
|
||||
|
||||
BExpressionContextGlobal expctxGlobal = new BExpressionContextGlobal( meta );
|
||||
rc.expctxWay = new BExpressionContextWay( rc.serversizing ? 262144 : 8192, meta );
|
||||
rc.expctxNode = new BExpressionContextNode( rc.serversizing ? 16384 : 2048, meta );
|
||||
rc.expctxWay = new BExpressionContextWay( rc.serversizing ? 262144 : 32768, meta );
|
||||
rc.expctxNode = new BExpressionContextNode( rc.serversizing ? 16384 : 4096, meta );
|
||||
|
||||
meta.readMetaData( new File( profileDir, "lookups.dat" ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ import java.util.List;
|
|||
import btools.expressions.BExpressionContext;
|
||||
import btools.expressions.BExpressionContextNode;
|
||||
import btools.expressions.BExpressionContextWay;
|
||||
import btools.mapaccess.DistanceChecker;
|
||||
import btools.mapaccess.OsmTransferNode;
|
||||
|
||||
public final class RoutingContext implements DistanceChecker
|
||||
public final class RoutingContext
|
||||
{
|
||||
public void setAlternativeIdx( int idx )
|
||||
{
|
||||
|
|
@ -349,28 +347,4 @@ public final class RoutingContext implements DistanceChecker
|
|||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRadius( int ilon0, int ilat0, OsmTransferNode firstTransfer, int ilon1, int ilat1 )
|
||||
{
|
||||
OsmNodeNamed wp = nogopoints.get(0);
|
||||
double keepRadius = wp.radius;
|
||||
try
|
||||
{
|
||||
int ilon = ilon0;
|
||||
int ilat = ilat0;
|
||||
for( OsmTransferNode trans = firstTransfer; trans != null; trans = trans.next )
|
||||
{
|
||||
calcDistance( ilon, ilat, trans.ilon, trans.ilat );
|
||||
ilon = trans.ilon;
|
||||
ilat = trans.ilat;
|
||||
}
|
||||
calcDistance( ilon, ilat, ilon1, ilat1 );
|
||||
return wp.radius < keepRadius;
|
||||
}
|
||||
finally
|
||||
{
|
||||
wp.radius = keepRadius;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,10 +226,19 @@ public class RoutingEngine extends Thread
|
|||
}
|
||||
finally
|
||||
{
|
||||
ProfileCache.releaseProfile( routingContext );
|
||||
if ( hasInfo() && routingContext.expctxWay != null )
|
||||
{
|
||||
logInfo( "expression cache stats=" + routingContext.expctxWay.cacheStats() );
|
||||
}
|
||||
|
||||
ProfileCache.releaseProfile( routingContext );
|
||||
|
||||
if ( nodesCache != null )
|
||||
{
|
||||
if ( hasInfo() && nodesCache != null )
|
||||
{
|
||||
logInfo( "NodesCache status before close=" + nodesCache.formatStatus() );
|
||||
}
|
||||
nodesCache.close();
|
||||
nodesCache = null;
|
||||
}
|
||||
|
|
@ -544,6 +553,10 @@ public class RoutingEngine extends Thread
|
|||
|
||||
private void resetCache()
|
||||
{
|
||||
if ( hasInfo() && nodesCache != null )
|
||||
{
|
||||
logInfo( "NodesCache status before reset=" + nodesCache.formatStatus() );
|
||||
}
|
||||
nodesMap = new OsmNodesMap();
|
||||
nodesCache = new NodesCache(segmentDir, nodesMap, routingContext.expctxWay, routingContext.carMode, routingContext.forceSecondaryData, nodesCache );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue