weather

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package weather fetches weather data

Index

Constants

This section is empty.

Variables

View Source
var OpenWeatherMapProvider provider = "OpenWeatherMap"

OpenWeatherMapProvider is a weather provider

Functions

This section is empty.

Types

type Description

type Description string

Description is a standardized weather description

const Clear Description = "Clear"

Clear indicates clear skies

const Extreme Description = "Extreme"

Extreme indicates an extreme event

const LightClouds Description = "Light Clouds"

LightClouds indicate some clouds

const OvercastClouds Description = "Overcast"

OvercastClouds indicates heavy clouds

const Rain Description = "Rain"

Rain indicates rain

const ScatteredClouds Description = "Scattered Clouds"

ScatteredClouds indicates scattered clouds

const Snow Description = "Snow"

Snow indicates snow

const ThunderStorm Description = "Thunderstorm"

ThunderStorm indicates a thunderstorm

const Windy Description = "Windy"

Windy indicates winds

type Fetcher

type Fetcher interface {
	FetchByCity(city string) (*Weather, error)
	FetchByLatLong(lat, long float64, timeZone string) (*Weather, error)
	FetchByZip(zip int) (*Weather, error)
}

Fetcher retrieves the current and forecasted weather How to get the timezone of a zipcode? http://download.geonames.org/export/zip/? gives lat/long of a zipcode then https://stackoverflow.com/a/16086964/522962 for the timezone.

type Instant

type Instant struct {
	Date        time.Time
	Code        Description
	Temperature int
	Low         int
	High        int
	Wind        float64
	Clouds      float64
	Rain        float64
	Snow        float64
	Pressure    float64
	Humidity    float64
}

Instant is the weather for a specified time

type OpenWeatherMap

type OpenWeatherMap struct {
	HTTPClient *http.Client
	Key        string
}

OpenWeatherMap retrieves information from the OpenWeatherMap API

func (*OpenWeatherMap) FetchByCity

func (o *OpenWeatherMap) FetchByCity(city string) (*Weather, error)

FetchByCity retrieves weather for a city from the OpenWeatherMap api

func (*OpenWeatherMap) FetchByLatLong

func (o *OpenWeatherMap) FetchByLatLong(lat, long float64, timeZone string) (*Weather, error)

FetchByLatLong retrieves weather for a latitude/longitude location from the OpenWeatherMap api

func (*OpenWeatherMap) FetchByZip

func (o *OpenWeatherMap) FetchByZip(zip int) (*Weather, error)

FetchByZip retrieves weather for a zipcode from the OpenWeatherMap api

type OwmInstant

type OwmInstant struct {
	Instant *Instant
	Dt      int64 `json:"dt"`
	Main    struct {
		Temp      float64 `json:"temp"`
		TempMin   float64 `json:"temp_min"`
		TempMax   float64 `json:"temp_max"`
		Pressure  float64 `json:"pressure"`
		Humidity  int     `json:"humidity"`
		SeaLevel  float64 `json:"sea_level"`
		GrndLevel float64 `json:"grnd_level"`
		TempKf    float64 `json:"temp_kf"`
	} `json:"main"`
	Weather []struct {
		ID          int    `json:"id"`
		Main        string `json:"main"`
		Description string `json:"description"`
		Icon        string `json:"icon"`
	} `json:"weather"`
	Wind struct {
		Speed float64 `json:"speed"`
		Deg   float64 `json:"deg"`
	} `json:"wind"`
	Clouds struct {
		All int `json:"all"`
	} `json:"clouds"`
	Rain struct {
		All float64 `json:"3h"` // rain volume for last 3 hrs
	} `json:"rain"`
	Snow struct {
		All float64 `json:"3h"` // snow volume for last 3 hrs
	} `json:"snow"`
	Sys struct {
		Type    int     `json:"type"`
		ID      int     `json:"id"`
		Message float64 `json:"message"`
		Pod     string  `json:"pod"`
		Country string  `json:"country"`
		Sunrise int     `json:"sunrise"`
		Sunset  int     `json:"sunset"`
	} `json:"sys"`
}

OwmInstant is an OpenWeatherMap day

type Weather

type Weather struct {
	City     string
	TimeZone string
	Current  *Instant
	Forecast []*Instant
	Provider provider
}

Weather includes the urrent and forecasted weather

Jump to

Keyboard shortcuts

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