additional condition detail
This commit is contained in:
parent
62bae1fb99
commit
92d12e36bc
1 changed files with 42 additions and 8 deletions
|
|
@ -386,15 +386,49 @@ fn symbolCodeToWeatherCode(symbol: []const u8) types.WeatherCode {
|
|||
fn symbolCodeToCondition(symbol: []const u8) []const u8 {
|
||||
var it = std.mem.splitScalar(u8, symbol, '_');
|
||||
const metno_weather_code = it.next().?;
|
||||
|
||||
const Prefix = enum {
|
||||
heavy,
|
||||
light,
|
||||
none,
|
||||
};
|
||||
// Check for intensity prefix
|
||||
const prefix: Prefix = if (std.mem.startsWith(u8, metno_weather_code, "heavy"))
|
||||
.heavy
|
||||
else if (std.mem.startsWith(u8, metno_weather_code, "light"))
|
||||
.light
|
||||
else
|
||||
.none;
|
||||
|
||||
if (std.mem.eql(u8, metno_weather_code, "clearsky")) return "Clear";
|
||||
if (std.mem.eql(u8, metno_weather_code, "partlycloudy")) return "Partly cloudy";
|
||||
if (std.mem.eql(u8, metno_weather_code, "fair")) return "Fair";
|
||||
if (std.mem.eql(u8, metno_weather_code, "cloudy")) return "Cloudy";
|
||||
if (std.mem.eql(u8, metno_weather_code, "fog")) return "Fog";
|
||||
if (std.mem.eql(u8, metno_weather_code, "thunder")) return "Thunderstorm";
|
||||
if (std.mem.eql(u8, metno_weather_code, "rain")) return "Rain";
|
||||
if (std.mem.eql(u8, metno_weather_code, "sleet")) return "Sleet";
|
||||
if (std.mem.eql(u8, metno_weather_code, "snow")) return "Snow";
|
||||
if (std.mem.indexOf(u8, metno_weather_code, "thunder") != null)
|
||||
return switch (prefix) {
|
||||
.heavy => "Heavy thunderstorm",
|
||||
.light => "Light thunderstorm",
|
||||
.none => "Thunderstorm",
|
||||
};
|
||||
if (std.mem.indexOf(u8, metno_weather_code, "rain") != null)
|
||||
return switch (prefix) {
|
||||
.heavy => "Heavy rain",
|
||||
.light => "Light rain",
|
||||
.none => "Rain",
|
||||
};
|
||||
if (std.mem.indexOf(u8, metno_weather_code, "sleet") != null)
|
||||
return switch (prefix) {
|
||||
.heavy => "Heavy sleet",
|
||||
.light => "Light sleet",
|
||||
.none => "Sleet",
|
||||
};
|
||||
if (std.mem.indexOf(u8, metno_weather_code, "snow") != null)
|
||||
return switch (prefix) {
|
||||
.heavy => "Heavy snow",
|
||||
.light => "Light snow",
|
||||
.none => "Snow",
|
||||
};
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue