Fix speed parsing

This commit is contained in:
Chumva 2019-12-11 10:12:36 +02:00
parent 5778ca03d3
commit e2d2502867
2 changed files with 4 additions and 1 deletions

View file

@ -243,7 +243,7 @@ object OsmandFormatter {
SpeedConstants.NAUTICALMILES_PER_HOUR -> kmh * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE
SpeedConstants.MINUTES_PER_KILOMETER -> {
if (metersPerSeconds < 0.111111111) {
return "-" + mc.toShortString(ctx)
return "-" + if (useLocalizedString) mc.toShortString(ctx) else mc.getDefaultString()
}
METERS_IN_KILOMETER / (metersPerSeconds * 60)
}

View file

@ -332,6 +332,9 @@ object OsmandLocationUtils {
fun parseSpeed(speedS: String): Double {
try {
if (!speedS.contains(" ")) {
return 0.0
}
val speedSplit = speedS.split(" ")
val speedVal = speedSplit.first().toDouble()
val speedFormat = OsmandFormatter.SpeedConstants.values().firstOrNull { it.getDefaultString() == speedSplit.last() }