data

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinuteDataPoint added in v1.0.24

type MinuteDataPoint struct {
	DateTime      int64   `json:"dt"`
	Precipitation float64 `json:"precipitation"`
}

type OpenWeatherRequest added in v1.0.16

type OpenWeatherRequest struct {
	Lat     string `json:"lat"`     // Latitude
	Long    string `json:"lon"`     // Longitude
	Exclude string `json:"exclude"` // Exclude data from response
	Units   string `json:"units"`   // Units to use
	AppId   string `json:"appid"`   // Application id / token
}

type OpenWeatherResponse added in v1.0.16

type OpenWeatherResponse struct {
	Lat            float64 `json:"lat"`
	Lon            float64 `json:"lon"`
	Timezone       string  `json:"timezone"`
	TimezoneOffset int     `json:"timezone_offset"`
	Current        struct {
		Dt        int     `json:"dt"`
		Sunrise   int     `json:"sunrise"`
		Sunset    int     `json:"sunset"`
		Temp      float64 `json:"temp"`
		FeelsLike float64 `json:"feels_like"`
		Pressure  int     `json:"pressure"`
		Humidity  int     `json:"humidity"`
		DewPoint  float64 `json:"dew_point"`
		Uvi       float64 `json:"uvi"`
		Clouds    int     `json:"clouds"`
		Rain      struct {
			LastHour float64 `json:"1h"`
		}
		Visibility int     `json:"visibility"`
		WindSpeed  float64 `json:"wind_speed"`
		WindDeg    int     `json:"wind_deg"`
		Weather    []struct {
			ID          int    `json:"id"`
			Main        string `json:"main"`
			Description string `json:"description"`
			Icon        string `json:"icon"`
		} `json:"weather"`
	} `json:"current"`
	Hourly []struct {
		Dt         int     `json:"dt"`
		Temp       float64 `json:"temp"`
		FeelsLike  float64 `json:"feels_like"`
		Pressure   int     `json:"pressure"`
		Humidity   int     `json:"humidity"`
		DewPoint   float64 `json:"dew_point"`
		Uvi        float64 `json:"uvi"`
		Clouds     int     `json:"clouds"`
		Visibility int     `json:"visibility"`
		WindSpeed  float64 `json:"wind_speed"`
		WindDeg    float64 `json:"wind_deg"`
		WindGust   float64 `json:"wind_gust"`
		Weather    []struct {
			ID          int    `json:"id"`
			Main        string `json:"main"`
			Description string `json:"description"`
			Icon        string `json:"icon"`
		} `json:"weather"`
		Pop  float64 `json:"pop"`
		Rain struct {
			OneH float64 `json:"1h"`
		} `json:"rain,omitempty"`
	} `json:"hourly"`
	Daily []struct {
		Dt        int     `json:"dt"`
		Sunrise   int     `json:"sunrise"`
		Sunset    int     `json:"sunset"`
		Moonrise  int     `json:"moonrise"`
		Moonset   int     `json:"moonset"`
		MoonPhase float64 `json:"moon_phase"`
		Temp      struct {
			Day   float64 `json:"day"`
			Min   float64 `json:"min"`
			Max   float64 `json:"max"`
			Night float64 `json:"night"`
			Eve   float64 `json:"eve"`
			Morn  float64 `json:"morn"`
		} `json:"temp"`
		FeelsLike struct {
			Day   float64 `json:"day"`
			Night float64 `json:"night"`
			Eve   float64 `json:"eve"`
			Morn  float64 `json:"morn"`
		} `json:"feels_like"`
		Pressure  int     `json:"pressure"`
		Humidity  int     `json:"humidity"`
		DewPoint  float64 `json:"dew_point"`
		WindSpeed float64 `json:"wind_speed"`
		WindDeg   int     `json:"wind_deg"`
		WindGust  float64 `json:"wind_gust"`
		Weather   []struct {
			ID          int    `json:"id"`
			Main        string `json:"main"`
			Description string `json:"description"`
			Icon        string `json:"icon"`
		} `json:"weather"`
		Clouds int     `json:"clouds"`
		Pop    float64 `json:"pop"`
		Rain   float64 `json:"rain"`
		Uvi    float64 `json:"uvi"`
	} `json:"daily"`
	Minutely []struct {
		Dt            int     `json:"dt"`
		Precipitation float64 `json:"precipitation"`
	} `json:"minutely"`
	Alerts []struct {
		SenderName  string   `json:"sender_name"`
		Event       string   `json:"event"`
		Start       float64  `json:"start"`
		End         float64  `json:"end"`
		Description string   `json:"description"`
		Tags        []string `json:"tags"`
	} `json:"alerts"`
}

type OpenWeatherService added in v1.0.16

type OpenWeatherService struct{}

OpenWeatherService is a weather service for OpenWeather formatted data

func (OpenWeatherService) GetWeatherReport added in v1.0.16

func (s OpenWeatherService) GetWeatherReport(ctx context.Context, lat, long string) (WeatherReport, error)

GetWeatherReport gets the weather report

type WeatherDataBlock

type WeatherDataBlock struct {
	Summary string             `json:"summary"`
	Icon    string             `json:"icon"`
	Data    []WeatherDataPoint `json:"data"`
}

WeatherDataBlock defines a group of data points

type WeatherDataPoint

type WeatherDataPoint struct {
	Time                int64   `json:"time"`
	Summary             string  `json:"summary"`
	Icon                string  `json:"icon"`
	PrecipIntensity     float64 `json:"precipIntensity"`
	PrecipIntensityMax  float64 `json:"precipIntensityMax"`
	PrecipProbability   float64 `json:"precipProbability"`
	PrecipType          string  `json:"precipType"`
	PrecipAccumulation  float64 `json:"precipAccumulation"`
	Temperature         float64 `json:"temperature"`
	TemperatureMin      float64 `json:"temperatureMin"`
	TemperatureMax      float64 `json:"temperatureMax"`
	ApparentTemperature float64 `json:"apparentTemperature"`
	WindSpeed           float64 `json:"windSpeed"`
	WindGust            float64 `json:"windGust"`
	WindBearing         float64 `json:"windBearing"`
	CloudCover          float64 `json:"cloudCover"`
	Humidity            float64 `json:"humidity"`
	Pressure            float64 `json:"pressure"`
	Visibility          float64 `json:"visibility"`
	Ozone               float64 `json:"ozone"`
	UVIndex             float64 `json:"uvindex"`
}

WeatherDataPoint defines a weather data point

type WeatherReport

type WeatherReport struct {
	Latitude  float64            `json:"latitude"`
	Longitude float64            `json:"longitude"`
	Currently WeatherDataPoint   `json:"currently"`
	Daily     WeatherDataBlock   `json:"daily"`
	Hourly    []WeatherDataPoint `json:"hourly"`
	Minutely  []MinuteDataPoint  `json:"minutely"`
	APICalls  int                `json:"apicalls"`
	Code      int                `json:"code"`
	Version   string             `json:"version"`
}

WeatherReport defines a weather report

func GetWeatherReport

func GetWeatherReport(ctx context.Context, services []WeatherService, lat, long string) WeatherReport

GetWeatherReport calls all services in parallel and returns the first result

type WeatherService

type WeatherService interface {
	// GetWeatherReport gets the weather report
	GetWeatherReport(ctx context.Context, lat, long string) (WeatherReport, error)
}

WeatherService is the interface for all services that can fetch weather data

Jump to

Keyboard shortcuts

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