shift precision cutover of avgSpeed display form 10%/1% to more realistic 5%/0.5%

This commit is contained in:
sonora 2015-07-18 18:25:38 +02:00
parent 1d42e6c10b
commit 5f7b295614

View file

@ -123,16 +123,16 @@ public class OsmAndFormatter {
ApplicationMode am = settings.getApplicationMode(); ApplicationMode am = settings.getApplicationMode();
float kmh = metersperseconds * 3.6f; float kmh = metersperseconds * 3.6f;
if (mc == MetricsConstants.KILOMETERS_AND_METERS) { if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
if (kmh >= 10 || am.hasFastSpeed()) { // e.g. car case and for high-speeds: Display rounded to 1 km/h (5% precision at 20 km/h)
// case of car if (kmh >= 20 || am.hasFastSpeed()) {
return ((int) Math.round(kmh)) + " " + ctx.getString(R.string.km_h); return ((int) Math.round(kmh)) + " " + ctx.getString(R.string.km_h);
} }
// for smaller values display 1 decimal digit x.y km/h, (0.5% precision at 20 km/h)
int kmh10 = (int) Math.round(kmh * 10f); int kmh10 = (int) Math.round(kmh * 10f);
// for smaller values display 1 decimal digit (x.0 km/h instead of x km/h)
return (kmh10 / 10f) + " " + ctx.getString(R.string.km_h); return (kmh10 / 10f) + " " + ctx.getString(R.string.km_h);
} else { } else {
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE; float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
if (mph >= 10 || am.hasFastSpeed()) { if (mph >= 20 || am.hasFastSpeed()) {
return ((int) Math.round(mph)) + " " + ctx.getString(R.string.mile_per_hour); return ((int) Math.round(mph)) + " " + ctx.getString(R.string.mile_per_hour);
} else { } else {
int mph10 = (int) Math.round(mph * 10f); int mph10 = (int) Math.round(mph * 10f);