Update deps

This commit is contained in:
eleksir
2025-02-09 15:15:23 +03:00
parent 07430d87ed
commit 6cebe40018
206 changed files with 6461 additions and 3066 deletions

View File

@@ -25,24 +25,24 @@ import (
// CurrentWeatherData struct contains an aggregate view of the structs
// defined above for JSON to be unmarshaled into.
type CurrentWeatherData struct {
GeoPos Coordinates `json:"coord"`
Sys Sys `json:"sys"`
Base string `json:"base"`
Weather []Weather `json:"weather"`
Main Main `json:"main"`
Visibility int `json:"visibility"`
Wind Wind `json:"wind"`
Clouds Clouds `json:"clouds"`
Rain Rain `json:"rain"`
Snow Snow `json:"snow"`
Dt int `json:"dt"`
ID int `json:"id"`
Name string `json:"name"`
Cod int `json:"cod"`
Timezone int `json:"timezone"`
Unit string
Lang string
Key string
GeoPos Coordinates `json:"coord"`
Sys Sys `json:"sys"`
Base string `json:"base"`
Weather []Weather `json:"weather"`
Main Main `json:"main"`
Visibility int `json:"visibility"`
Wind Wind `json:"wind"`
Clouds Clouds `json:"clouds"`
Rain Rain `json:"rain"`
Snow Snow `json:"snow"`
Dt int `json:"dt"`
ID int `json:"id"`
Name string `json:"name"`
Cod int `json:"cod"`
Timezone int `json:"timezone"`
Unit string
Lang string
Key string
*Settings
}

View File

@@ -68,7 +68,7 @@ type HistoricalWeatherData struct {
}
// NewHistorical returns a new HistoricalWeatherData pointer with
//the supplied arguments.
// the supplied arguments.
func NewHistorical(unit, key string, options ...Option) (*HistoricalWeatherData, error) {
h := &HistoricalWeatherData{
Settings: NewSettings(),

View File

@@ -17,20 +17,22 @@ import (
"encoding/json"
"fmt"
"strings"
"time"
)
// OneCallData struct contains an aggregate view of the structs
// defined above for JSON to be unmarshaled into.
type OneCallData struct {
Latitude float64 `json:"lat"`
Longitude float64 `json:"lon"`
Timezone string `json:"timezone"`
TimezoneOffset int `json:"timezone_offset"`
Current OneCallCurrentData `json:"current,omitempty"`
Minutely []OneCallMinutelyData `json:"minutely,omitempty"`
Hourly []OneCallHourlyData `json:"hourly,omitempty"`
Daily []OneCallDailyData `json:"daily,omitempty"`
Alerts []OneCallAlertData `json:"alerts,omitempty"`
Latitude float64 `json:"lat"`
Longitude float64 `json:"lon"`
Timezone string `json:"timezone"`
TimezoneOffset int `json:"timezone_offset"`
Current OneCallCurrentData `json:"current,omitempty"`
Minutely []OneCallMinutelyData `json:"minutely,omitempty"`
Hourly []OneCallHourlyData `json:"hourly,omitempty"`
Daily []OneCallDailyData `json:"daily,omitempty"`
Alerts []OneCallAlertData `json:"alerts,omitempty"`
Data []OneCallTimeMachineData `json:"data,omitempty"`
Unit string
Lang string
@@ -39,6 +41,24 @@ type OneCallData struct {
*Settings
}
type OneCallTimeMachineData 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"`
Clouds int `json:"clouds"`
UVI float64 `json:"uvi"`
Visibility int `json:"visibility"`
WindSpeed float64 `json:"wind_speed"`
WindGust float64 `json:"wind_gust,omitempty"`
WindDeg float64 `json:"wind_deg"`
Weather []Weather `json:"weather"`
}
type OneCallCurrentData struct {
Dt int `json:"dt"`
Sunrise int `json:"sunrise"`
@@ -161,7 +181,19 @@ func NewOneCall(unit, lang, key string, excludes []string, options ...Option) (*
// OneCallByCoordinates will provide the onecall weather with the
// provided location coordinates.
func (w *OneCallData) OneCallByCoordinates(location *Coordinates) error {
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(onecallURL, "appid=%s&lat=%f&lon=%f&units=%s&lang=%s&exclude=%s"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang, w.Excludes))
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(onecallURL, "?appid=%s&lat=%f&lon=%f&units=%s&lang=%s&exclude=%s"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang, w.Excludes))
if err != nil {
return err
}
defer response.Body.Close()
return json.NewDecoder(response.Body).Decode(&w)
}
// OneCallTimeMachine will provide the onecall timemachine weather with the
// provided location coordinates and unix timestamp
func (w *OneCallData) OneCallTimeMachine(location *Coordinates, datetime time.Time) error {
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(onecallURL, "/timemachine?appid=%s&lat=%f&lon=%f&units=%s&lang=%s&dt=%d"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang, datetime.Unix()))
if err != nil {
return err
}

View File

@@ -35,7 +35,7 @@ var (
var DataUnits = map[string]string{"C": "metric", "F": "imperial", "K": "internal"}
var (
baseURL = "https://api.openweathermap.org/data/2.5/weather?%s"
onecallURL = "https://api.openweathermap.org/data/3.0/onecall?%s"
onecallURL = "https://api.openweathermap.org/data/3.0/onecall%s"
iconURL = "https://openweathermap.org/img/w/%s"
groupURL = "http://api.openweathermap.org/data/2.5/group?%s"
stationURL = "https://api.openweathermap.org/data/2.5/station?id=%d"

View File

@@ -106,33 +106,33 @@ type UVIndexInfo struct {
// UVData contains data in regards to UV index ranges, rankings, and steps for protection
var UVData = []UVIndexInfo{
{
UVIndex: []float64{0, 2.9},
MGC: "Green",
Risk: "Low",
UVIndex: []float64{0, 2.9},
MGC: "Green",
Risk: "Low",
RecommendedProtection: "Wear sunglasses on bright days; use sunscreen if there is snow on the ground, which reflects UV radiation, or if you have particularly fair skin.",
},
{
UVIndex: []float64{3, 5.9},
MGC: "Yellow",
Risk: "Moderate",
UVIndex: []float64{3, 5.9},
MGC: "Yellow",
Risk: "Moderate",
RecommendedProtection: "Take precautions, such as covering up, if you will be outside. Stay in shade near midday when the sun is strongest.",
},
{
UVIndex: []float64{6, 7.9},
MGC: "Orange",
Risk: "High",
UVIndex: []float64{6, 7.9},
MGC: "Orange",
Risk: "High",
RecommendedProtection: "Cover the body with sun protective clothing, use SPF 30+ sunscreen, wear a hat, reduce time in the sun within three hours of solar noon, and wear sunglasses.",
},
{
UVIndex: []float64{8, 10.9},
MGC: "Red",
Risk: "Very high",
UVIndex: []float64{8, 10.9},
MGC: "Red",
Risk: "Very high",
RecommendedProtection: "Wear SPF 30+ sunscreen, a shirt, sunglasses, and a wide-brimmed hat. Do not stay in the sun for too long.",
},
{
UVIndex: []float64{11},
MGC: "Violet",
Risk: "Extreme",
UVIndex: []float64{11},
MGC: "Violet",
Risk: "Extreme",
RecommendedProtection: "Take all precautions: Wear SPF 30+ sunscreen, a long-sleeved shirt and trousers, sunglasses, and a very broad hat. Avoid the sun within three hours of solar noon.",
},
}