added alternative up/down costfactors

This commit is contained in:
Arndt 2014-08-24 10:14:44 +02:00
parent 0cb894465e
commit 3a0f08dd5d
2 changed files with 8 additions and 8 deletions

View file

@ -206,7 +206,7 @@ final class OsmPath implements OsmLinkHolder
int reduce = dist * rc.elevationbufferreduce; int reduce = dist * rc.elevationbufferreduce;
if ( reduce > excess ) if ( reduce > excess )
{ {
downweight = ((float)reduce)/excess; downweight = ((float)excess)/reduce;
reduce = excess; reduce = excess;
} }
excess = ehbd - rc.elevationmaxbuffer; excess = ehbd - rc.elevationmaxbuffer;
@ -236,7 +236,7 @@ final class OsmPath implements OsmLinkHolder
int reduce = dist * rc.elevationbufferreduce; int reduce = dist * rc.elevationbufferreduce;
if ( reduce > excess ) if ( reduce > excess )
{ {
upweight = ((float)reduce)/excess; upweight = ((float)excess)/reduce;
reduce = excess; reduce = excess;
} }
excess = ehbu - rc.elevationmaxbuffer; excess = ehbu - rc.elevationmaxbuffer;
@ -267,7 +267,7 @@ final class OsmPath implements OsmLinkHolder
float costfactor = cfup*upweight + cf*(1.f - upweight - downweight) + cfdown*downweight; float costfactor = cfup*upweight + cf*(1.f - upweight - downweight) + cfdown*downweight;
float fcost = dist * costfactor + 0.5f; float fcost = dist * costfactor + 0.5f;
if ( cf >= 10000. || fcost + cost >= 2000000000. ) if ( costfactor > 9999. || fcost + cost >= 2000000000. )
{ {
cost = -1; cost = -1;
return; return;
@ -276,10 +276,11 @@ final class OsmPath implements OsmLinkHolder
cost += waycost; cost += waycost;
// *** add initial cost if factor changed // *** add initial cost if factor changed
float costdiff = cf - lastCostfactor; float newcostfactor = (cfup + cfdown + cf)/3;
float costdiff = newcostfactor - lastCostfactor;
if ( costdiff > 0.0005 || costdiff < -0.0005 ) if ( costdiff > 0.0005 || costdiff < -0.0005 )
{ {
lastCostfactor = cf; lastCostfactor = newcostfactor;
float initialcost = rc.expctxWay.getInitialcost(); float initialcost = rc.expctxWay.getInitialcost();
int iicost = (int)initialcost; int iicost = (int)initialcost;
cost += iicost; cost += iicost;
@ -288,7 +289,6 @@ final class OsmPath implements OsmLinkHolder
if ( recordTransferNodes ) if ( recordTransferNodes )
{ {
int iCost = (int)(costfactor*1000 + 0.5f); int iCost = (int)(costfactor*1000 + 0.5f);
//int iCost = (int)(rc.expctxWay.getCostfactor()*1000 + 0.5f);
lastMessage = (lon2-180000000) + "\t" lastMessage = (lon2-180000000) + "\t"
+ (lat2-90000000) + "\t" + (lat2-90000000) + "\t"
+ ele2/4 + "\t" + ele2/4 + "\t"

View file

@ -62,9 +62,9 @@ public final class RoutingContext implements DistanceChecker
carMode = 0.f != expctxGlobal.getVariableValue( "validForCars", 0.f ); carMode = 0.f != expctxGlobal.getVariableValue( "validForCars", 0.f );
pass1coefficient = expctxGlobal.getVariableValue( "pass1coefficient", 1.5f ); pass1coefficient = expctxGlobal.getVariableValue( "pass1coefficient", 1.5f );
pass2coefficient = expctxGlobal.getVariableValue( "pass2coefficient", 0.f ); pass2coefficient = expctxGlobal.getVariableValue( "pass2coefficient", 0.f );
elevationpenaltybuffer = (int)(expctxGlobal.getVariableValue( "elevationpenaltybuffer", 10.f )*1000000); elevationpenaltybuffer = (int)(expctxGlobal.getVariableValue( "elevationpenaltybuffer", 5.f )*1000000);
elevationmaxbuffer = (int)(expctxGlobal.getVariableValue( "elevationmaxbuffer", 10.f )*1000000); elevationmaxbuffer = (int)(expctxGlobal.getVariableValue( "elevationmaxbuffer", 10.f )*1000000);
elevationbufferreduce = (int)(expctxGlobal.getVariableValue( "elevationbufferreduce", 1.f )*10000); elevationbufferreduce = (int)(expctxGlobal.getVariableValue( "elevationbufferreduce", 0.f )*10000);
} }
public RoutingMessageHandler messageHandler = new RoutingMessageHandler(); public RoutingMessageHandler messageHandler = new RoutingMessageHandler();