diff options
| author | Petri Hienonen <petri.hienonen@gmail.com> | 2026-02-01 17:31:30 +0200 |
|---|---|---|
| committer | Petri Hienonen <petri.hienonen@gmail.com> | 2026-02-01 17:31:30 +0200 |
| commit | 757f611a4d738688bc97cc6787ecce8650f25873 (patch) | |
| tree | 248a829960dadc09c496a2c3b66189ed4ba6676b /models.go | |
| parent | c9cc45a8c97496a3996df968360f096cf7172407 (diff) | |
| download | weather-757f611a4d738688bc97cc6787ecce8650f25873.tar.zst | |
Second
Diffstat (limited to '')
| -rw-r--r-- | models.go | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/models.go b/models.go new file mode 100644 index 0000000..6493b96 --- /dev/null +++ b/models.go @@ -0,0 +1,96 @@ +// models.go - Data models +package main + +import ( + "encoding/xml" +) + +// OWMResponse represents OpenWeatherMap API response format +type OWMResponse struct { + Lat float64 `json:"lat"` + Lon float64 `json:"lon"` + Timezone string `json:"timezone"` + TimezoneOffset int `json:"timezone_offset"` + Current Current `json:"current"` + Hourly []Current `json:"hourly"` +} + +// Current represents current or hourly weather data +type Current struct { + Dt int64 `json:"dt"` + Sunrise int64 `json:"sunrise,omitempty"` + Sunset int64 `json:"sunset,omitempty"` + Temp float64 `json:"temp"` + FeelsLike float64 `json:"feels_like"` + Pressure int `json:"pressure"` + Humidity int `json:"humidity"` + DewPoint float64 `json:"dew_point"` + Uvi float64 `json:"uvi"` + Clouds int `json:"clouds"` + Visibility int `json:"visibility"` + WindSpeed float64 `json:"wind_speed"` + WindDeg int `json:"wind_deg"` + WindGust float64 `json:"wind_gust"` + Weather []Weather `json:"weather"` + Rain *Rain `json:"rain,omitempty"` + LocalTime string `json:"local_time,omitempty"` // ISO 8601 format +} + +// Rain represents precipitation data +type Rain struct { + OneH float64 `json:"1h"` +} + +// Weather represents weather condition +type Weather struct { + ID int `json:"id"` + Main string `json:"main"` + Description string `json:"description"` + Icon string `json:"icon"` +} + +// ForecastData represents parsed FMI forecast data +type ForecastData struct { + Latitude float64 + Longitude float64 + Timezone string + Timestamps []int64 + Parameters []string + Values [][]float64 + ParamIndex map[string]int +} + +// XML models for FMI API response +type FeatureCollection struct { + XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureCollection"` + Members []struct { + GridSeriesObservation struct { + XMLName xml.Name `xml:"GridSeriesObservation"` + Namespace string `xml:"xmlns,attr"` + Result struct { + MultiPointCoverage struct { + XMLName xml.Name `xml:"MultiPointCoverage"` + Namespace string `xml:"xmlns,attr"` + DomainSet struct { + SimpleMultiPoint struct { + XMLName xml.Name `xml:"SimpleMultiPoint"` + Positions string `xml:"positions"` + } `xml:"SimpleMultiPoint"` + } `xml:"domainSet"` + RangeSet struct { + DataBlock struct { + TupleList string `xml:"doubleOrNilReasonTupleList"` + } `xml:"DataBlock"` + } `xml:"rangeSet"` + RangeType struct { + DataRecord struct { + Fields []struct { + Name string `xml:"name,attr"` + } `xml:"field"` + } `xml:"DataRecord"` + } `xml:"rangeType"` + } `xml:"MultiPointCoverage"` + } `xml:"result"` + } `xml:"GridSeriesObservation"` + } `xml:"member"` +} |
