bbcweather

package module
v0.0.0-...-a8b6473 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 6 Imported by: 0

README

BBC Weather API tools

Go Reference

Retrieves the current and forecasted weather from the BBC Weather APIs

wx

wx is a command line tool for displaying the current weather from your nearest observation station and the forecasted weather for the next 14 days. Uses the BBC weather APIs for the source of information.

go install github.com/codehex/bbcweather/cmd/wx@latest

Locations can be in the form of

  • The name of the location, city or region
  • The first part of the post code
  • Longitude and latitude
  • The location ID (see Geonames dataset for more details on location IDs, data dump is here) e.g.
wx Edinburgh Airport     # By specific location
wx New York              # By city or town
wx Lake District         # By region
wx Switzerland           # By country
wx SW19                  # By postcode (e.g. Wimbeldon)
wx 48.8566,2.3522        # By longitude and latitude (e.g. Paris)
wx 2993458               # By location ID (e.g. Monaco - https://www.geonames.org/2993458)

A preset location can be used by setting the WX_QUERY env variable

export WX_QUERY=Paris
wx

Here's an example of a weather report

wx Output

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCountryFromCode

func GetCountryFromCode(code string) (string, bool)

GetCountryFromCode useds an embedded list of country codes to find the corresponding country name

Types

type CurrentWeatherReport

type CurrentWeatherReport struct {
	ReportLocation       Location
	StationName          string
	DistFromStationKm    float64
	DistFromStationMiles float64
	UpdatedAt            time.Time

	TempC        int
	TempF        int
	WindSpeedKph int
	WindSpeedMph int
	WindCategory WindType
}

func GetCurrentWeatherForLocation

func GetCurrentWeatherForLocation(loc Location) (CurrentWeatherReport, error)

type DayForecast

type DayForecast struct {
	ForecastDate        time.Time
	IssueDate           time.Time
	LastUpdated         time.Time
	WeatherDescription  string
	MaxTempC            int
	MaxTempF            int
	MinTempC            int
	MinTempF            int
	ChanceOfRainPercent int
	WindSpeedKph        int
	WindSpeedMph        int
	WindCategory        WindType
}

type ForecastReport

type ForecastReport struct {
	ForecastLocation Location
	DayForecasts     []DayForecast
}

func GetWeatherForecast

func GetWeatherForecast(loc Location) (ForecastReport, error)

type Location

type Location struct {
	ID                  string
	Name                string
	Region              string
	Country             string
	Latitude, Longitude float64
}

func GetLocationByQuery

func GetLocationByQuery(query string) (Location, bool, error)

GetLocationByQuery returns the location for the given query. Returns the most relevant result

type WindType

type WindType struct {
	BeaufortNumber  int
	MaxWindSpeedMph int
	Summary         string
	Description     string
}

func GetWindTypeFromSpeed

func GetWindTypeFromSpeed(speedMph int) WindType

Directories

Path Synopsis
cmd
wx

Jump to

Keyboard shortcuts

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