nws

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NWS_BASE_URL = "https://api.weather.gov"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyPeriod added in v0.20.0

type DailyPeriod struct {
	Number                     int                `json:"number,omitempty"`
	Name                       string             `json:"name,omitempty"`
	StartTime                  string             `json:"startTime,omitempty"`
	EndTime                    string             `json:"endTime,omitempty"`
	IsDaytime                  bool               `json:"isDaytime,omitempty"`
	Temperature                int                `json:"temperature,omitempty"`
	TemperatureUnit            string             `json:"temperatureUnit,omitempty"`
	TemperatureTrend           string             `json:"temperatureTrend,omitempty"`
	ProbabilityOfPrecipitation UnitValue[int]     `json:"probabilityOfPrecipitation,omitempty"`
	Dewpoint                   UnitValue[float64] `json:"dewpoint,omitempty"`
	RelativeHumidity           UnitValue[int]     `json:"relativeHumidity,omitempty"`
	WindSpeed                  string             `json:"windSpeed,omitempty"`
	WindDirection              string             `json:"windDirection,omitempty"`
	Icon                       string             `json:"icon,omitempty"`
	ShortForecast              string             `json:"shortForecast,omitempty"`
	DetailedForecast           string             `json:"detailedForecast,omitempty"`
}

type DailyProps added in v0.20.0

type DailyProps struct {
	Updated time.Time     `json:"updated"`
	Units   string        `json:"units"`
	Periods []DailyPeriod `json:"periods"`
}

type HourlyPeriod

type HourlyPeriod struct {
	Number                     int                `json:"number"`
	StartTime                  time.Time          `json:"startTime"`
	Endime                     time.Time          `json:"endTime"`
	IsDayTime                  bool               `json:"isDayTime"`
	Temperature                int                `json:"temperature"`
	ProbabilityOfPrecipitation UnitValue[int]     `json:"probabilityOfPrecipitation"`
	DewPoint                   UnitValue[float64] `json:"dewpoint"`
	ShortForecast              string             `json:"shortForecast"`
}

type HourlyProps

type HourlyProps struct {
	Updated time.Time      `json:"updated"`
	Units   string         `json:"units"`
	Periods []HourlyPeriod `json:"periods"`
}

func (HourlyProps) GetHighLow

func (p HourlyProps) GetHighLow(hours int) (high int, low int)

type NwsClient

type NwsClient struct {
	// contains filtered or unexported fields
}

func New

func New() *NwsClient

func (*NwsClient) CoordinatesToPoint

func (c *NwsClient) CoordinatesToPoint(lat float64, lon float64) (Point, error)

func (*NwsClient) GetDailyForecast added in v0.20.0

func (c *NwsClient) GetDailyForecast(p Point) (DailyProps, error)

func (*NwsClient) GetHourlyForecast

func (c *NwsClient) GetHourlyForecast(p Point) (HourlyProps, error)

func (*NwsClient) GetLatestObservations

func (c *NwsClient) GetLatestObservations(p Point) (Observations, error)

func (*NwsClient) GetStations

func (c *NwsClient) GetStations(p Point) ([]string, error)

type Observations

type Observations struct {
	Timestamp     time.Time          `json:"timestamp"`
	Temperature   UnitValue[float64] `json:"temperature"`
	DewPoint      UnitValue[float64] `json:"dewpoint"`
	WindDirection UnitValue[int]     `json:"windDirection"`
	WindSpeed     UnitValue[float64] `json:"windSpeed"`
}

type Point

type Point struct {
	ID         string     `json:"id"`
	Properties PointProps `json:"properties"`
	Lat        float64
	Lon        float64
}

func (Point) GetWebURL added in v0.20.0

func (p Point) GetWebURL() string

type PointProps

type PointProps struct {
	GridId              string `json:"gridId"`
	GridX               int    `json:"gridX"`
	GridY               int    `json:"gridY"`
	Forecast            string `json:"forecast"`
	ForecastHourly      string `json:"forecastHourly"`
	ForecastGridData    string `json:"forecastGridData"`
	ForecastZone        string `json:"forecastZone"`
	TimeZone            string `json:"timeZone"`
	RadarStation        string `json:"radarStation"`
	ObservationStations string `json:"observationStations"`
}

type UnitValue

type UnitValue[T any] struct {
	UnitCode string `json:"unitCode"`
	Value    T      `json:"value"`
}

Jump to

Keyboard shortcuts

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