met

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Access [Meteorologisk institutt's API](https://api.met.no)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.0.8

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(siteName string) (*Client, error)

Returns new Client with provided siteName.

Returns error if siteName is empty.

func (*Client) Forecast added in v0.0.8

func (c *Client) Forecast(lat, lon float64, alt *int) (*LocationForecastResult, error)

Returns LocationsForecast by requested coordinates lat and lon with optional alt.

Returns error if request fails.

API endpoint: https://api.met.no/weatherapi/locationforecast/2.0/documentation

type LocationForecast

type LocationForecast struct {
	Type string `json:"type"`

	Geometry struct {
		Type        string    `json:"type"`
		Coordinates []float64 `json:"coordinates"`
	} `json:"geometry"`

	Properties struct {
		Meta       Meta         `json:"meta"`
		Timeseries []Timeseries `json:"timeseries"`
	} `json:"properties"`
}

type LocationForecastResult

type LocationForecastResult struct {
	Expires      time.Time `json:"expires"`
	LastModified time.Time `json:"lastModified"`
	LocationForecast
}

type Meta

type Meta struct {
	UpdatedAt time.Time `json:"updated_at"`
	Units     Units     `json:"units"`
}

type NextXHours

type NextXHours struct {
	Summary struct {
		SymbolCode string `json:"symbol_code"`
	} `json:"summary"`
	Details struct {
		AirTemperatureMax           float64 `json:"air_temperature_max"`
		AirTemperatureMin           float64 `json:"air_temperature_min"`
		PrecipitationAmount         float64 `json:"precipitation_amount"`
		PrecipitationAmountMax      float64 `json:"precipitation_amount_max"`
		PrecipitationAmountMin      float64 `json:"precipitation_amount_min"`
		ProbabilityOfPrecipitation  float64 `json:"probability_of_precipitation"`
		ProbabilityOfThunder        float64 `json:"probability_of_thunder"`
		UltravioletIndexClearSkyMax float64 `json:"ultraviolet_index_clear_sky_max"`
	} `json:"details"`
}

type Timeseries

type Timeseries struct {
	Time time.Time `json:"time"`
	Data struct {
		Instant struct {
			Details struct {
				AirPressureAtSeaLevel    float64 `json:"air_pressure_at_sea_level"`
				AirTemperature           float64 `json:"air_temperature"`
				CloudAreaFraction        float64 `json:"cloud_area_fraction"`
				CloudAreaFractionHigh    float64 `json:"cloud_area_fraction_high"`
				CloudAreaFractionLow     float64 `json:"cloud_area_fraction_low"`
				CloudAreaFractionMedium  float64 `json:"cloud_area_fraction_medium"`
				DewPointTemperature      float64 `json:"dew_point_temperature"`
				FogAreaFraction          float64 `json:"fog_area_fraction"`
				RelativeHumidity         float64 `json:"relative_humidity"`
				UltravioletIndexClearSky float64 `json:"ultraviolet_index_clear_sky"`
				WindFromDirection        float64 `json:"wind_from_direction"`
				WindSpeed                float64 `json:"wind_speed"`
			} `json:"details"`
		} `json:"instant"`
		Next1_Hours  *NextXHours `json:"next_1_hours,omitempty"`
		Next6_Hours  *NextXHours `json:"next_6_hours,omitempty"`
		Next12_Hours *NextXHours `json:"next_12_hours,omitempty"`
	} `json:"data"`
}

type Units

type Units struct {
	AirPressureAtSeaLevel    string `json:"air_pressure_at_sea_level"`
	AirTemperature           string `json:"air_temperature"`
	AirTemperatureMax        string `json:"air_temperature_max"`
	AirTemperatureMin        string `json:"air_temperature_min"`
	CloudAreaFraction        string `json:"cloud_area_fraction"`
	CloudAreaFractionHigh    string `json:"cloud_area_fraction_high"`
	CloudAreaFractionLow     string `json:"cloud_area_fraction_low"`
	CloudAreaFractionMedium  string `json:"cloud_area_fraction_medium"`
	DewPointTemperature      string `json:"dew_point_temperature"`
	FogAreaFraction          string `json:"fog_area_fraction"`
	PrecipitationAmount      string `json:"precipitation_amount"`
	RelativeHumidity         string `json:"relative_humidity"`
	UltravioletIndexClearSky string `json:"ultraviolet_index_clear_sky"`
	WindFromDirection        string `json:"wind_from_direction"`
	WindSpeed                string `json:"wind_speed"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL