yr

package
v0.0.0-...-54266d6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL   string
	UserAgent string
	HTTPClient
}

func NewClient

func NewClient(cfg Config, HTTPClient HTTPClient) *Client

func (*Client) GetCompleteForecast

func (c *Client) GetCompleteForecast(ctx context.Context, lat, lon, altitude float64) (Forecast, error)

type Config

type Config struct {
	BaseURL   string `envconfig:"YR_URL" default:"https://api.met.no/weatherapi/locationforecast/2.0/"`
	UserAgent string `envconfig:"YR_USER_AGENT" default:"yr-go"`
}

type Forecast

type Forecast struct {
	Type       string     `json:"type"`
	Geometry   Geometry   `json:"geometry"`
	Properties Properties `json:"properties"`
}

type ForecastDetails

type ForecastDetails struct {
	AirPressureAtSeaLevel      float64 `json:"air_pressure_at_sea_level"`
	AirTemperature             float64 `json:"air_temperature"`
	AirTemperature10Percentile float64 `json:"air_temperature_percentile_10"`
	AirTemperature90Percentile float64 `json:"air_temperature_percentile_90"`
	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"`
	WindSpeedOfGust            float64 `json:"wind_speed_of_gust"`
	WindSpeed10Percentile      float64 `json:"wind_speed_percentile_10"`
	WindSpeed90Percentile      float64 `json:"wind_speed_percentile_90"`
}

type Geometry

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

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Properties

type Properties struct {
	Meta struct {
		Updated_at time.Time         `json:"updated_at"`
		Units      map[string]string `json:"units"`
	} `json:"meta"`
	Timeseries []struct {
		Time time.Time `json:"time"`
		Data struct {
			Instant struct {
				Details ForecastDetails `json:"details"`
			} `json:"instant"`
		} `json:"data"`
	} `json:"timeseries"`
}

Jump to

Keyboard shortcuts

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