diff --git a/.gitignore b/.gitignore index 4a9b72a..32b0ae5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml .gradle +.idea/ /local.properties /.idea/caches /.idea/gradle.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 681f41a..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
-
-
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 82fb904..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/RouteServer.xml b/.idea/runConfigurations/RouteServer.xml deleted file mode 100644 index c6a8cca..0000000 --- a/.idea/runConfigurations/RouteServer.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/brouter-core/src/main/java/btools/router/OsmTrack.java b/brouter-core/src/main/java/btools/router/OsmTrack.java index f836b4b..0c4e516 100644 --- a/brouter-core/src/main/java/btools/router/OsmTrack.java +++ b/brouter-core/src/main/java/btools/router/OsmTrack.java @@ -45,6 +45,7 @@ public final class OsmTrack public boolean isDirty; public boolean showspeed; + public boolean showSpeedProfile; public List pois = new ArrayList(); @@ -62,8 +63,6 @@ public final class OsmTrack private VoiceHintList voiceHints; - private boolean sendSpeedProfile; - public String message = null; public ArrayList 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 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 ) diff --git a/brouter-core/src/main/java/btools/router/RoutingContext.java b/brouter-core/src/main/java/btools/router/RoutingContext.java index 204a072..19bcc7b 100644 --- a/brouter-core/src/main/java/btools/router/RoutingContext.java +++ b/brouter-core/src/main/java/btools/router/RoutingContext.java @@ -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; diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index 18585a1..9d247cb 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -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; } diff --git a/brouter-core/src/main/java/btools/router/StdPath.java b/brouter-core/src/main/java/btools/router/StdPath.java index a1db614..b6b527f 100644 --- a/brouter-core/src/main/java/btools/router/StdPath.java +++ b/brouter-core/src/main/java/btools/router/StdPath.java @@ -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;