iface

package
v0.0.0-...-d88a6a7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: ISC Imports: 2 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllBackends  = make(map[string]Backend)
	AllFrontends = make(map[string]Frontend)
)

Functions

This section is empty.

Types

type Astro

type Astro struct {
	Moonrise time.Time
	Moonset  time.Time
	Sunrise  time.Time
	Sunset   time.Time
}

type Backend

type Backend interface {
	Setup()
	Fetch(location string, numdays int) Data
}

type Cond

type Cond struct {
	// Time is the time, where this weather condition applies.
	Time time.Time

	// Code is the general weather condition and must be one the WeatherCode
	// constants.
	Code WeatherCode

	// Desc is a short string describing the condition. It should be just one
	// sentence.
	Desc string

	// TempC is the temperature in degrees celsius.
	TempC *float32

	// FeelsLikeC is the felt temperature (with windchill effect e.g.) in
	// degrees celsius.
	FeelsLikeC *float32

	// ChanceOfRainPercent is the probability of rain or snow. It must be in the
	// range [0, 100].
	ChanceOfRainPercent *int

	// PrecipM is the precipitation amount in meters(!) per hour. Must be >= 0.
	PrecipM *float32

	// VisibleDistM is the visibility range in meters(!). It must be >= 0.
	VisibleDistM *float32

	// WindspeedKmph is the average wind speed in kilometers per hour. The value
	// must be >= 0.
	WindspeedKmph *float32

	// WindGustKmph is the maximum temporary wind speed in kilometers per
	// second. It should be > WindspeedKmph.
	WindGustKmph *float32

	// WinddirDegree is the direction the wind is blowing from on a clock
	// oriented circle with 360 degrees. 0 means the wind is blowing from north,
	// 90 means the wind is blowing from east, 180 means the wind is blowing
	// from south and 270 means the wind is blowing from west. The value must be
	// in the range [0, 359].
	WinddirDegree *int

	// Humidity is the *relative* humidity and must be in [0, 100].
	Humidity *int
}

type Data

type Data struct {
	Current  Cond
	Forecast []Day
	Location string
	GeoLoc   *LatLon
}

type Day

type Day struct {
	// Date is the date of this Day.
	Date time.Time

	// Slots is a slice of conditions for different times of day. They should be
	// ordered by the contained Time field.
	Slots []Cond

	// Astronomy contains planetary data.
	Astronomy Astro
}

type Frontend

type Frontend interface {
	Setup()
	Render(weather Data, unitSystem UnitSystem)
}

type LatLon

type LatLon struct {
	Latitude  float32
	Longitude float32
}

type UnitSystem

type UnitSystem int
const (
	UnitsMetric UnitSystem = iota
	UnitsImperial
	UnitsSi
	UnitsMetricMs
)

func (UnitSystem) Distance

func (u UnitSystem) Distance(distM float32) (res float32, unit string)

func (UnitSystem) Speed

func (u UnitSystem) Speed(spdKmph float32) (res float32, unit string)

func (UnitSystem) Temp

func (u UnitSystem) Temp(tempC float32) (res float32, unit string)

type WeatherCode

type WeatherCode int
const (
	CodeUnknown WeatherCode = iota
	CodeCloudy
	CodeFog
	CodeHeavyRain
	CodeHeavyShowers
	CodeHeavySnow
	CodeHeavySnowShowers
	CodeLightRain
	CodeLightShowers
	CodeLightSleet
	CodeLightSleetShowers
	CodeLightSnow
	CodeLightSnowShowers
	CodePartlyCloudy
	CodeSunny
	CodeThunderyHeavyRain
	CodeThunderyShowers
	CodeThunderySnowShowers
	CodeVeryCloudy
)

Jump to

Keyboard shortcuts

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