Fix headwind forecast field does not show preview (#165)
This commit is contained in:
parent
917770e45a
commit
1fe7eb1a16
@ -55,7 +55,6 @@ class HeadwindForecastDataType(karooSystem: KarooSystemService) : LineGraphForec
|
||||
}
|
||||
|
||||
val headwindPoints = try {
|
||||
if (upcomingRoute != null){
|
||||
(0..<HEADWIND_SAMPLE_COUNT).mapNotNull { i ->
|
||||
val t = i / HEADWIND_SAMPLE_COUNT.toDouble()
|
||||
|
||||
@ -67,6 +66,11 @@ class HeadwindForecastDataType(karooSystem: KarooSystemService) : LineGraphForec
|
||||
y = headwindSpeed)
|
||||
}
|
||||
|
||||
if (upcomingRoute == null) {
|
||||
Log.e(KarooHeadwindExtension.TAG, "Upcoming route is null")
|
||||
return@mapNotNull null
|
||||
}
|
||||
|
||||
val beforeLineData = lineData.getOrNull(floor((lineData.size) * t).toInt().coerceAtLeast(0)) ?: lineData.firstOrNull()
|
||||
val afterLineData = lineData.getOrNull(ceil((lineData.size) * t).toInt().coerceAtLeast(0)) ?: lineData.lastOrNull()
|
||||
|
||||
@ -115,9 +119,6 @@ class HeadwindForecastDataType(karooSystem: KarooSystemService) : LineGraphForec
|
||||
y = headwindSpeedInUserUnit.toFloat()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
} catch(e: Exception) {
|
||||
Log.e(KarooHeadwindExtension.TAG, "Error calculating headwind points", e)
|
||||
emptyList()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user