Commit 03ce6234 authored by Nate Graham's avatar Nate Graham 💤
Browse files

[Weather data engine] Handle windy conditions in NOAA backend

Summary:
Right now windy conditions are not handled at all. I live in an area with very frequent
windy conditions especially during certain times of year so this is annoying because I
see the purple question mark icon a lot, which in the past has made me stop using the
weather widget.

This patch implements handling for windy + clear and cloudy conditions for NOAA. I
don't know how to implement this for Wettercom.

Depends on D24537

Test Plan:
Before: {F7568603}
After: {F7568554}

Reviewers: kossebau, #plasma, spstarr

Reviewed By: #plasma, spstarr

Subscribers: spstarr, plasma-devel, #vdg

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24483
parent 63dca884
......@@ -146,12 +146,20 @@ QString IonInterface::getWeatherIcon(ConditionIcons condition) const
switch (condition) {
case ClearDay:
return QStringLiteral("weather-clear");
case ClearWindyDay:
return QStringLiteral("weather-clear-wind");
case FewCloudsDay:
return QStringLiteral("weather-few-clouds");
case FewCloudsWindyDay:
return QStringLiteral("weather-few-clouds-wind");
case PartlyCloudyDay:
return QStringLiteral("weather-clouds");
case PartlyCloudyWindyDay:
return QStringLiteral("weather-clouds-wind");
case Overcast:
return QStringLiteral("weather-overcast");
case OvercastWindy:
return QStringLiteral("weather-overcast-wind");
case Rain:
return QStringLiteral("weather-showers");
case LightRain:
......@@ -180,10 +188,16 @@ QString IonInterface::getWeatherIcon(ConditionIcons condition) const
return QStringLiteral("weather-snow-rain");
case FewCloudsNight:
return QStringLiteral("weather-few-clouds-night");
case FewCloudsWindyNight:
return QStringLiteral("weather-few-clouds-wind-night");
case PartlyCloudyNight:
return QStringLiteral("weather-clouds-night");
case PartlyCloudyWindyNight:
return QStringLiteral("weather-clouds-wind-night");
case ClearNight:
return QStringLiteral("weather-clear-night");
case ClearWindyNight:
return QStringLiteral("weather-clear-wind-night");
case Mist:
return QStringLiteral("weather-fog");
case Haze:
......
......@@ -119,10 +119,10 @@ class ION_EXPORT IonInterface : public Plasma::DataEngine
public:
enum ConditionIcons { ClearDay = 1, FewCloudsDay, PartlyCloudyDay, Overcast,
enum ConditionIcons { ClearDay = 1, ClearWindyDay, FewCloudsDay, FewCloudsWindyDay, PartlyCloudyDay, PartlyCloudyWindyDay, Overcast, OvercastWindy,
Rain, LightRain, Showers, ChanceShowersDay, Thunderstorm, Hail,
Snow, LightSnow, Flurries, FewCloudsNight, ChanceShowersNight,
PartlyCloudyNight, ClearNight, Mist, Haze, FreezingRain,
Snow, LightSnow, Flurries, FewCloudsNight, FewCloudsWindyNight, ChanceShowersNight,
PartlyCloudyNight, PartlyCloudyWindyNight, ClearNight, ClearWindyNight, Mist, Haze, FreezingRain,
RainSnow, FreezingDrizzle, ChanceThunderstormDay, ChanceThunderstormNight,
ChanceSnowDay, ChanceSnowNight, NotAvailable
};
......
......@@ -734,29 +734,64 @@ IonInterface::ConditionIcons NOAAIon::getConditionIcon(const QString& weather, b
weather.contains(QLatin1String("mostly clear")) || weather.contains(QLatin1String("increasing clouds")) ||
weather.contains(QLatin1String("becoming cloudy")) || weather.contains(QLatin1String("clearing")) ||
weather.contains(QLatin1String("decreasing clouds")) || weather.contains(QLatin1String("becoming sunny"))) {
result = isDayTime ? IonInterface::FewCloudsDay : IonInterface::FewCloudsNight;
if (weather.contains(QLatin1String("breezy")) ||
weather.contains(QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
result = isDayTime ? IonInterface::FewCloudsWindyDay : IonInterface::FewCloudsWindyNight;
} else {
result = isDayTime ? IonInterface::FewCloudsDay : IonInterface::FewCloudsNight;
}
} else if (weather.contains(QLatin1String("partly cloudy")) || weather.contains(QLatin1String("partly sunny")) ||
weather.contains(QLatin1String("partly clear"))) {
result = isDayTime ? IonInterface::PartlyCloudyDay : IonInterface::PartlyCloudyNight;
if (weather.contains(QLatin1String("breezy")) ||
weather.contains(QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
result = isDayTime ? IonInterface::PartlyCloudyWindyDay : IonInterface::PartlyCloudyWindyNight;
} else {
result = isDayTime ? IonInterface::PartlyCloudyDay : IonInterface::PartlyCloudyNight;
}
} else if (weather.contains(QLatin1String("overcast")) || weather.contains(QLatin1String("cloudy"))) {
result = IonInterface::Overcast;
if (weather.contains(QLatin1String("breezy")) ||
weather.contains(QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
result = IonInterface::OvercastWindy;
} else {
result = IonInterface::Overcast;
}
} else if (weather.contains(QLatin1String("haze")) || weather.contains(QLatin1String("smoke")) ||
weather.contains(QLatin1String("dust")) || weather.contains(QLatin1String("sand"))) {
result = IonInterface::Haze;
} else if (weather.contains(QLatin1String("fair")) || weather.contains(QLatin1String("clear")) || weather.contains(QLatin1String("sunny"))) {
result = isDayTime ? IonInterface::ClearDay : IonInterface::ClearNight;
if (weather.contains(QLatin1String("breezy")) ||
weather.contains(QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
result = isDayTime ? IonInterface::ClearWindyDay : IonInterface::ClearWindyNight;
} else {
result = isDayTime ? IonInterface::ClearDay : IonInterface::ClearNight;
}
} else if (weather.contains(QLatin1String("fog"))) {
result = IonInterface::Mist;
} else if (weather.contains(QLatin1String("hot"))) {
// temperature condition has not hint about air ingredients, so let's assume the sky is clear when it is hot
result = isDayTime ? IonInterface::ClearDay : IonInterface::ClearNight;
if (weather.contains(QLatin1String("breezy")) ||
weather.contains(QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
result = isDayTime ? IonInterface::ClearWindyDay : IonInterface::ClearWindyNight;
} else {
result = isDayTime ? IonInterface::ClearDay : IonInterface::ClearNight;
}
} else if (weather.contains (QLatin1String("breezy")) ||
weather.contains (QLatin1String("wind")) ||
weather.contains (QLatin1String("gust"))) {
// Assume a clear sky when it's windy but no clouds have been mentioned
result = isDayTime ? IonInterface::ClearWindyDay : IonInterface::ClearWindyNight;
} else {
result = IonInterface::NotAvailable;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment