Documentation
¶
Index ¶
- Variables
- func CheckAPIKeyExists(apiKey string) bool
- func OptionCodiEstacio(codiEstacio string) func(p *Parameters) error
- func OptionCodiEstat(codiEstat string) func(p *Parameters) error
- func OptionCodiVariable(codiVariable string) func(p *Parameters) error
- func OptionData(d Data) func(p *Parameters) error
- func OptionTimeDate(d TimeDate) func(p *Parameters) error
- func ValidAPIKey(key string) error
- func ValidCodiEstacio(c string) bool
- func ValidCodiEstat(c string) bool
- func ValidCodiVariable(c string) bool
- func ValidData(d Data) bool
- type APIError
- type BasesTemporals
- type Comarca
- type Config
- type Coordenades
- type Data
- type Estacions
- type Estats
- type Lectura
- type Measurements
- type Mesurades
- func (m *Mesurades) MeasurementAllByStation(p *Parameters) error
- func (m *Mesurades) MeasurementByDay(p *Parameters) error
- func (m *Mesurades) MeasurementLast(p *Parameters) error
- func (m *Mesurades) MeasurementMetadataAll() error
- func (m *Mesurades) MeasurementMetadataAllByStation(p *Parameters) error
- func (m *Mesurades) MeasurementMetadataByStation(p *Parameters) error
- func (m *Mesurades) MeasurementMetadataUnique(p *Parameters) error
- type MetadadesEstacions
- type MetadadesVariable
- type MetadadesVariableEstacio
- type MetadadesVariables
- type MetadadesVariablesEstacio
- type Municipi
- type Option
- type Parameters
- type Provincia
- type Settings
- type TimeDate
- type Variable
- type Xarxa
Constants ¶
This section is empty.
Variables ¶
var CodisEstacions = map[string]string{}/* 189 elements not displayed */
CodisEstacions holds all stations in ope state to be used
var CodisEstat = map[string]string{
"ope": "Operativa",
"des": "Desmantellada",
"bte": "Baixa temporal",
}
CodisEstat holds all the status that a station can have
var CodisVariables = map[string]string{
"1": "Pressió atmosfèrica màxima",
"2": "Pressió atmosfèrica mínima",
"3": "Humitat relativa màxima",
"X4": "Temperatura màxima de subsòl a 5 cm",
"5": "Temperatura mínima de subsòl a 5 cm",
"6": "TDR màxima a 10 cm",
"7": "TDR mínima a 10 cm",
"8": "Desviació estàndard de la irradiància neta",
"9": "Irradiància reflectida",
"10": "Irradiància fotosintèticament activa (PAR)",
"11": "Temperatura de supefície",
"12": "Temperatura màxima de superfície",
"13": "Temperatura mínima de superfície",
"14": "Temperatura de subsòl a 40 cm",
"16": "Nivell evaporímetre",
"20": "Velocitat del vent a 10 m (vec.)",
"21": "Direcció del vent a 10 m (m. u)",
"22": "Desviació est. de la direcció del vent a 10 m",
"23": "Velocitat del vent a 6 m (vec.)",
"24": "Direcció del vent a 6 m (m. u)",
"25": "Desviació est. de la direcció de vent a 6 m",
"26": "Velocitat del vent a 2 m (vec.)",
"27": "Direcció del vent a 2 m (m. u)",
"28": "Desviació est. de la direcció del vent a 2 m",
"30": "Velocitat del vent a 10 m (esc.)",
"31": "Direcció de vent 10 m (m. 1)",
"32": "Temperatura",
"33": "Humitat relativa",
"34": "Pressió atmosfèrica",
"35": "Precipitació",
"36": "Irradiància solar global",
"37": "Desviació est. de la irradiància solar global",
"38": "Gruix de neu a terra",
"39": "Radiació UV",
"40": "Temperatura màxima",
"42": "Temperatura mínima",
"44": "Humitat relativa mínima",
"46": "Velocitat del vent a 2 m (esc.)",
"47": "Direcció del vent a 2 m (m. 1)",
"48": "Velocitat del vent a 6 m (esc.)",
"49": "Direcció del vent a 6 m (m. 1)",
"50": "Ratxa màxima del vent a 10 m",
"51": "Direcció de la ratxa màxima del vent a 10 m",
"53": "Ratxa màxima del vent a 6 m",
"54": "Direcció de la ratxa màxima del vent a 6 m",
"56": "Ratxa màxima del vent a 2 m",
"57": "Direcció de la ratxa màxima del vent a 2 m",
"59": "Irradiància neta",
"60": "Temperatura de subsòl a 5 cm",
"61": "Temperatura de subsòl a 50 cm",
"62": "TDR a 10 cm",
"63": "TDR a 35 cm",
"64": "Humectació moll",
"65": "Humectació sec",
"66": "Humectació res",
"67": "Humectació moll 2",
"68": "Humectació sec 2",
"69": "Humectació res 2",
"70": "Precipitació acumulada",
"71": "Bateria",
"72": "Precipitació màxima en 1 minut",
"74": "Humitat del combustible forestal 1",
"75": "Temperatura del combustible forestal 1",
"76": "Humitat del combustible forestal 2",
"77": "Temperatura del combustible forestal 2",
"78": "Humitat del combustible forestal 3",
"79": "Temperatura del combustible forestal 3",
"80": "Temperatura de la neu 1",
"81": "Temperatura de la neu 2",
"82": "Temperatura de la neu 3",
"83": "Temperatura de la neu 4",
"84": "Temperatura de la neu 5",
"85": "Temperatura de la neu 6",
"86": "Temperatura de la neu 7",
"87": "Temperatura de la neu 8",
"88": "Quality number",
"89": "Temperatura del datalogger",
"90": "Altura màxima",
"91": "Període màxima",
"92": "Altura significant",
"93": "Període significant",
"94": "Altura mitjana",
"95": "Període mitjà",
"96": "Direcció del pic",
"97": "Temperatura superficial del mar",
}
CodisVariables holds all the measurements performed by the weather stations. Note that not all the stations measures all the variables. To see which measurements a station does check the method MeasurementMetadataAllByStation
Functions ¶
func CheckAPIKeyExists ¶
CheckAPIKeyExists will see if an API key has been set.
func OptionCodiEstacio ¶
func OptionCodiEstacio(codiEstacio string) func(p *Parameters) error
OptionCodiEstacio is a helper function to set up the value of CodiEstacio to be passed in Parameters struct
func OptionCodiEstat ¶
func OptionCodiEstat(codiEstat string) func(p *Parameters) error
OptionCodiEstat is a helper function to set up the value of CodiEstat to be passed in Parameters struct
func OptionCodiVariable ¶
func OptionCodiVariable(codiVariable string) func(p *Parameters) error
OptionCodiVariable is a helper function to set up the value of CodiVariable to be passed in Parameters struct
func OptionData ¶
func OptionData(d Data) func(p *Parameters) error
OptionData is a helper function to set up the value of Data to be passed in Parameters struct
func OptionTimeDate ¶
func OptionTimeDate(d TimeDate) func(p *Parameters) error
Option TimeData is a helper function to set up the value of Timedate to be passed in Parameters struct
func ValidAPIKey ¶
ValidAPIKey makes sure that the key given is a valid one
func ValidCodiEstacio ¶
ValidCodiEstacio makes sure the string passed in is an acceptable station code.
func ValidCodiEstat ¶
ValidCodiEstat makes sure the string passed in is an acceptable estat code.
func ValidCodiVariable ¶
ValidCodiVariable makes sure the string passed in is an acceptable variable code.
Types ¶
type BasesTemporals ¶
type BasesTemporals []struct { Codi string `json:"codi"` DataInici string `json:"dataInici"` DataFi string `json:"dataFi"` }
BasesTemporals TODO
type Comarca ¶
type Comarca struct { Codi int `json:"codi"` // Comarca identification code Nom string `json:"nom"` // Name of the comarca }
Comarca struct holds information on which Comarca is located the station.
type Config ¶
type Config struct {
APIKey string // API Key for connecting to the OWM
}
Config will hold default settings
type Coordenades ¶
type Coordenades struct { Latitud float64 `json:"latitud"` // Latitude expressed in decimal degrees. WSG84 reference system Longitud float64 `json:"Longitud"` // Longitude expressed in decimal degrees. WSG84 reference system }
Coordenades struct holds georeference information of the stations
type Data ¶
Data struct holds the time settings in general the time format will be YYYY/MM/D or YYYY-MM-DZ but this is transparent for the final user.
type Estacions ¶
type Estacions struct { MetadadesEstacions Key string CodiEstacio string // ? CodiVariable string // ? *Settings }
Mesurades holds all the data representations to unmarshall the API responses
func NewEstacions ¶
NewMesurades returns a new MesuradesData pointer with the supplied parameters
func (*Estacions) StationsAll ¶
func (e *Estacions) StationsAll(p *Parameters) error
Returns a list of metadata from all stations. If settings are specified, filters by specified status and date The API resource is /estacions/metadades?estat={estat}&data={data} where the parameters `estat` and data optional. Request example: https://api.meteo.cat/xema/v1/estacions/metadades?estat=ope&data=2017-03-27Z
type Estats ¶
type Estats []struct { Codi int `json:"codi"` DataInici string `json:"dataInici"` DataFi interface{} `json:"dataFi"` }
Estats struct holds information of station code when initiated and or finalized.
type Lectura ¶
type Lectura struct { Data string `json:"data"` Valor float64 `json:"valor"` Estat string `json:"estat"` BaseHoraria string `json:"baseHoraria"` }
Lectura is an aggregate type which represents the data registered in the station. This value with a code represents a variable, e.g {"codi":5,"lectures":[{"data":"2021-01-06T10:00Z","dataExtrem":"2021-01-06T10:24Z","valor":8.7,"estat":" ","baseHoraria":"SH"}]}
type Measurements ¶
Measurements holds the measurements done in a station
type Mesurades ¶
type Mesurades struct { Variable Measurements MetadadesVariablesEstacio MetadadesVariableEstacio MetadadesVariables Key string CodiEstacio string // ? CodiVariable string // ? *Settings }
Mesurades holds all the data representations to unmarshall the API responses
func NewMesurades ¶
NewMesurades returns a new MesuradesData pointer with the supplied parameters
func (*Mesurades) MeasurementAllByStation ¶
func (m *Mesurades) MeasurementAllByStation(p *Parameters) error
func (*Mesurades) MeasurementByDay ¶
func (m *Mesurades) MeasurementByDay(p *Parameters) error
This function returns information about a weather variable for all stations on a specific day. If a station code is provided, it returns the data for that variable and station. The API endpoint for this function is /variables/mesurades/{codi_variable}/{any}/{mes}/{dia}?codiEstacio={codi_estacio}.
The following parameters are mandatory: - `codi_variable`: The code of the variable to retrieve data for. - `any`: The year of the date to retrieve data for. - `mes`: The month of the date to retrieve data for. - `dia`: The day of the date to retrieve data for. The `codi_estacio` parameter is optional, and can be used to filter the data by a specific station code. Request example: https://api.meteo.cat/xema/v1/variables/mesurades/32/2017/03/27?codiEstacio=UG
func (*Mesurades) MeasurementLast ¶
func (m *Mesurades) MeasurementLast(p *Parameters) error
Returns the last measurement of the last 4 hours for all stations of a variable, filtered by station if indicated The API resource is /variables/mesurades/{codi_variable}/ultimes?codiEstacio={codi_estacio} where `codi_variable` is mandatory and `codi_estacio` is optional. Request example: https://api.meteo.cat/xema/v1/variables/mesurades/5/ultimes?codiEstacio=UG
func (*Mesurades) MeasurementMetadataAll ¶
Returns the metadata of all variables regardless of the stations at which they are measured. The API resource is /variables/mesurades/metadades and there are no parameters. Request example https://api.meteo.cat/xema/v1/variables/mesurades/metadades
func (*Mesurades) MeasurementMetadataAllByStation ¶
func (m *Mesurades) MeasurementMetadataAllByStation(p *Parameters) error
Returns metadata of all variables measured by the station with code specified in the URL, filtered by status and date if specified The API resource is /estacions/{codiEstacio}/variables/mesurades/metadades?estat={estat}&data={data} where `estat` and `date` are optional. The `estat` parameter describes the state of the station and it can have one of the following values [ope, des, bte]. These values means "Operativa", "Baixa temporal" and "Desmantellada" respectively. See https://apidocs.meteocat.gencat.cat/documentacio/dades-de-la-xema/ for more information. Note that the 'data' and 'estat' parameters are required together in order to filter the metadata Request example https://api.meteo.cat/xema/v1/estacions/UG/variables/mesurades/metadades?estat=ope&data=2017-03-27Z
func (*Mesurades) MeasurementMetadataByStation ¶
func (m *Mesurades) MeasurementMetadataByStation(p *Parameters) error
MeasurementMetadataByStation Returns the metadata of the variable with the code specified in the URL that measures the station with the code indicated in the URL The API resource is /estacions/{codiEstacio}/variables/mesurades/{codiVariable}/metadades where the parameters 'codiEstacio' and 'codiVariable' are mandatory Request example https://api.meteo.cat/xema/v1/estacions/UG/variables/mesurades/3/metadades
func (*Mesurades) MeasurementMetadataUnique ¶
func (m *Mesurades) MeasurementMetadataUnique(p *Parameters) error
Returns the metadata of the variable with code indicated in the URL, regardless of the stations in which they are measured. The API resource is /variables/mesurades/{codi_variable}/metadades where the parameter 'codi_variable' is mandatory. Request example: https://api.meteo.cat/xema/v1/variables/mesurades/1/metadades
type MetadadesEstacions ¶
type MetadadesEstacions struct { Codi string `json:"codi"` // Identification code for each automatic weather station (EMA) Nom string `json:"nom"` // Name of the EMA Tipus string `json:"tipus"` // Type of station typically automatic Coordenades Coordenades `json:"coordenades"` // Georeference data of the station Emplacament string `json:"emplacament"` // Descriptive name of where the station is located e.g Planters Gusi, ctra. antiga de València, km 14 Altitud float64 `json:"altitud"` // Altitude in meters of the station above the sea level. Municipi Municipi `json:"municipi"` // Municipi Comarca Comarca `json:"comarca"` // Comarca Provincia Provincia `json:"provincia"` // Provincia Xarxa Xarxa `json:"xarxa"` // Network tipically XEMA Estats Estats `json:"estats"` }
Aggregation of fields and structs to unmarshal the responses
type MetadadesVariable ¶
type MetadadesVariable struct { Codi int `json:"codi"` // Identifier code of the variable Nom string `json:"nom"` // Identifier name of the variable Unitats string `json:"unitats"` // Unit of measurement of variables e.g T(ºC),... Acronim string `json:"acronim"` // Acronym of the variable Tipus string `json:"tipus"` // Type of variable Decimals int `json:"decimals"` // Number of decimal numbers }
MetadadesVariable is an aggregation of fields to hold the metadata asociated with the variables of the Network of Automatic Meteorological Stations (XEMA), integrated into the Network of Meteorological Equipment of the Generalitat de Catalunya (Xemec), of the Meteorological Service of Catalonia. Each variable is identified by a code.
type MetadadesVariableEstacio ¶
type MetadadesVariableEstacio struct { MetadadesVariable Estats BasesTemporals }
MetadadesVariableEstacio is an agreggate type to hold the metadata of the variable data registered in a particular station
type MetadadesVariables ¶
type MetadadesVariables []struct{ MetadadesVariable }
MetadadesVariables is a slice which holds the metadata of all variables
type MetadadesVariablesEstacio ¶
type MetadadesVariablesEstacio []struct{ MetadadesVariableEstacio }
MetadadesVariablesEstacio is a slice which holds the variables metadata of all the data registered bu a station
type Municipi ¶
type Municipi struct { Codi string `json:"codi"` // INE code of the municipi Nom string `json:"nom"` // Name of the municipi }
Municipi struct holds information on which municipi is located the station.
type Option ¶
Optional client settings
func WithHttpClient ¶
// WithHttpClient sets custom http client when creating a new Client.
type Parameters ¶
Parameters holds all the options to be passed in to the methods
func NewParameters ¶
func NewParameters(options ...func(*Parameters) error) (*Parameters, error)
NewParameters generates a new Parameters config.
type Provincia ¶
type Provincia struct { Codi int `json:"codi"` // Provincia identification code Nom string `json:"nom"` // Name of the provincia }
Provincia struct holds information on which Provincia is located the station.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings holds the client settings
func NewSettings ¶
func NewSettings() *Settings
NewSettings returns a new Setting pointer with default http client.
type Variable ¶
Variable is an agreggate type which represents the variable data registered in a station.
type Xarxa ¶
type Xarxa struct { Codi int `json:"codi"` // Xarxa identification code Nom string `json:"nom"` // Name of the Network }
Xarxa struct holds information on which Xarxa is located the station. The xarxa field refers to the stations of the Network of Automatic Meteorological Stations (XEMA) of Catalonia