config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DateLayout = "2006-01-02"
View Source
const DateLayoutShort = "Mon Jan 2"
View Source
const DateTimeLayout = "2006-01-02T15:04"
View Source
const DateTimeLayoutShort = "Jan 2 15:04"
View Source
const TimeLayout = "15:04"

Variables

View Source
var Colors = []TerminalColor{
	{Rune: ' ', Tag: "[-]"},
	{Rune: 'y', Tag: "[yellow]"},
	{Rune: 'r', Tag: "[red]"},
	{Rune: 'b', Tag: "[blue]"},
	{Rune: 'c', Tag: "[cyan]"},
	{Rune: 'g', Tag: "[green]"},
}
View Source
var Services = []Service{
	{
		Name:        "OM",
		Description: "Open-Meteo",
		UrlName:     "forecast",
	},
	{
		Name:        "DWD",
		Description: "DWD Germany",
		UrlName:     "dwd-icon",
	},
	{
		Name:        "NOAA",
		Description: "NOAA U.S.",
		UrlName:     "gfs",
	},
	{
		Name:        "MF",
		Description: "Meteo France",
		UrlName:     "meteofrance",
	},
}

Functions

func CreateDir

func CreateDir(path string) error

func Direction

func Direction(degrees float64) string

func LoadLocations

func LoadLocations() (map[string]Location, error)

func SaveCliArgs

func SaveCliArgs(args *CliArgs) error

func SaveLocations

func SaveLocations(locations map[string]Location) error

Types

type CliArgs

type CliArgs struct {
	Location    string
	Coords      Location `yaml:"-"`
	SetDefault  bool     `yaml:"-"`
	ForceSearch bool     `yaml:"-"`
	Days        int
	PastDays    int
	Service     Service
}

func LoadCliArgs

func LoadCliArgs() (CliArgs, error)

type CurrentMetric

type CurrentMetric string
const (
	CurrentWeatherCode  CurrentMetric = "weather_code"
	CurrentTemp         CurrentMetric = "temperature_2m"
	CurrentApparentTemp CurrentMetric = "apparent_temperature"
	CurrentRH           CurrentMetric = "relative_humidity_2m"
	CurrentPrecip       CurrentMetric = "precipitation"
	CurrentCloudCover   CurrentMetric = "cloud_cover"
	CurrentWindSpeed    CurrentMetric = "wind_speed_10m"
	CurrentWindDir      CurrentMetric = "wind_direction_10m"
	CurrentWindGusts    CurrentMetric = "wind_gusts_10m"
)

type CurrentWeather

type CurrentWeather struct {
	Time   time.Time
	Values map[string]float64
}

type DailyMetric

type DailyMetric string
const (
	DailyWeatherCode DailyMetric = "weather_code"
	DailyMinTemp     DailyMetric = "temperature_2m_min"
	DailyMaxTemp     DailyMetric = "temperature_2m_max"
	DailySunshine    DailyMetric = "sunshine_duration"
	DailyPrecip      DailyMetric = "precipitation_sum"
	DailyPrecipHours DailyMetric = "precipitation_hours"
	DailyPrecipProb  DailyMetric = "precipitation_probability_max"
	DailyWindSpeed   DailyMetric = "wind_speed_10m_max"
	DailyWindGusts   DailyMetric = "wind_gusts_10m_max"
	DailyWindDir     DailyMetric = "wind_direction_10m_dominant"
)

type ForecastOptions

type ForecastOptions struct {
	Location          Location
	Service           string          // Default "forecast"
	TemperatureUnit   string          // Default "celsius"
	WindSpeedUnit     string          // Default "kmh",
	PrecipitationUnit string          // Default "mm"
	Days              int             // Default 7
	PastDays          int             // Default 0
	CurrentMetrics    []CurrentMetric // List of required current metrics
	HourlyMetrics     []HourlyMetric  // List of required hourly metrics
	DailyMetrics      []DailyMetric   // List of required daily metrics
}

func (*ForecastOptions) ToURL

func (o *ForecastOptions) ToURL(baseURL string) string

type GeoOptions

type GeoOptions struct {
	Name  string
	Count int
}

func (*GeoOptions) ToURL

func (o *GeoOptions) ToURL(baseURL string) string

type GeoResult

type GeoResult struct {
	Results []GeoResultEntry
}

func ParseGeo

func ParseGeo(data []byte) (*GeoResult, error)

type GeoResultEntry

type GeoResultEntry struct {
	Name        string
	Latitude    float64
	Longitude   float64
	Country     string
	CountryCode string `json:"country_code"`
	Admin1      string
	Elevation   float64
	TimeZone    string
	Population  int
}

type HourlyMetric

type HourlyMetric string
const (
	HourlyWeatherCode  HourlyMetric = "weather_code"
	HourlyTemp         HourlyMetric = "temperature_2m"
	HourlyApparentTemp HourlyMetric = "apparent_temperature"
	HourlyRH           HourlyMetric = "relative_humidity_2m"
	HourlyPrecipProb   HourlyMetric = "precipitation_probability"
	HourlyPrecip       HourlyMetric = "precipitation"
	HourlyCloudCover   HourlyMetric = "cloud_cover"
	HourlyWindSpeed    HourlyMetric = "wind_speed_10m"
	HourlyWindDir      HourlyMetric = "wind_direction_10m"
	HourlyWindGusts    HourlyMetric = "wind_gusts_10m"
)

type Location

type Location struct {
	Lat      float64
	Lon      float64
	TimeZone string
}

type MeteoResult

type MeteoResult struct {
	Location Location
	TimeZone *time.Location

	GenerationTime_ms float64
	Current           CurrentWeather

	Hourly     map[string][]float64
	HourlyTime []time.Time

	Daily     map[string][]float64
	DailyTime []time.Time

	ThreeHourly     map[string][]float64
	ThreeHourlyTime []time.Time

	SixHourly     map[string][]float64
	SixHourlyTime []time.Time
}

func ParseMeteo

func ParseMeteo(data []byte, opt *ForecastOptions) (*MeteoResult, error)

func (*MeteoResult) GetCurrent

func (r *MeteoResult) GetCurrent(key CurrentMetric) float64

func (*MeteoResult) GetDaily

func (r *MeteoResult) GetDaily(key DailyMetric) []float64

func (*MeteoResult) GetHourly

func (r *MeteoResult) GetHourly(key HourlyMetric) []float64

func (*MeteoResult) GetSixHourly

func (r *MeteoResult) GetSixHourly(key HourlyMetric) []float64

func (*MeteoResult) GetThreeHourly

func (r *MeteoResult) GetThreeHourly(key HourlyMetric) []float64

type Options

type Options interface {
	ToURL(baseURL string) string
}

type Service

type Service struct {
	Name        string
	Description string
	UrlName     string
}

type TerminalColor

type TerminalColor struct {
	Rune rune
	Tag  string
}

Jump to

Keyboard shortcuts

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