Fix precipitation forecast datafield shows empty values (#89)
* Fix forecasted precipitation of 0 is shown as empty text * Fix precipitation probability is not interpolated * Add changelog note * Round up precipitation values in precipitation forecast field * Fix open meteo precipitation probability is not copied over
This commit is contained in:
parent
fee38d1150
commit
885c8746cf
@ -90,7 +90,8 @@ tasks.register("generateManifest") {
|
||||
"latestVersionCode" to android.defaultConfig.versionCode,
|
||||
"developer" to "github.com/timklge",
|
||||
"description" to "Open-source extension that provides headwind direction, wind speed and other weather data fields.",
|
||||
"releaseNotes" to "* Interpolate between forecasted and current weather data\n" +
|
||||
"releaseNotes" to "* Fix precipitation forecast field\n" +
|
||||
"* Interpolate between forecasted and current weather data\n" +
|
||||
"* Colorize field background instead of text\n" +
|
||||
"* Add OpenWeatherMap support contributed by lockevod\n" +
|
||||
"* Add tailwind field\n" +
|
||||
|
||||
@ -263,6 +263,7 @@ fun lerpWeather(
|
||||
temperature = start.temperature + (end.temperature - start.temperature) * factor,
|
||||
relativeHumidity = lerpNullable(start.relativeHumidity, end.relativeHumidity, factor),
|
||||
precipitation = start.precipitation + (end.precipitation - start.precipitation) * factor,
|
||||
precipitationProbability = lerpNullable(start.precipitationProbability, end.precipitationProbability, factor),
|
||||
cloudCover = lerpNullable(start.cloudCover, end.cloudCover, factor),
|
||||
surfacePressure = lerpNullable(start.surfacePressure, end.surfacePressure, factor),
|
||||
sealevelPressure = lerpNullable(start.sealevelPressure, end.sealevelPressure, factor),
|
||||
|
||||
@ -24,6 +24,7 @@ import de.timklge.karooheadwind.TemperatureUnit
|
||||
import de.timklge.karooheadwind.weatherprovider.WeatherInterpretation
|
||||
import io.hammerhead.karooext.KarooSystemService
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@Composable
|
||||
@ -38,7 +39,7 @@ fun PrecipitationForecast(
|
||||
Column(modifier = GlanceModifier.fillMaxHeight().padding(1.dp).width(86.dp), horizontalAlignment = rowAlignment) {
|
||||
Row(modifier = GlanceModifier.defaultWeight().fillMaxWidth(), horizontalAlignment = rowAlignment, verticalAlignment = Alignment.CenterVertically) {
|
||||
val precipitationProbabilityText = if (precipitationProbability != null) "${precipitationProbability}% " else ""
|
||||
val precipitationText = if (precipitation > 0) precipitation.toString() else ""
|
||||
val precipitationText = precipitation.toString()
|
||||
Text(
|
||||
text = "${precipitationProbabilityText}${precipitationText}",
|
||||
style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontFamily = FontFamily.Monospace, fontSize = TextUnit(24f, TextUnitType.Sp), textAlign = TextAlign.Center)
|
||||
@ -97,7 +98,7 @@ class PrecipitationForecastDataType(karooSystem: KarooSystemService) : ForecastD
|
||||
isImperial: Boolean
|
||||
) {
|
||||
PrecipitationForecast(
|
||||
precipitation = precipitation.roundToInt().coerceAtLeast(0),
|
||||
precipitation = ceil(precipitation).toInt(),
|
||||
precipitationProbability = precipitationProbability,
|
||||
distance = distance,
|
||||
timeLabel = timeLabel,
|
||||
|
||||
@ -20,6 +20,7 @@ data class OpenMeteoWeatherForecastData(
|
||||
WeatherData(
|
||||
temperature = temperature[index],
|
||||
precipitation = precipitation[index],
|
||||
precipitationProbability = precipitationProbability[index].toDouble(),
|
||||
windSpeed = windSpeed[index],
|
||||
windDirection = windDirection[index],
|
||||
windGusts = windGusts[index],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user