Fix speed parsing
This commit is contained in:
parent
5778ca03d3
commit
e2d2502867
2 changed files with 4 additions and 1 deletions
|
@ -243,7 +243,7 @@ object OsmandFormatter {
|
||||||
SpeedConstants.NAUTICALMILES_PER_HOUR -> kmh * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE
|
SpeedConstants.NAUTICALMILES_PER_HOUR -> kmh * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE
|
||||||
SpeedConstants.MINUTES_PER_KILOMETER -> {
|
SpeedConstants.MINUTES_PER_KILOMETER -> {
|
||||||
if (metersPerSeconds < 0.111111111) {
|
if (metersPerSeconds < 0.111111111) {
|
||||||
return "-" + mc.toShortString(ctx)
|
return "-" + if (useLocalizedString) mc.toShortString(ctx) else mc.getDefaultString()
|
||||||
}
|
}
|
||||||
METERS_IN_KILOMETER / (metersPerSeconds * 60)
|
METERS_IN_KILOMETER / (metersPerSeconds * 60)
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,6 +332,9 @@ object OsmandLocationUtils {
|
||||||
|
|
||||||
fun parseSpeed(speedS: String): Double {
|
fun parseSpeed(speedS: String): Double {
|
||||||
try {
|
try {
|
||||||
|
if (!speedS.contains(" ")) {
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
val speedSplit = speedS.split(" ")
|
val speedSplit = speedS.split(" ")
|
||||||
val speedVal = speedSplit.first().toDouble()
|
val speedVal = speedSplit.first().toDouble()
|
||||||
val speedFormat = OsmandFormatter.SpeedConstants.values().firstOrNull { it.getDefaultString() == speedSplit.last() }
|
val speedFormat = OsmandFormatter.SpeedConstants.values().firstOrNull { it.getDefaultString() == speedSplit.last() }
|
||||||
|
|
Loading…
Reference in a new issue