summaryrefslogtreecommitdiffstats
path: root/weather_mapper.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--weather_mapper.go69
1 files changed, 37 insertions, 32 deletions
diff --git a/weather_mapper.go b/weather_mapper.go
index 7f01217..9bfab01 100644
--- a/weather_mapper.go
+++ b/weather_mapper.go
@@ -1,7 +1,9 @@
-// weather_mapper.go - Maps FMI weather symbols to OWM format
+// weather_mapper.go - Fixed with exported map
package main
-import "time"
+import (
+ "time"
+)
// WeatherMapper handles weather symbol mapping
type WeatherMapper struct {
@@ -11,36 +13,7 @@ type WeatherMapper struct {
// NewWeatherMapper creates a new weather mapper
func NewWeatherMapper() *WeatherMapper {
return &WeatherMapper{
- symbolMap: map[int]Weather{
- 1: {800, "Clear", "clear sky", "01"},
- 2: {801, "Clouds", "few clouds", "02"},
- 3: {802, "Clouds", "scattered clouds", "03"},
- 4: {803, "Clouds", "broken clouds", "04"},
- 5: {804, "Clouds", "overcast clouds", "04"},
- 6: {701, "Mist", "mist", "50"},
- 7: {701, "Mist", "mist", "50"},
- 8: {741, "Fog", "fog", "50"},
- 9: {741, "Fog", "fog", "50"},
- 10: {741, "Fog", "fog", "50"},
- 11: {300, "Drizzle", "light intensity drizzle", "09"},
- 12: {301, "Drizzle", "drizzle", "09"},
- 13: {302, "Drizzle", "heavy intensity drizzle", "09"},
- 21: {520, "Rain", "light intensity shower rain", "09"},
- 22: {521, "Rain", "shower rain", "09"},
- 23: {522, "Rain", "heavy intensity shower rain", "09"},
- 24: {511, "Rain", "freezing rain", "13"},
- 25: {500, "Rain", "light rain", "10"},
- 26: {501, "Rain", "moderate rain", "10"},
- 27: {502, "Rain", "heavy intensity rain", "10"},
- 30: {500, "Rain", "light rain", "10"},
- 31: {501, "Rain", "moderate rain", "10"},
- 32: {502, "Rain", "heavy intensity rain", "10"},
- 40: {600, "Snow", "light snow", "13"},
- 41: {600, "Snow", "light snow", "13"},
- 42: {601, "Snow", "snow", "13"},
- 43: {602, "Snow", "heavy snow", "13"},
- 91: {200, "Thunderstorm", "thunderstorm with light rain", "11"},
- },
+ symbolMap: FmiToOwm,
}
}
@@ -61,3 +34,35 @@ func (wm *WeatherMapper) Map(symbol int, forecastTime, sunrise, sunset time.Time
return weather
}
+
+// FmiToOwm is the global FMI to OpenWeatherMap mapping
+var FmiToOwm = map[int]Weather{
+ 1: {800, "Clear", "clear sky", "01"},
+ 2: {801, "Clouds", "few clouds", "02"},
+ 3: {802, "Clouds", "scattered clouds", "03"},
+ 4: {803, "Clouds", "broken clouds", "04"},
+ 5: {804, "Clouds", "overcast clouds", "04"},
+ 6: {701, "Mist", "mist", "50"},
+ 7: {701, "Mist", "mist", "50"},
+ 8: {741, "Fog", "fog", "50"},
+ 9: {741, "Fog", "fog", "50"},
+ 10: {741, "Fog", "fog", "50"},
+ 11: {300, "Drizzle", "light intensity drizzle", "09"},
+ 12: {301, "Drizzle", "drizzle", "09"},
+ 13: {302, "Drizzle", "heavy intensity drizzle", "09"},
+ 21: {520, "Rain", "light intensity shower rain", "09"},
+ 22: {521, "Rain", "shower rain", "09"},
+ 23: {522, "Rain", "heavy intensity shower rain", "09"},
+ 24: {511, "Rain", "freezing rain", "13"},
+ 25: {500, "Rain", "light rain", "10"},
+ 26: {501, "Rain", "moderate rain", "10"},
+ 27: {502, "Rain", "heavy intensity rain", "10"},
+ 30: {500, "Rain", "light rain", "10"},
+ 31: {501, "Rain", "moderate rain", "10"},
+ 32: {502, "Rain", "heavy intensity rain", "10"},
+ 40: {600, "Snow", "light snow", "13"},
+ 41: {600, "Snow", "light snow", "13"},
+ 42: {601, "Snow", "snow", "13"},
+ 43: {602, "Snow", "heavy snow", "13"},
+ 91: {200, "Thunderstorm", "thunderstorm with light rain", "11"},
+}