patch times and turns (volker)

This commit is contained in:
Arndt Brenschede 2019-04-17 12:36:57 +02:00
parent d719877892
commit 02b8202001
5 changed files with 63 additions and 9 deletions

View file

@ -334,6 +334,11 @@ public final class OsmTrack
if ( t.voiceHints != null ) if ( t.voiceHints != null )
{ {
if (ourSize > 0){
for (VoiceHint hint : t.voiceHints.list) {
hint.indexInTrack = hint.indexInTrack + ourSize -1;
}
}
if ( voiceHints == null ) if ( voiceHints == null )
{ {
voiceHints = t.voiceHints; voiceHints = t.voiceHints;
@ -435,13 +440,31 @@ public final class OsmTrack
if ( turnInstructionMode == 3) // osmand style if ( turnInstructionMode == 3) // osmand style
{ {
float lastRteTime = voiceHints.list.get(0).getTime();
sb.append(" <rte>\n"); sb.append(" <rte>\n");
for( VoiceHint hint: voiceHints.list )
for( int i = 0 ; i < voiceHints.list.size(); i++ )
{ {
VoiceHint hint = voiceHints.list.get(i);
sb.append(" <rtept lat=\"").append( formatILat( hint.ilat ) ).append( "\" lon=\"" ) sb.append(" <rtept lat=\"").append( formatILat( hint.ilat ) ).append( "\" lon=\"" )
.append( formatILon( hint.ilon ) ).append( "\">\n" ) .append( formatILon( hint.ilon ) ).append( "\">\n" )
.append ( " <desc>" ).append( hint.getMessageString() ).append( "</desc>\n <extensions>\n <turn>" ) .append ( " <desc>" ).append( hint.getMessageString() ).append( "</desc>\n <extensions>\n");
.append( hint.getCommandString() ).append("</turn>\n <turn-angle>").append( "" + hint.angle )
float rteTime;
if (i < voiceHints.list.size() -1) {
rteTime = voiceHints.list.get(i + 1).getTime();
} else {
rteTime = nodes.get(nodes.size() - 1).getTime();
}
if ( rteTime != lastRteTime ) // add timing only if available
{
double t = rteTime - lastRteTime;
sb.append( " <time>" ).append( "" + (int)(t+0.5) ).append( "</time>\n" );
lastRteTime = rteTime;
}
sb.append(" <turn>" ).append( hint.getCommandString() ).append("</turn>\n <turn-angle>").append( "" + (int)hint.angle )
.append("</turn-angle>\n <offset>").append( "" + hint.indexInTrack ).append("</offset>\n </extensions>\n </rtept>\n"); .append("</turn-angle>\n <offset>").append( "" + hint.indexInTrack ).append("</offset>\n </extensions>\n </rtept>\n");
} }
sb.append("</rte>\n"); sb.append("</rte>\n");
@ -693,6 +716,22 @@ public final class OsmTrack
return format1( getTotalSeconds()/60. ) + "m"; return format1( getTotalSeconds()/60. ) + "m";
} }
public String getFormattedTime2()
{
int seconds = (int)(getTotalSeconds() + 0.5);
int hours = seconds/3600;
int minutes = (seconds - hours * 3600) / 60;
seconds = seconds - hours * 3600 - minutes * 60;
String time = "";
if (hours != 0)
time = "" + hours + "h ";
if (minutes != 0)
time = time + minutes + "m ";
if (seconds != 0)
time = time + seconds + "s";
return time;
}
public String getFormattedEnergy() public String getFormattedEnergy()
{ {
return format1( energy/3600000. ) + "kwh"; return format1( energy/3600000. ) + "kwh";

View file

@ -168,7 +168,7 @@ public class RoutingEngine extends Thread
+ " plain-ascend = " + track.plainAscend + " cost=" + track.cost; + " plain-ascend = " + track.plainAscend + " cost=" + track.cost;
if ( track.energy != 0 ) if ( track.energy != 0 )
{ {
track.message += " energy=" + track.getFormattedEnergy() + " time=" + track.getFormattedTime(); track.message += " energy=" + track.getFormattedEnergy() + " time=" + track.getFormattedTime2();
} }
track.name = "brouter_" + routingContext.getProfileName() + "_" + i; track.name = "brouter_" + routingContext.getProfileName() + "_" + i;
@ -1322,6 +1322,11 @@ public class RoutingEngine extends Thread
return foundTrack.plainAscend; return foundTrack.plainAscend;
} }
public String getTime()
{
return foundTrack.getFormattedTime2();
}
public OsmTrack getFoundTrack() public OsmTrack getFoundTrack()
{ {
return foundTrack; return foundTrack;

View file

@ -238,6 +238,15 @@ final class StdPath extends OsmPath
elevation_buffer += delta_h; elevation_buffer += delta_h;
double incline = calcIncline( dist ); double incline = calcIncline( dist );
double wayMaxspeed;
wayMaxspeed = rc.expctxWay.getMaxspeed() / 3.6f;
if (wayMaxspeed == 0)
{
wayMaxspeed = rc.maxSpeed;
}
wayMaxspeed = Math.min(wayMaxspeed,rc.maxSpeed);
double speed; // Travel speed double speed; // Travel speed
double f_roll = rc.totalMass * GRAVITY * ( rc.defaultC_r + incline ); double f_roll = rc.totalMass * GRAVITY * ( rc.defaultC_r + incline );
if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9 ) if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9 )
@ -248,7 +257,7 @@ final class StdPath extends OsmPath
else if (rc.bikeMode) else if (rc.bikeMode)
{ {
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, wayMaxspeed);
} }
else else
{ {

View file

@ -13,7 +13,7 @@ public final class BExpressionContextWay extends BExpressionContext implements T
private boolean decodeForbidden = true; private boolean decodeForbidden = true;
private static String[] buildInVariables = private static String[] buildInVariables =
{ "costfactor", "turncost", "uphillcostfactor", "downhillcostfactor", "initialcost", "nodeaccessgranted", "initialclassifier", "trafficsourcedensity", "istrafficbackbone", "priorityclassifier", "classifiermask" }; { "costfactor", "turncost", "uphillcostfactor", "downhillcostfactor", "initialcost", "nodeaccessgranted", "initialclassifier", "trafficsourcedensity", "istrafficbackbone", "priorityclassifier", "classifiermask", "maxspeed" };
protected String[] getBuildInVariableNames() protected String[] getBuildInVariableNames()
{ {
@ -31,6 +31,7 @@ public final class BExpressionContextWay extends BExpressionContext implements T
public float getIsTrafficBackbone() { return getBuildInVariable(8); } public float getIsTrafficBackbone() { return getBuildInVariable(8); }
public float getPriorityClassifier() { return getBuildInVariable(9); } public float getPriorityClassifier() { return getBuildInVariable(9); }
public float getClassifierMask() { return getBuildInVariable(10); } public float getClassifierMask() { return getBuildInVariable(10); }
public float getMaxspeed() { return getBuildInVariable(11); }
public BExpressionContextWay( BExpressionMetaData meta ) public BExpressionContextWay( BExpressionMetaData meta )
{ {

View file

@ -807,8 +807,8 @@ public class BRouterView extends View
else else
{ {
String memstat = memoryClass + "mb pathPeak " + ((cr.getPathPeak()+500)/1000) + "k"; String memstat = memoryClass + "mb pathPeak " + ((cr.getPathPeak()+500)/1000) + "k";
String result = "version = BRouter-1.4.9\n" + "mem = " + memstat + "\ndistance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend() String result = "version = BRouter-1.4.11\n" + "mem = " + memstat + "\ndistance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend()
+ " m\n" + "plain ascend = " + cr.getPlainAscend(); + " m\n" + "plain ascend = " + cr.getPlainAscend() + " m\n" + "estimated time = " + cr.getTime();
rawTrack = cr.getFoundRawTrack(); rawTrack = cr.getFoundRawTrack();