Fix mph for small speed
This commit is contained in:
parent
d7e4286d97
commit
873b26beb0
2 changed files with 13 additions and 2 deletions
|
@ -100,7 +100,13 @@ public class OsmAndFormatter {
|
|||
if(mc == MetricsConstants.KILOMETERS_AND_METERS){
|
||||
return ((int) kmh) + " " + ctx.getString(R.string.km_h);
|
||||
} else {
|
||||
return ((int) (kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE)) + " "+ ctx.getString(R.string.mile_per_hour);
|
||||
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
|
||||
if(mph >= 10) {
|
||||
return ((int) (mph)) + " "+ ctx.getString(R.string.mile_per_hour);
|
||||
} else {
|
||||
mph = ((int)mph*10f)/10f;
|
||||
return mph + " "+ ctx.getString(R.string.mile_per_hour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,12 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
public boolean updateInfo() {
|
||||
// draw speed
|
||||
if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
|
||||
if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > .3f) {
|
||||
// .3 mps == 1.08 kph
|
||||
float minDelta = .3f;
|
||||
// Update more often at walk/run speeds, since we give higher resolution
|
||||
// and use .02 instead of .03 to account for rounding effects.
|
||||
if (cachedSpeed < 6) minDelta = .015f;
|
||||
if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > minDelta) {
|
||||
cachedSpeed = map.getLastKnownLocation().getSpeed();
|
||||
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
|
|
Loading…
Reference in a new issue