summaryrefslogtreecommitdiffstats
path: root/converter.go
diff options
context:
space:
mode:
Diffstat (limited to 'converter.go')
-rw-r--r--converter.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/converter.go b/converter.go
index 0e2b74c..fa49a61 100644
--- a/converter.go
+++ b/converter.go
@@ -1,4 +1,4 @@
-// converter.go - Converts ForecastData to OWMResponse
+// converter.go - Update to use exported FmiToOwm map
package main
import (
@@ -119,7 +119,27 @@ func (fd *ForecastData) convertToCurrent(index int, timestamp int64, loc *time.L
if val, err := fd.getFloatValue(index, "WeatherSymbol3"); err == nil && !math.IsNaN(val) {
symbol := int(math.Round(val))
forecastTime := time.Unix(timestamp, 0)
- current.Weather = []Weather{mapper.Map(symbol, forecastTime, sunrise, sunset)}
+
+ // Use the mapper or fallback to the global map
+ var weather Weather
+ if mapper != nil {
+ weather = mapper.Map(symbol, forecastTime, sunrise, sunset)
+ } else {
+ // Fallback to global map
+ if w, ok := FmiToOwm[symbol]; ok {
+ weather = w
+ // Determine day/night
+ isDay := forecastTime.After(sunrise) && forecastTime.Before(sunset)
+ if isDay {
+ weather.Icon += "d"
+ } else {
+ weather.Icon += "n"
+ }
+ } else {
+ weather = Weather{800, "Clear", "clear sky", "01d"}
+ }
+ }
+ current.Weather = []Weather{weather}
} else {
// Default weather
current.Weather = []Weather{{800, "Clear", "clear sky", "01d"}}