From 4132aa0f83ad6cab4d670926394281f58d64a18b Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 26 Apr 2025 10:10:29 -0700 Subject: [PATCH] Add the wind annoyance factor from Buddy and placeholders for a new Feels Like calculation. --- lib/helpers/json.dart | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/helpers/json.dart b/lib/helpers/json.dart index dafbf07..40ef298 100644 --- a/lib/helpers/json.dart +++ b/lib/helpers/json.dart @@ -12,7 +12,9 @@ String formatOpenWeatherData(var data) { humidity = pullOpenWeatherHumidity(data); String windChill = getWindChill(temp, windSpeed), - heatIndex = getHeatIndex(temp, humidity); + heatIndex = getHeatIndex(temp, humidity), + windAnnoyance = getWindAnnoyance(temp, windSpeed), + feelsLike = getUniversalThermalClimateIndex(); String comfort = ""; @@ -22,6 +24,8 @@ String formatOpenWeatherData(var data) { " and humidity of $humidity$humidityUnits." " $windChill" " $heatIndex" + " $windAnnoyance" + " $feelsLike" " $comfort"; final String doubleSpace = " ", singleSpace = " "; @@ -142,3 +146,32 @@ String getHeatIndex(String temp, String humidity) { } return ""; } + +double calcWindAnnoyance(double temp, double windSpeed) { + double windAnnoyance = (temp / (windSpeed * (windSpeed * 0.05))); + + if (debug) { + debugPrint("DEBUG: windAnnoyance = '$windAnnoyance'"); + } + return windAnnoyance; +} + +String getWindAnnoyance(String temp, String windSpeed) { + double temperature = double.parse(temp); + double wind = double.parse(windSpeed); + + double windAnnoyance = calcWindAnnoyance(temperature, wind); + + if (windAnnoyance < 3) { + return "Wind may be a bit much for the temperature."; + } + return ""; +} + +double calcUniversalThermalClimateIndex() { + return 0; +} + +String getUniversalThermalClimateIndex() { + return ""; +}