Documentation ¶
Overview ¶
wwo provides an interface to the premium api of worldweatheronline.com
This requires an API key, held by a WWO structure, which is then used to perform queries.
var weather = WWO({"your-hex-api-key-goes-in-here!"}) forecast, err := weather.GetLocal("London", map[string]string{})
The optional options passed in the map are documented with the various Get functions. Each Get function returns a structure of the appropriate type and a possible error. That error will be set for any transport, unmashalling, or API errors, depending on the type of error, including all API errors, the structure may also be filled in to some extent.
Index ¶
- type Area
- type Astronomy
- type ClimateAverage
- type Condition
- type CurrentCondition
- type Date
- type ForecastChances
- type ForecastCondition
- type ForecastWeather
- type LevelCond
- type Local
- type Marine
- type MarineCondition
- type MarineWeather
- type PastLocal
- type PastMarine
- type Request
- type Search
- type Ski
- type SkiCondition
- type SkiWeather
- type TempRange
- type Tide
- type Time12
- type TimeHMM
- type TimeZone
- type WWO
- func (w *WWO) GetLocal(location string, opt map[string]string) (*Local, error)
- func (w *WWO) GetMarine(location string, opt map[string]string) (*Marine, error)
- func (w *WWO) GetPastLocal(location string, opt map[string]string) (*PastLocal, error)
- func (w *WWO) GetPastMarine(location string, opt map[string]string) (*PastMarine, error)
- func (w *WWO) GetSearch(location string, opt map[string]string) (*Search, error)
- func (w *WWO) GetSki(location string, opt map[string]string) (*Ski, error)
- func (w *WWO) GetTimeZone(location string, opt map[string]string) (*TimeZone, error)
- type Weather
- type Zone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Area ¶
type Area struct { Country string `xml:"country"` Latitude float64 `xml:"latitude"` Longitude float64 `xml:"longitude"` Name string `xml:"areaName"` Region string `xml:"region"` Population uint `xml:"population"` // Location's population DistanceMI float64 `xml:"distance_miles"` // mi Distance between query point and this area WeatherURL string `xml:"weatherUrl"` Zone *Zone `xml:"timezone"` }
Describes an area known to WorldWeatherOnline
type Astronomy ¶
type Astronomy struct { Moonrise Time12 `xml:"moonrise"` // Local time of moonrise Moonset Time12 `xml:"moonset"` // Local time of moonset Sunrise Time12 `xml:"sunrise"` // Local time of sunrise Sunset Time12 `xml:"sunset"` // Local time of sunset }
Astronomical events for a day.
type ClimateAverage ¶
type ClimateAverage struct { Index uint `xml:"index"` // Month index Integer: 1-12 Name string `xml:"name"` // The name of the month MinTemp float64 `xml:"avgMinTemp"` // °C Average minimum temperature MinTemp_F float64 `xml:"avgMinTemp_F"` // °F Average minimum temperature MaxTemp float64 `xml:"avgMaxTemp"` // °C Average maximum temperature MaxTemp_F float64 `xml:"avgMaxTemp_F"` // °F Average maximum temperature AbsMinTemp float64 `xml:"absMinTemp"` // °C Absolute minimum temperature AbsMinTemp_F float64 `xml:"absMinTemp_F"` // °F Absolute minimum temperature AbsMaxTemp float64 `xml:"absMaxTemp"` // °C Absolute maximum temperature AbsMaxTemp_F float64 `xml:"absMaxTemp_F"` // °F Absolute maximum temperature Temp float64 `xml:"avgTemp"` // °C Average temperature Temp_F float64 `xml:"avgTemp_F"` // °F Average temperature MaxWindSpeed float64 `xml:"maxWindSpeed_kmph"` // km/hr Maximum wind speed FIXME average or absolute? MaxWindSpeed_mph float64 `xml:"maxWindSpeed_mph"` // mi/hr Maximum wind speed MaxWindSpeed_knots float64 `xml:"maxWindSpeed_knots"` // knots Maximum wind speed MaxWindSpeed_ms float64 `xml:"maxWindSpeed_ms"` // m/s Maximum wind speed WindSpeed float64 `xml:"avgWindSpeed_kmph"` // km/hr Average wind speed WindSpeed_miles float64 `xml:"avgWindSpeed_miles"` // mi/hr Average wind speed WindSpeed_knots float64 `xml:"avgWindSpeed_knots"` // knots Average wind speed WindSpeed_ms float64 `xml:"avgWindSpeed_ms"` // m/s Average wind speed WindGust float64 `xml:"avgWindGust_kmph"` // km/hr Average wind gust WindGust_miles float64 `xml:"avgWindGust_miles"` // mi/hr Average wind gust WindGust_knots float64 `xml:"avgWindGust_knots"` // knots Average wind gust WindGust_ms float64 `xml:"avgWindGust_ms"` // m/s Average wind gust DailyRainfall float64 `xml:"avgDailyRainfall"` // mm Average daily rainfall DailyRainfall_inch float64 `xml:"avgDailyRainfall_inch"` // in Average daily rainfall MonthlyRainfall float64 `xml:"avgMonthlyRainfall"` // mm Average monthly rainfall MonthlyRainfall_inch float64 `xml:"avgMonthlyRainfall_inch"` // in Average monthly rainfall Humidity float64 `xml:"avgHumidity"` // % Average humidity Cloud float64 `xml:"avgCloud"` // % Average cloud cover Visibility float64 `xml:"avgVis_km"` // km Average visibility Visibility_miles float64 `xml:"avgVis_miles"` // mi Average visibility Pressure float64 `xml:"avgPressure_mb"` // mbar Average pressure Pressure_inch float64 `xml:"avgPressure_inch"` // in Average pressure DryDays uint `xml:"avgDryDays"` // Average number of dry days RainDays uint `xml:"avgRainDays"` // Average number of rain days SnowDays uint `xml:"avgSnowDays"` // Average number of snow days FogDays uint `xml:"avgFogDays"` // Average number of foggy days ThunderDays uint `xml:"avgThunderDays"` // Average number of thunder days UVIndex uint `xml:"avgUVIndex"` // Average UV Index SunHour float64 `xml:"avgSunHour"` // hr/day Average Sun }
Climate averages in a Local Forecast.
type Condition ¶
type Condition struct { Time TimeHMM `xml:"time"` // Local time (Duration after start of day) CloudCover uint `xml:"cloudcover"` // % Cloud cover amount DewPoint int `xml:"DewPointC"` // °C Dew point temperature DewPointF int `xml:"DewPointF"` // °F Dew point temperature FeelsLike int `xml:"FeelsLikeC"` // °C Feels like temperature FeelsLikeF int `xml:"FeelsLikeF"` // °F Feels like temperature HeatIndex int `xml:"HeatIndexC"` // °C Heat index temperature HeatIndexF int `xml:"HeatIndexF"` // °F Heat index temperature Humidity uint `xml:"humidity"` // % Humidity Precip float64 `xml:"precipMM"` // mm Precipitation PrecipInches float64 `xml:"precipInches"` // in Precipitation Pressure uint `xml:"pressure"` // mbar Atmospheric pressure PressureInches uint `xml:"pressureInches"` // in Atmospheric pressure Temp int `xml:"tempC"` // °C Temperature TempF int `xml:"tempF"` // °F Temperature Visibility uint `xml:"visibility"` // km Visibility VisibilityMiles uint `xml:"visibilityMiles"` // mi Visibility WeatherCode uint `xml:"weatherCode"` // Weather condition code <https://developer.worldweatheronline.com/api/docs/weather-icons.aspx> WeatherDesc string `xml:"weatherDesc"` // Weather condition description WeatherIconUrl string `xml:"weatherIconUrl"` // URL to weather icon WindChill int `xml:"WindChillC"` // °C Wind chill temperature WindChillF int `xml:"WindChillF"` // °F Wind chill temperature WindDir uint `xml:"winddirDegree"` // °EoN Wind direction WindDirCompass string `xml:"winddir16Point"` // Wind direction 16-point compass WindGust uint `xml:"WindGustKmph"` // km/hr Wind gust WindGustMiles uint `xml:"WindGustMiles"` // mi/hr Wind gust WindSpeed uint `xml:"windspeedKmph"` // km/hr Wind speed WindSpeedKnots uint `xml:"windspeedKnots"` // knots Wind speed WindSpeedMeterSec uint `xml:"windspeedMeterSec"` // m/s Wind speed WindSpeedMiles uint `xml:"windspeedMiles"` // mi/hr Wind speed }
Weather conditions common to most reports.
type CurrentCondition ¶
type CurrentCondition struct { Condition TempF int `xml:"temp_F"` // °F Temperature Temp int `xml:"temp_C"` // °C Temperature Time Time12 `xml:"observation_time"` // Time of the observation }
Current weather conditions in a Local Forecast.
type ForecastChances ¶
type ForecastChances struct { ChanceFog uint `xml:"chanceoffog"` // % Chance of fog ChanceFrost uint `xml:"chanceoffrost"` // % Chance of front ChanceOvercast uint `xml:"chanceofovercast"` // % Chance of being cloudy ChanceRain uint `xml:"chanceofrain"` // % Chance of rain ChanceSnow uint `xml:"chanceofsnow"` // % Chance of snow ChanceHighTemp uint `xml:"chanceofhightemp"` // % Chance of high temperatures FIXME not in docs ChanceDry uint `xml:"chanceofremdry"` // % Chance of remaining dry FIXME not in docs ChanceSunshine uint `xml:"chanceofsunshine"` // % Chance of being sunny ChanceThunder uint `xml:"chanceofthunder"` // % Chance of thunder and/or lightning ChanceWindy uint `xml:"chanceofwindy"` // % Chance of being windy }
Chances of various conditions in a Local Forecast.
type ForecastCondition ¶
type ForecastCondition struct { Condition ForecastChances }
Conditions in the n-hourly Local Forecast.
type ForecastWeather ¶
type ForecastWeather struct { Weather Condition []ForecastCondition `xml:"hourly"` // Forcasted weather conditions }
Weather report for a Local Forecast.
type LevelCond ¶
type LevelCond struct { Temp int `xml:"tempC"` // °C Temperature TempF int `xml:"tempF"` // °F Temperature WindSpeed uint `xml:"windspeedKmph"` // km/hr Wind speed WindSpeedKnots uint `xml:"windspeedKnots"` // knots Wind speed WindSpeedMeterSec uint `xml:"windspeedMeterSec"` // m/s Wind speed WindSpeedMiles uint `xml:"windspeedMiles"` // mi/hr Wind speed WindDir uint `xml:"winddirDegree"` // °EoN Wind direction WindDirCompass string `xml:"winddir16Point"` // Wind direction 16-point compass WeatherCode uint `xml:"weatherCode"` // Weather condition code <https://developer.worldweatheronline.com/api/docs/weather-icons.aspx> WeatherDesc string `xml:"weatherDesc"` // Weather condition description WeatherIconUrl string `xml:"weatherIconUrl"` // URL to weather icon }
Weather conditions at a particular elevation band.
type Local ¶
type Local struct { Area Area `xml:"nearest_area"` // the nearest area to the query Climate []ClimateAverage `xml:"ClimateAverages>month"` // monthly climate averages Current CurrentCondition `xml:"current_condition"` // current weather conditions Request Request `xml:"request"` // details of the original request Weather []ForecastWeather `xml:"weather"` // forecasted weather conditions Error *string `xml:"error>msg"` // errors }
A Local Weather Forecast
type Marine ¶
type Marine struct { Request Request `xml:"request"` // details of the original request Area Area `xml:"nearest_area"` // the nearest area to the query Weather []MarineWeather `xml:"weather"` // the marine weather forecast Error *string `xml:"error>msg"` // errors }
A Marine Weather Forecast
type MarineCondition ¶
type MarineCondition struct { Condition SigHeight float64 `xml:"sigHeight_m"` // m Significant wave height SwellHeight float64 `xml:"swellHeight_m"` // m Swell wave height SwellHeight_ft float64 `xml:"swellHeight_ft"` // ft Swell wave height FIXME docs say swell_Height_ft SwellDir uint `xml:"swellDir"` // °EoN Swell direction SwellDirCompass string `xml:"swellDir16Point"` // Swell compass direction SwellPeriod float64 `xml:"swellPeriod_secs"` // sec Swell period WaterTemp int `xml:"waterTemp_C"` // °C Water temperature WaterTemp_F int `xml:"waterTemp_F"` // °F Water temperature }
Conditions in the n-hourly Marine Forecast.
type MarineWeather ¶
type MarineWeather struct { Weather Condition []MarineCondition `xml:"hourly"` // Forcasted weather conditions Tide []Tide `xml:"tides>tide_data"` // Tide information }
Weather report for a Marine Forecast.
type PastLocal ¶
type PastLocal struct { Request Request `xml:"request"` // details of the original request Area Area `xml:"nearest_area"` // the nearest area to the query Weather []Weather `xml:"weather"` // the historical weather report Error *string `xml:"error>msg"` // errors }
A Historical Local Weather Report
type PastMarine ¶
type PastMarine Marine // historical marine reports are very similar to marine forecasts
A Historical Marine Weather Report
type Request ¶
type Request struct { Query string `xml:"query"` // The location query used Type string `xml:"type"` // The type of location request }
Most queries include the request that generated them.
type Search ¶
type Search struct { Area []Area `xml:"result"` // the list of areas found Error *string `xml:"error>msg"` // errors }
An Area Search Report
type Ski ¶
type Ski struct { Request Request `xml:"request"` // details of the original request Area Area `xml:"nearest_area"` // the nearest area to the query Weather []SkiWeather `xml:"weather"` // the ski weather forecast Error *string `xml:"error>msg"` // errors }
A Ski Weather Forecast
type SkiCondition ¶
type SkiCondition struct { ForecastChances Top LevelCond `xml:"top"` // Temperature range at top Mid LevelCond `xml:"mid"` // Temperature range at middle Bottom LevelCond `xml:"bottom"` // Temperature range at bottom CloudCover uint `xml:"cloudcover"` // % Cloud cover amount Visibility uint `xml:"visibility"` // km Visibility VisibilityMiles uint `xml:"visibilityMiles"` // mi Visibility Pressure uint `xml:"pressure"` // mbar Atmospheric pressure PressureInches uint `xml:"pressureInches"` // in Atmospheric pressure Snowfall float64 `xml:"snowfall_cm"` // cm Snowfall FreezeLevel uint `xml:"freezeLevel"` // m Freeze elevation Humidity uint `xml:"humidity"` // % Humidity Precip float64 `xml:"precipMM"` // mm Precipitation PrecipInches float64 `xml:"precipInches"` // in Precipitation }
Weather conditions for a Ski Forecast.
type SkiWeather ¶
type SkiWeather struct { Weather ChanceSnow uint `xml:"chanceofsnow"` // % Chance of snow TotalSnow float64 `xml:"totalSnowfall_cm"` // cm Total snowfall amount Top TempRange `xml:"top"` // Temperature range at top Mid TempRange `xml:"mid"` // Temperature range at middle Bottom TempRange `xml:"bottom"` // Temperature range at bottom Condition []SkiCondition `xml:"hourly"` // Forcasted weather conditions }
weather report for a Ski Forecast
type TempRange ¶
type TempRange struct { MaxTemp int `xml:"maxtempC"` // °C Maximum temperature MaxTempF int `xml:"maxtempF"` // °F Maximum temperature MinTemp int `xml:"mintempC"` // °C Minimum temperature MinTempF int `xml:"mintempF"` // °F Minimum temperature }
A range of temperatures in a given period of time
type Tide ¶
type Tide struct { Time Time12 `xml:"tideTime"9` // Local time of tide Height float64 `xml:"tideHeight_mt"` // m Tide height Type string `xml:"tide_type"` // High, Low, Normal }
A tide entry in a Marine Forecast or Record.
type Time12 ¶
Times of tides, sun/moon rise/set, are given in local time without a date.
func (*Time12) UnmarshalXML ¶
type TimeHMM ¶
Times of forecast and historical detailed conditions as an integer representing local time.
func (*TimeHMM) UnmarshalXML ¶
type TimeZone ¶
type TimeZone struct { Request Request `xml:"request"` // details of the original request Area Area `xml:"nearest_area"` // the nearest area to the query Zone Zone `xml:"time_zone"` // the time zone data for the nearest area Error *string `xml:"error>msg"` // errors }
A Timezone Report
type WWO ¶
Essential information for WorldWeatherOnline lookups.
func (*WWO) GetLocal ¶
Fetch a local forecast for location.
Supported options are (defaults marked with *):
num_of_days Number of days of forecast to include (0-21, *14) date Start date of forecast (today, *tomorrow, YYYY-mm-dd) fx Include forecast (*yes, no) cc Include current conditions (*yes, no) mca Include monthly averages (*yes, no) fx24 Include tp-hourly forecasts (*yes, no) includelocation Include nearest location information (yes, *no) tp Number of hours in detailed forecast (1, *3, 6, 12, 24)
func (*WWO) GetMarine ¶
Fetch a marine forecast for location.
Supported options are (defaults marked with *):
fx Include forecast (*yes, no) tp Number of hours in detailed forecast (1, *3, 6, 12, 24) tide Include tide information (yes, *no)
func (*WWO) GetPastLocal ¶
Fetch historical local weather information for location.
Supported options are (defaults marked with *):
date Start date (YYYY-mm-dd) enddate End date (YYYY-mm-dd) includelocation Include nearest location information (yes, *no) tp Number of hours in detailed forecast (1, *3, 6, 12, 24)
func (*WWO) GetPastMarine ¶
Fetch historical marine weather information for location.
Supported options are (defaults marked with *):
date Start date (YYYY-mm-dd) enddate End date (YYYY-mm-dd) tp Number of hours in detailed forecast (1, *3, 6, 12, 24) tide Include tide information (yes, *no)
func (*WWO) GetSearch ¶
Look up locations.
Supported options are (defaults marked with *):
num_of_results Number of results to return (1-50, *10) timezone Include timezone information (yes, *no) popular Include only popular locations (yes, *no) wct Limit locations to type (ski, cricket, football, golf, fishing)
type Weather ¶
type Weather struct { TempRange Astronomy Astronomy `xml:"astronomy"` // Astronomical information for the day Date Date `xml:"date"` // Date of forecast SunHour float64 `xml:"sunHour"` // Total sun in hours TotalSnow float64 `xml:"totalSnow_cm"` // Total snowfall amount in cm UVIndex uint `xml:"uvIndex"` // UV Index Condition []Condition `xml:"hourly"` // Weather conditions }
The common fields of weather reports.