Merge pull request #127 from Phyks/travelTime

Few fixes to travel time computation
This commit is contained in:
abrensch 2018-12-12 22:22:33 +01:00 committed by GitHub
commit cab8ca3dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -175,8 +175,8 @@ public final class RoutingContext
turnInstructionRoundabouts = expctxGlobal.getVariableValue( "turnInstructionRoundabouts", 1.f ) != 0.f; turnInstructionRoundabouts = expctxGlobal.getVariableValue( "turnInstructionRoundabouts", 1.f ) != 0.f;
// Speed computation model (for bikes) // Speed computation model (for bikes)
// Mass of the biker + bike + luggages, in kg // Total mass (biker + bike + luggages or hiker), in kg
bikeMass = expctxGlobal.getVariableValue( "bikeMass", 90.f ); totalMass = expctxGlobal.getVariableValue( "totalMass", 90.f );
// Max speed (before braking), in km/h in profile and m/s in code // Max speed (before braking), in km/h in profile and m/s in code
maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 45.f ) / 3.6; maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 45.f ) / 3.6;
// Equivalent surface for wind, S * C_x, F = -1/2 * S * C_x * v^2 = - S_C_x * v^2 // Equivalent surface for wind, S * C_x, F = -1/2 * S * C_x * v^2 = - S_C_x * v^2
@ -224,7 +224,7 @@ public final class RoutingContext
public boolean turnInstructionRoundabouts; public boolean turnInstructionRoundabouts;
// Speed computation model (for bikes) // Speed computation model (for bikes)
public double bikeMass; public double totalMass;
public double maxSpeed; public double maxSpeed;
public double S_C_x; public double S_C_x;
public double defaultC_r; public double defaultC_r;

View file

@ -243,16 +243,21 @@ final class StdPath extends OsmPath
double incline = calcIncline( dist ); double incline = calcIncline( dist );
double speed; // Travel speed double speed; // Travel speed
double f_roll = rc.bikeMass * GRAVITY * ( rc.defaultC_r + incline ); double energy;
if (rc.footMode ) if (rc.footMode || rc.expctxWay.getCostfactor() > 5)
{ {
// Use Tobler's hiking function for walking sections // Use Tobler's hiking function for walking sections
speed = 6 * exp(-3.5 * Math.abs( incline + 0.05)) / 3.6; speed = 6 * exp(-3.5 * Math.abs( incline + 0.05)) / 3.6;
energy = rc.totalMass * GRAVITY * incline * dist;
} }
else if (rc.bikeMode) else if (rc.bikeMode)
{ {
double f_roll = rc.totalMass * GRAVITY * ( rc.defaultC_r + incline );
speed = solveCubic( rc.S_C_x, f_roll, rc.bikerPower ); speed = solveCubic( rc.S_C_x, f_roll, rc.bikerPower );
speed = Math.min(speed, rc.maxSpeed); speed = Math.min(speed, rc.maxSpeed);
// Don't compute energy assuming constant biker power, as speed is capped
// to a max value.
energy = dist*(rc.S_C_x*speed*speed + f_roll);
} }
else else
{ {
@ -260,7 +265,7 @@ final class StdPath extends OsmPath
} }
float dt = (float) ( dist / speed ); float dt = (float) ( dist / speed );
totalTime += dt; totalTime += dt;
totalEnergy += dist*(rc.S_C_x*speed*speed + f_roll); totalEnergy += energy;
} }
private static double solveCubic( double a, double c, double d ) private static double solveCubic( double a, double c, double d )