summaryrefslogtreecommitdiffstats
path: root/models.go
blob: 6493b96050cf11bac99166b5bb0435a65069b33d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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"`
}