owm

package
v0.1.4-alpha-deployment Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnitsStandard = "standard"
	UnitsMetric   = "metric"
	UnitsImperial = "imperial"

	ExcludeCurrent  = "current"
	ExcludeMinutely = "minutely"
	ExcludeHourly   = "hourly"
	ExcludeDaily    = "daily"

	LanguageEnglish = "en"

	EndpointOneCall = "https://api.openweathermap.org/data/2.5/onecall"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client open weather map client

func NewClient

func NewClient(apiKey string, units string, language string) *Client

NewClient create new open weather map client

func (*Client) GetDailyForecast

func (c *Client) GetDailyForecast(ctx context.Context, lat, lng float64) ([]HourlyForecast, error)

GetDailyForecast get daily weather from the OpenWeatherMap service

func (*Client) GetForecast

func (c *Client) GetForecast(ctx context.Context, lat, lng float64, exclude string) (*Forecast, error)

GetForecast requests Forecast from OpenWeatherMap API

func (*Client) GetHourlyForecast

func (c *Client) GetHourlyForecast(ctx context.Context, lat, lng float64) ([]HourlyForecast, error)

GetHourlyForecast get hourly weather from the OpenWeatherMap service

type CurrentForecast

type CurrentForecast struct {
	CurrentTime int64         `json:"dt"`
	SunriseTime int64         `json:"sunrise"`
	SunsetTime  int64         `json:"sunset"`
	Temperature float64       `json:"temp"`
	FeelsLike   float64       `json:"feels_like"`
	Pressure    int           `json:"pressure"`
	Humidity    int           `json:"humidity"`
	DewPoint    float64       `json:"dew_point"`
	UVIndex     float64       `json:"uvi"`
	Clouds      int           `json:"clouds"`
	Visibility  int           `json:"visibility"`
	WindSpeed   float64       `json:"wind_speed"`
	WindGust    float64       `json:"wind_gust"`
	WindDeg     int           `json:"wind_deg"`
	Rain        Precipitation `json:"rain"`
	Snow        Precipitation `json:"snow"`
	Weather     []Weather     `json:"weather"`
}

func (*CurrentForecast) GetCurrentTime

func (f *CurrentForecast) GetCurrentTime() time.Time

func (*CurrentForecast) GetSunriseTime

func (f *CurrentForecast) GetSunriseTime() time.Time

func (*CurrentForecast) GetSunsetTime

func (f *CurrentForecast) GetSunsetTime() time.Time

type DailyFeelsLike

type DailyFeelsLike struct {
	Day   float64 `json:"day"`
	Night float64 `json:"night"`
	Eve   float64 `json:"eve"`
	Morn  float64 `json:"morn"`
}

type DailyForecast

type DailyForecast struct {
	ForecastTime int64            `json:"dt"`
	SunriseTime  int64            `json:"sunrise"`
	SunsetTime   int64            `json:"sunset"`
	MoonriseTime int64            `json:"moonrise"`
	MoonsetTime  int64            `json:"moonset"`
	MoonPhase    float64          `json:"moon_phase"`
	Temperature  DailyTemperature `json:"temp"`
	FeelsLike    DailyFeelsLike   `json:"feels_like"`
	Pressure     int              `json:"pressure"`
	Humidity     int              `json:"humidity"`
	DewPoint     float64          `json:"dew_point"`
	UVIndex      float64          `json:"uvi"`
	Clouds       int              `json:"clouds"`
	Visibility   int              `json:"visibility"`
	WindSpeed    float64          `json:"wind_speed"`
	WindGust     float64          `json:"wind_gust"`
	WindDeg      int              `json:"wind_deg"`
	Rain         float64          `json:"rain"`
	Weather      []Weather        `json:"weather"`
	POP          float64          `json:"pop"`
}

func (*DailyForecast) GetForecastTime

func (d *DailyForecast) GetForecastTime() time.Time

func (*DailyForecast) GetMoonriseTime

func (d *DailyForecast) GetMoonriseTime() time.Time

func (*DailyForecast) GetMoonsetTime

func (d *DailyForecast) GetMoonsetTime() time.Time

func (*DailyForecast) GetSunriseTime

func (d *DailyForecast) GetSunriseTime() time.Time

func (*DailyForecast) GetSunsetTime

func (d *DailyForecast) GetSunsetTime() time.Time

type DailyTemperature

type DailyTemperature struct {
	Day   float64 `json:"day"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
	Night float64 `json:"night"`
	Eve   float64 `json:"eve"`
	Morn  float64 `json:"morn"`
}

type Forecast

type Forecast struct {
	Lat            float64          `json:"lat"`
	Lon            float64          `json:"lon"`
	TimeZone       string           `json:"timezone"`
	TimeZoneOffset int              `json:"timezone_offset"`
	Current        CurrentForecast  `json:"current"`
	Minutely       []Minutely       `json:"minutely"`
	Hourly         []HourlyForecast `json:"hourly"`
	Daily          []DailyForecast  `json:"daily"`
}

type ForecastError

type ForecastError struct {
	Message string `json:"message"`
	Cod     string `json:"cod"`
}

type HourlyForecast

type HourlyForecast struct {
	ForecastTime int64         `json:"dt"`
	Temperature  float64       `json:"temp"`
	FeelsLike    float64       `json:"feels_like"`
	Pressure     int           `json:"pressure"`
	Humidity     int           `json:"humidity"`
	DewPoint     float64       `json:"dew_point"`
	UVIndex      float64       `json:"uvi"`
	Clouds       int           `json:"clouds"`
	Visibility   int           `json:"visibility"`
	WindSpeed    float64       `json:"wind_speed"`
	WindGust     float64       `json:"wind_gust"`
	WindDeg      int           `json:"wind_deg"`
	Rain         Precipitation `json:"rain"`
	Snow         Precipitation `json:"snow"`
	Weather      []Weather     `json:"weather"`
}

func (*HourlyForecast) GetForecastTime

func (f *HourlyForecast) GetForecastTime() time.Time

type Minutely

type Minutely struct {
	Dt            int `json:"dt"`
	Precipitation int `json:"precipitation"`
}

type Precipitation

type Precipitation struct {
	H float64 `json:"1h"`
}

type Weather

type Weather struct {
	Id          int    `json:"id"`
	Main        string `json:"main"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

Jump to

Keyboard shortcuts

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