Merge pull request #317 from afischerdev/migrate-to-android11

Speed handling #301
This commit is contained in:
afischerdev 2021-07-08 13:46:47 +02:00 committed by GitHub
commit f8e600e43d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 199 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
*.iml *.iml
.gradle .gradle
.idea/
/local.properties /local.properties
/.idea/caches /.idea/caches
/.idea/gradle.xml /.idea/gradle.xml

View file

@ -1,116 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

View file

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
<option name="myDefaultNotNull" value="android.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="12">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="android.annotation.Nullable" />
<item index="7" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="11">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="android.annotation.NonNull" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View file

@ -1,16 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RouteServer" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="btools.server.RouteServer" />
<module name="brouter-server" />
<option name="PROGRAM_PARAMETERS" value="misc/segments4 misc/profiles2 ../customprofiles 17777 1 localhost" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="btools.server.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

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

View file

@ -166,6 +166,7 @@ public final class RoutingContext
trafficSourceMinDist = expctxGlobal.getVariableValue( "trafficSourceMinDist", 3000.f ); trafficSourceMinDist = expctxGlobal.getVariableValue( "trafficSourceMinDist", 3000.f );
showspeed = 0.f != expctxGlobal.getVariableValue( "showspeed", 0.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 ); inverseRouting = 0.f != expctxGlobal.getVariableValue( "inverseRouting", 0.f );
int tiMode = (int)expctxGlobal.getVariableValue( "turnInstructionMode", 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 // Total mass (biker + bike + luggages or hiker), in kg
totalMass = expctxGlobal.getVariableValue( "totalMass", 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
if (footMode) {
maxSpeed = expctxGlobal.getVariableValue( "maxSpeed", 6.f ) / 3.6;
} else {
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
S_C_x = expctxGlobal.getVariableValue( "S_C_x", 0.5f * 0.45f ); 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) // 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 double trafficSourceMinDist;
public boolean showspeed; public boolean showspeed;
public boolean showSpeedProfile;
public boolean inverseRouting; public boolean inverseRouting;
public OsmPrePath firstPrePath; public OsmPrePath firstPrePath;

View file

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

View file

@ -252,16 +252,17 @@ final class StdPath extends OsmPath
if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9 ) if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9 )
{ {
// Use Tobler's hiking function for walking sections // 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) 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, wayMaxspeed); speed = Math.min(speed, wayMaxspeed);
} }
else else // all other
{ {
return; speed = wayMaxspeed;
} }
float dt = (float) ( dist / speed ); float dt = (float) ( dist / speed );
totalTime += dt; totalTime += dt;