weather

package
v0.0.0-...-13156d4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: MIT Imports: 7 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 {
	// contains filtered or unexported fields
}

Client is used to communcate with a service and fetch current and future information about the weather.

func NewOWMClient

func NewOWMClient(key string) *Client

NewOWMClient a new Client, which talks to the OpenWeatherMaps (https://openweathermap.org).

func (Client) Current

func (c Client) Current() (State, error)

Current fetches and returns the current weather state from open weather maps.

func (Client) Forecast

func (c Client) Forecast() ([]State, error)

Forecast fetches and returns the weather forecast. As the forecast grain (e.g., each 3 hours for the next day) can vary and callers need to inspect each of the State's timestamp to identify it.

type Description

type Description struct {
	Text string `bson:"text,omitempty"` // Weather condition within the group
	Icon string `bson:"icon,omitempty"` // Weather icon id
}

Description stores overall information to describe the weather. That include text, images and so on.

type State

type State struct {
	Timestamp   time.Time   // Timestamp in unix UTC
	Description Description // Icon and other text describing the weather state
	Wind        Wind        // Wind description
	Temp        float64     // Temperature, Celsius
	Humidity    float64     // Humidity, %
	Rain        float64     // Rain volume for the last hours
	Cloudiness  float64     // Cloudiness, %
}

State stores the complete information about the weather at a certain time.

type Wind

type Wind struct {
	Speed     float64 `bson:"speed,omitempty"` // Wind speed, meter/sec
	Direction float64 `bson:"deg,omitempty"`   // Wind direction, degrees (meteorological)
}

Wind stores information about the wind.

Jump to

Keyboard shortcuts

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