nws

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 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 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) 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"`
}

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