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,
|
"latestVersionCode" to android.defaultConfig.versionCode,
|
||||||
"developer" to "github.com/timklge",
|
"developer" to "github.com/timklge",
|
||||||
"description" to "Open-source extension that provides headwind direction, wind speed and other weather data fields.",
|
"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" +
|
"* Colorize field background instead of text\n" +
|
||||||
"* Add OpenWeatherMap support contributed by lockevod\n" +
|
"* Add OpenWeatherMap support contributed by lockevod\n" +
|
||||||
"* Add tailwind field\n" +
|
"* Add tailwind field\n" +
|
||||||
|
|||||||
@ -263,6 +263,7 @@ fun lerpWeather(
|
|||||||
temperature = start.temperature + (end.temperature - start.temperature) * factor,
|
temperature = start.temperature + (end.temperature - start.temperature) * factor,
|
||||||
relativeHumidity = lerpNullable(start.relativeHumidity, end.relativeHumidity, factor),
|
relativeHumidity = lerpNullable(start.relativeHumidity, end.relativeHumidity, factor),
|
||||||
precipitation = start.precipitation + (end.precipitation - start.precipitation) * factor,
|
precipitation = start.precipitation + (end.precipitation - start.precipitation) * factor,
|
||||||
|
precipitationProbability = lerpNullable(start.precipitationProbability, end.precipitationProbability, factor),
|
||||||
cloudCover = lerpNullable(start.cloudCover, end.cloudCover, factor),
|
cloudCover = lerpNullable(start.cloudCover, end.cloudCover, factor),
|
||||||
surfacePressure = lerpNullable(start.surfacePressure, end.surfacePressure, factor),
|
surfacePressure = lerpNullable(start.surfacePressure, end.surfacePressure, factor),
|
||||||
sealevelPressure = lerpNullable(start.sealevelPressure, end.sealevelPressure, factor),
|
sealevelPressure = lerpNullable(start.sealevelPressure, end.sealevelPressure, factor),
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import de.timklge.karooheadwind.TemperatureUnit
|
|||||||
import de.timklge.karooheadwind.weatherprovider.WeatherInterpretation
|
import de.timklge.karooheadwind.weatherprovider.WeatherInterpretation
|
||||||
import io.hammerhead.karooext.KarooSystemService
|
import io.hammerhead.karooext.KarooSystemService
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
import kotlin.math.ceil
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -38,7 +39,7 @@ fun PrecipitationForecast(
|
|||||||
Column(modifier = GlanceModifier.fillMaxHeight().padding(1.dp).width(86.dp), horizontalAlignment = rowAlignment) {
|
Column(modifier = GlanceModifier.fillMaxHeight().padding(1.dp).width(86.dp), horizontalAlignment = rowAlignment) {
|
||||||
Row(modifier = GlanceModifier.defaultWeight().fillMaxWidth(), horizontalAlignment = rowAlignment, verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = GlanceModifier.defaultWeight().fillMaxWidth(), horizontalAlignment = rowAlignment, verticalAlignment = Alignment.CenterVertically) {
|
||||||
val precipitationProbabilityText = if (precipitationProbability != null) "${precipitationProbability}% " else ""
|
val precipitationProbabilityText = if (precipitationProbability != null) "${precipitationProbability}% " else ""
|
||||||
val precipitationText = if (precipitation > 0) precipitation.toString() else ""
|
val precipitationText = precipitation.toString()
|
||||||
Text(
|
Text(
|
||||||
text = "${precipitationProbabilityText}${precipitationText}",
|
text = "${precipitationProbabilityText}${precipitationText}",
|
||||||
style = TextStyle(color = ColorProvider(Color.Black, Color.White), fontFamily = FontFamily.Monospace, fontSize = TextUnit(24f, TextUnitType.Sp), textAlign = TextAlign.Center)
|
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
|
isImperial: Boolean
|
||||||
) {
|
) {
|
||||||
PrecipitationForecast(
|
PrecipitationForecast(
|
||||||
precipitation = precipitation.roundToInt().coerceAtLeast(0),
|
precipitation = ceil(precipitation).toInt(),
|
||||||
precipitationProbability = precipitationProbability,
|
precipitationProbability = precipitationProbability,
|
||||||
distance = distance,
|
distance = distance,
|
||||||
timeLabel = timeLabel,
|
timeLabel = timeLabel,
|
||||||
|
|||||||
@ -20,6 +20,7 @@ data class OpenMeteoWeatherForecastData(
|
|||||||
WeatherData(
|
WeatherData(
|
||||||
temperature = temperature[index],
|
temperature = temperature[index],
|
||||||
precipitation = precipitation[index],
|
precipitation = precipitation[index],
|
||||||
|
precipitationProbability = precipitationProbability[index].toDouble(),
|
||||||
windSpeed = windSpeed[index],
|
windSpeed = windSpeed[index],
|
||||||
windDirection = windDirection[index],
|
windDirection = windDirection[index],
|
||||||
windGusts = windGusts[index],
|
windGusts = windGusts[index],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user