diff --git a/brouter-core/src/main/java/btools/router/OsmTrack.java b/brouter-core/src/main/java/btools/router/OsmTrack.java index b18415a..f31b04c 100644 --- a/brouter-core/src/main/java/btools/router/OsmTrack.java +++ b/brouter-core/src/main/java/btools/router/OsmTrack.java @@ -454,12 +454,7 @@ public final class OsmTrack .append( formatILon( nodes.get(0).getILon() ) ).append( "\">\n" ) .append ( " start\n \n"); - float rteTime; - if(!voiceHints.list.isEmpty()){ - rteTime = voiceHints.list.get(0).getTime(); - }else{ - rteTime = 0; - } + float rteTime = getVoiceHintTime( 0 ); if ( rteTime != lastRteTime ) // add timing only if available { @@ -476,11 +471,7 @@ public final class OsmTrack .append( formatILon( hint.ilon ) ).append( "\">\n" ) .append ( " " ).append( hint.getMessageString() ).append( "\n \n"); - if (i < voiceHints.list.size() -1) { - rteTime = voiceHints.list.get(i + 1).getTime(); - } else { - rteTime = nodes.get(nodes.size() - 1).getTime(); - } + rteTime = getVoiceHintTime( i+1 ); if ( rteTime != lastRteTime ) // add timing only if available { @@ -502,16 +493,17 @@ public final class OsmTrack if ( turnInstructionMode == 2 ) // locus style { - float lastRteTime = 0.f; + float lastRteTime = getVoiceHintTime( 0 ); - for( VoiceHint hint: voiceHints.list ) + for( int i=0; i" ) .append( hint.selev == Short.MIN_VALUE ? "" : "" + (hint.selev / 4.) + "" ) .append( "" ).append( hint.getMessageString() ).append( "" ) .append( "" ).append( "" + hint.distanceToNext ).append( "" ); - float rteTime = hint.getTime(); + float rteTime = getVoiceHintTime( i+1 ); if ( rteTime != lastRteTime ) // add timing only if available { double t = rteTime - lastRteTime; @@ -1056,6 +1048,23 @@ public final class OsmTrack } } + private float getVoiceHintTime( int i ) + { + if ( voiceHints.list.isEmpty() ) + { + return 0f; + } + if ( i < voiceHints.list.size() ) + { + return voiceHints.list.get(i).getTime(); + } + if ( nodes.isEmpty() ) + { + return 0f; + } + return nodes.get(nodes.size() - 1).getTime(); + } + private MessageData startSection( OsmPathElement element, OsmPathElement root ) { diff --git a/brouter-core/src/main/java/btools/router/VoiceHint.java b/brouter-core/src/main/java/btools/router/VoiceHint.java index 9634ee2..1e15bac 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHint.java +++ b/brouter-core/src/main/java/btools/router/VoiceHint.java @@ -38,7 +38,7 @@ public class VoiceHint public float getTime() { - return goodWay == null ? 0.f : goodWay.time; + return oldWay == null ? 0.f : oldWay.time; } float angle;