weatherfeeder: split the former maximumdirect.net/weatherd project in two.
feedkit now contains a reusable core, while weatherfeeder is a concrete implementation that includes weather-specific functions.
This commit is contained in:
127
internal/standards/wmo_categories.go
Normal file
127
internal/standards/wmo_categories.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package standards
|
||||
|
||||
import "gitea.maximumdirect.net/ejr/weatherfeeder/internal/model"
|
||||
|
||||
// This file provides small, shared helper functions for reasoning about WMO codes.
|
||||
// These are intentionally "coarse" categories that are useful for business logic,
|
||||
// dashboards, and alerting decisions.
|
||||
//
|
||||
// Example uses:
|
||||
// - jogging suitability: precipitation? thunderstorm? freezing precip?
|
||||
// - quick glance: "is it cloudy?" "is there any precip?"
|
||||
// - downstream normalizers / aggregators
|
||||
|
||||
func IsThunderstorm(code model.WMOCode) bool {
|
||||
switch code {
|
||||
case 95, 96, 99:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsHail(code model.WMOCode) bool {
|
||||
switch code {
|
||||
case 96, 99:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsFog(code model.WMOCode) bool {
|
||||
switch code {
|
||||
case 45, 48:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// IsPrecipitation returns true if the code represents any precipitation
|
||||
// (drizzle, rain, snow, showers, etc.).
|
||||
func IsPrecipitation(code model.WMOCode) bool {
|
||||
switch code {
|
||||
// Drizzle
|
||||
case 51, 53, 55, 56, 57:
|
||||
return true
|
||||
|
||||
// Rain
|
||||
case 61, 63, 65, 66, 67:
|
||||
return true
|
||||
|
||||
// Snow
|
||||
case 71, 73, 75, 77:
|
||||
return true
|
||||
|
||||
// Showers
|
||||
case 80, 81, 82, 85, 86:
|
||||
return true
|
||||
|
||||
// Thunderstorm (often includes rain/hail)
|
||||
case 95, 96, 99:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsRainFamily(code model.WMOCode) bool {
|
||||
switch code {
|
||||
// Drizzle + freezing drizzle
|
||||
case 51, 53, 55, 56, 57:
|
||||
return true
|
||||
|
||||
// Rain + freezing rain
|
||||
case 61, 63, 65, 66, 67:
|
||||
return true
|
||||
|
||||
// Rain showers
|
||||
case 80, 81, 82:
|
||||
return true
|
||||
|
||||
// Thunderstorm often implies rain
|
||||
case 95, 96, 99:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsSnowFamily(code model.WMOCode) bool {
|
||||
switch code {
|
||||
// Snow and related
|
||||
case 71, 73, 75, 77:
|
||||
return true
|
||||
|
||||
// Snow showers
|
||||
case 85, 86:
|
||||
return true
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// IsFreezingPrecip returns true if the code represents freezing drizzle/rain.
|
||||
func IsFreezingPrecip(code model.WMOCode) bool {
|
||||
switch code {
|
||||
case 56, 57, 66, 67:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// IsSkyOnly returns true for codes that represent "sky condition only"
|
||||
// (clear/mostly/partly/cloudy) rather than fog/precip/etc.
|
||||
func IsSkyOnly(code model.WMOCode) bool {
|
||||
switch code {
|
||||
case 0, 1, 2, 3:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user