speed handling #301

This commit is contained in:
afischerdev 2021-07-08 13:35:49 +02:00
parent 0078f86cf6
commit 57da34d205
9 changed files with 21 additions and 199 deletions

View file

@ -45,6 +45,7 @@ public final class OsmTrack
public boolean isDirty;
public boolean showspeed;
public boolean showSpeedProfile;
public List<OsmNodeNamed> pois = new ArrayList<OsmNodeNamed>();
@ -62,8 +63,6 @@ public final class OsmTrack
private VoiceHintList voiceHints;
private boolean sendSpeedProfile;
public String message = null;
public ArrayList<String> messageList = null;
@ -368,7 +367,7 @@ public final class OsmTrack
energy += t.energy;
showspeed |= t.showspeed;
sendSpeedProfile |= t.sendSpeedProfile;
showSpeedProfile |= t.showSpeedProfile;
}
public int distance;
@ -766,7 +765,7 @@ public final class OsmTrack
sb.deleteCharAt( sb.lastIndexOf( "," ) );
sb.append( " ],\n" );
}
if ( sendSpeedProfile ) // true if vmax was send
if ( showSpeedProfile ) // set in profile
{
ArrayList<String> sp = aggregateSpeedProfile();
if ( sp.size() > 0 )
@ -779,7 +778,7 @@ public final class OsmTrack
sb.append( " ],\n" );
}
}
else // ... otherwise traditional message list
// ... traditional message list
{
sb.append( " \"messages\": [\n" );
sb.append( " [\"" ).append( MESSAGES_HEADER.replaceAll( "\t", "\", \"" ) ).append( "\"],\n" );
@ -826,17 +825,17 @@ public final class OsmTrack
String sele = n.getSElev() == Short.MIN_VALUE ? "" : ", " + n.getElev();
if ( showspeed ) // hack: show speed instead of elevation
{
int speed = 0;
double speed = 0;
if ( nn != null )
{
int dist = n.calcDistance( nn );
float dt = n.getTime()-nn.getTime();
if ( dt != 0.f )
{
speed = (int)((3.6f*dist)/dt + 0.5);
speed = ((3.6f*dist)/dt + 0.5);
}
}
sele = ", " + speed;
sele = ", " + (((int)(speed*10))/10.f);
}
sb.append( " [" ).append( formatILon( n.getILon() ) ).append( ", " ).append( formatILat( n.getILat() ) )
.append( sele ).append( "],\n" );
@ -1058,7 +1057,7 @@ public final class OsmTrack
public void prepareSpeedProfile( RoutingContext rc )
{
sendSpeedProfile = rc.keyValues != null && rc.keyValues.containsKey( "vmax" );
// sendSpeedProfile = rc.keyValues != null && rc.keyValues.containsKey( "vmax" );
}
public void processVoiceHints( RoutingContext rc )

View file

@ -166,6 +166,7 @@ public final class RoutingContext
trafficSourceMinDist = expctxGlobal.getVariableValue( "trafficSourceMinDist", 3000.f );
showspeed = 0.f != expctxGlobal.getVariableValue( "showspeed", 0.f );
showSpeedProfile = 0.f != expctxGlobal.getVariableValue( "showSpeedProfile", 0.f );
inverseRouting = 0.f != expctxGlobal.getVariableValue( "inverseRouting", 0.f );
int tiMode = (int)expctxGlobal.getVariableValue( "turnInstructionMode", 0.f );
@ -180,7 +181,11 @@ public final class RoutingContext
// Total mass (biker + bike + luggages or hiker), in kg
totalMass = expctxGlobal.getVariableValue( "totalMass", 90.f );
// Max speed (before braking), in km/h in profile and m/s in code
maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 45.f ) / 3.6;
if (footMode) {
maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 6.f ) / 3.6;
} else {
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
S_C_x = expctxGlobal.getVariableValue( "S_C_x", 0.5f * 0.45f );
// Default resistance of the road, F = - m * g * C_r (for good quality road)
@ -223,6 +228,7 @@ public final class RoutingContext
public double trafficSourceMinDist;
public boolean showspeed;
public boolean showSpeedProfile;
public boolean inverseRouting;
public OsmPrePath firstPrePath;

View file

@ -916,6 +916,7 @@ public class RoutingEngine extends Thread
logInfo( "found track at cost " + path.cost + " nodesVisited = " + nodesVisited );
OsmTrack t = compileTrack( path, verbose );
t.showspeed = routingContext.showspeed;
t.showSpeedProfile = routingContext.showSpeedProfile;
return t;
}

View file

@ -252,16 +252,17 @@ final class StdPath extends OsmPath
if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9 )
{
// Use Tobler's hiking function for walking sections
speed = 6 * FastMath.exp(-3.5 * Math.abs( incline + 0.05)) / 3.6;
speed = rc.maxSpeed * 3.6;
speed = (speed * FastMath.exp(-3.5 * Math.abs( incline + 0.05))) / 3.6;
}
else if (rc.bikeMode)
{
speed = solveCubic( rc.S_C_x, f_roll, rc.bikerPower );
speed = Math.min(speed, wayMaxspeed);
}
else
else // all other
{
return;
speed = wayMaxspeed;
}
float dt = (float) ( dist / speed );
totalTime += dt;