2023-08-21 23:56:17 +00:00
|
|
|
package taf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-08-23 00:45:03 +00:00
|
|
|
"go.elara.ws/taf/airports"
|
2023-08-21 23:56:17 +00:00
|
|
|
"go.elara.ws/taf/units"
|
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Forecast represents a Terminal Aerodrome Forecast (TAF) weather report for a specific airport.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Forecast struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Identifier holds the ICAO airport identifier for which this forecast was issued.
|
|
|
|
Identifier string `json:"identifier,omitempty"`
|
|
|
|
|
|
|
|
// Airport provides additional information about the airport for which this forecast was issued.
|
|
|
|
Airport airports.Airport `json:"airport,omitempty"`
|
|
|
|
|
|
|
|
// PublishTime indicates the time at which this forecast was issued.
|
|
|
|
PublishTime time.Time `json:"publish_time,omitempty"`
|
|
|
|
|
|
|
|
// Valid defines the period during which this forecast is applicable.
|
|
|
|
Valid ValidPair `json:"valid,omitempty"`
|
|
|
|
|
|
|
|
// Visibility describes the anticipated visibility conditions.
|
|
|
|
Visibility Visibility `json:"visibility,omitempty"`
|
|
|
|
|
|
|
|
// Wind describes the projected wind conditions.
|
|
|
|
Wind Wind `json:"wind,omitempty"`
|
|
|
|
|
|
|
|
// SkyCondition lists the expected sky conditions.
|
|
|
|
SkyCondition []SkyCondition `json:"sky_condition,omitempty"`
|
|
|
|
|
|
|
|
// Temperature lists the expected temperature values.
|
|
|
|
Temperature []Temperature `json:"temperature,omitempty"`
|
|
|
|
|
|
|
|
// Weather lists information about the expected weather conditions.
|
|
|
|
Weather []Weather `json:"weather,omitempty"`
|
|
|
|
|
|
|
|
// Probabilities contains the probabilities for potential conditions.
|
|
|
|
Probabilities []*Probability `json:"probabilities,omitempty"`
|
|
|
|
|
|
|
|
// Changes lists any expected changes in conditions.
|
|
|
|
Changes []*Change `json:"changes,omitempty"`
|
|
|
|
|
|
|
|
// Flags contains special flags associated with the forecast.
|
|
|
|
Flags []Flag `json:"flags,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Change represents a change in weather conditions within a forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Change struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Type specifies the nature of this weather change.
|
|
|
|
Type ChangeType `json:"type,omitempty"`
|
|
|
|
|
|
|
|
// Valid defines the period during which this change is applicable.
|
|
|
|
Valid ValidPair `json:"valid,omitempty"`
|
|
|
|
|
|
|
|
// Visibility describes the anticipated visibility conditions.
|
|
|
|
Visibility Visibility `json:"visibility,omitempty"`
|
|
|
|
|
|
|
|
// Wind describes the projected wind conditions.
|
|
|
|
Wind Wind `json:"wind,omitempty"`
|
|
|
|
|
|
|
|
// SkyCondition lists the expected sky conditions.
|
2023-08-21 23:56:17 +00:00
|
|
|
SkyCondition []SkyCondition `json:"sky_condition,omitempty"`
|
2023-08-25 21:38:19 +00:00
|
|
|
|
|
|
|
// Temperature lists the expected temperature values.
|
|
|
|
Temperature []Temperature `json:"temperature,omitempty"`
|
|
|
|
|
|
|
|
// Weather lists information about the expected weather conditions.
|
|
|
|
Weather []Weather `json:"weather,omitempty"`
|
|
|
|
|
|
|
|
// Flags contains special flags associated with the change.
|
|
|
|
Flags []Flag `json:"flags,omitempty"`
|
|
|
|
|
|
|
|
// Probability indicates the percent chance of this change occurring.
|
|
|
|
Probability int `json:"probability,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Probability represents the probability of potential conditions occurring within a forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Probability struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Valid defines the period during which these potential conditions are applicable.
|
|
|
|
Valid ValidPair `json:"valid,omitempty"`
|
|
|
|
|
|
|
|
// Value indicates the percent chance of these conditions occurring.
|
|
|
|
Value int `json:"value,omitempty"`
|
|
|
|
|
|
|
|
// Visibility describes the anticipated visibility conditions.
|
|
|
|
Visibility Visibility `json:"visibility,omitempty"`
|
|
|
|
|
|
|
|
// Wind describes the projected wind conditions.
|
|
|
|
Wind Wind `json:"wind,omitempty"`
|
|
|
|
|
|
|
|
// SkyCondition lists the expected sky conditions.
|
2023-08-21 23:56:17 +00:00
|
|
|
SkyCondition []SkyCondition `json:"sky_condition,omitempty"`
|
2023-08-25 21:38:19 +00:00
|
|
|
|
|
|
|
// Temperature lists the expected temperature values.
|
|
|
|
Temperature []Temperature `json:"temperature,omitempty"`
|
|
|
|
|
|
|
|
// Weather lists information about the expected weather conditions.
|
|
|
|
Weather []Weather `json:"weather,omitempty"`
|
|
|
|
|
|
|
|
// Flags contains special flags associated with the potential conditions.
|
|
|
|
Flags []Flag `json:"flags,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// ValidPair represents a time interval for which weather data is valid.
|
2023-08-21 23:56:17 +00:00
|
|
|
type ValidPair struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// From represents the time from which the data is valid.
|
|
|
|
From time.Time `json:"from,omitempty"`
|
|
|
|
|
|
|
|
// To indicates the time until which the data is valid.
|
|
|
|
To time.Time `json:"to,omitempty"`
|
|
|
|
|
|
|
|
// Duration contains the total duration for which the data remains valid
|
2023-08-21 23:56:17 +00:00
|
|
|
Duration time.Duration `json:"duration,omitempty"`
|
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Visibility represents the visibility conditions in the forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Visibility struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Plus indicates whether visibility is expected to be greater than the specified value.
|
|
|
|
Plus bool `json:"plus,omitempty"`
|
|
|
|
|
|
|
|
// Value holds the visibility measurement. Its unit is determined by the Unit field.
|
|
|
|
Value float64 `json:"value,omitempty"`
|
|
|
|
|
|
|
|
// Unit specifies the unit of measurement for the visibility value.
|
|
|
|
Unit units.Distance `json:"unit,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// SkyConditionType represents different types of sky conditions in the forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type SkyConditionType string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Sky Condition Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
Few SkyConditionType = "Few"
|
|
|
|
Scattered SkyConditionType = "Scattered"
|
|
|
|
Broken SkyConditionType = "Broken"
|
|
|
|
Overcast SkyConditionType = "Overcast"
|
|
|
|
VerticalVisibility SkyConditionType = "VerticalVisibility"
|
|
|
|
SkyClear SkyConditionType = "SkyClear"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// CloudType represents different types of cloud formations.
|
2023-08-21 23:56:17 +00:00
|
|
|
type CloudType string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Cloud Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
CumuloNimbus CloudType = "CumuloNumbus"
|
|
|
|
ToweringCumulus CloudType = "ToweringCumulus"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// SkyCondition represents the condition of the sky, including cloud cover and altitude.
|
2023-08-21 23:56:17 +00:00
|
|
|
type SkyCondition struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Type specifies the nature of the expected sky condition.
|
|
|
|
Type SkyConditionType `json:"type,omitempty"`
|
|
|
|
|
|
|
|
// Altitude represents the altitude at which this sky condition is anticipated, in feet.
|
|
|
|
Altitude int `json:"altitude,omitempty"`
|
|
|
|
|
|
|
|
// CloudType defines the type of clouds expected in the sky.
|
|
|
|
CloudType CloudType `json:"cloud_type,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Wind represents wind-related information in a weather forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Wind struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Direction indicates the wind direction of the expected wind.
|
|
|
|
Direction Direction `json:"direction,omitempty"`
|
|
|
|
|
|
|
|
// WindShear specifies the altitude at which wind shear is expected.
|
|
|
|
WindShear int `json:"wind_shear,omitempty"`
|
|
|
|
|
|
|
|
// Speed represents the anticipated wind speed. The unit is determined by the Unit field.
|
|
|
|
Speed int `json:"speed,omitempty"`
|
|
|
|
|
|
|
|
// Gusts holds the projected gust speed. The unit is determined by the Unit field.
|
|
|
|
Gusts int `json:"gusts,omitempty"`
|
|
|
|
|
|
|
|
// Unit denotes the unit of measurement for wind and gust speeds.
|
|
|
|
Unit units.Speed `json:"unit,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Direction describes the wind direction, which can be variable.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Direction struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Variable signifies if the wind direction is variable. When true, Value is set to zero.
|
2023-08-21 23:56:17 +00:00
|
|
|
Variable bool `json:"variable,omitempty"`
|
2023-08-25 21:38:19 +00:00
|
|
|
|
|
|
|
// Value specifies the wind direction in degrees.
|
|
|
|
Value int `json:"value,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Modifier represents modifiers for weather conditions, such as "Heavy" or "Light".
|
2023-08-21 23:56:17 +00:00
|
|
|
type Modifier string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Weather Modifiers
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-25 21:38:19 +00:00
|
|
|
// Heavy indicates that weather conditions are expected to be severe.
|
2023-08-23 00:34:26 +00:00
|
|
|
Heavy Modifier = "Heavy"
|
2023-08-25 21:38:19 +00:00
|
|
|
// Light indicates that weather conditions are expected to be mild.
|
2023-08-23 00:34:26 +00:00
|
|
|
Light Modifier = "Light"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Descriptor represents descriptors for weather conditions, such as "Shallow" or "Showers".
|
2023-08-21 23:56:17 +00:00
|
|
|
type Descriptor string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Weather Descriptors
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
Shallow Descriptor = "Shallow"
|
|
|
|
Patches Descriptor = "Patches"
|
|
|
|
LowDrifting Descriptor = "LowDrifting"
|
|
|
|
Blowing Descriptor = "Blowing"
|
|
|
|
Showers Descriptor = "Showers"
|
|
|
|
Thunderstorm Descriptor = "Thunderstorm"
|
|
|
|
Freezing Descriptor = "Freezing"
|
|
|
|
Partial Descriptor = "Partial"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Precipitation represents different types of precipitation.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Precipitation string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Precipitation Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
Drizzle Precipitation = "Drizzle"
|
|
|
|
Rain Precipitation = "Rain"
|
|
|
|
Snow Precipitation = "Snow"
|
|
|
|
SnowGrains Precipitation = "SnowGrains"
|
|
|
|
IceCrystals Precipitation = "IceCrystals"
|
|
|
|
IcePellets Precipitation = "IcePellets"
|
|
|
|
Hail Precipitation = "Hail"
|
|
|
|
SmallHail Precipitation = "SmallHail"
|
|
|
|
Unknown Precipitation = "Unknown"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Obscuration represents different types of atmospheric obscurations.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Obscuration string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Atmospheric Obscuration Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
Mist Obscuration = "Mist"
|
|
|
|
Fog Obscuration = "Fog"
|
|
|
|
Smoke Obscuration = "Smoke"
|
|
|
|
Dust Obscuration = "Dust"
|
|
|
|
Sand Obscuration = "Sand"
|
|
|
|
Haze Obscuration = "Haze"
|
|
|
|
Spray Obscuration = "Spray"
|
|
|
|
VolcanicAsh Obscuration = "VolcanicAsh"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Phenomenon represents different atmospheric phenomena like whirls, squalls, etc.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Phenomenon string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Weather Phenomena
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
Whirls Phenomenon = "Whirls"
|
|
|
|
Squalls Phenomenon = "Squalls"
|
|
|
|
FunnelCloud Phenomenon = "FunnelCloud"
|
|
|
|
Sandstorm Phenomenon = "Sandstorm"
|
|
|
|
Duststorm Phenomenon = "Duststorm"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Weather represents various weather-related conditions in the forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Weather struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Vicinity specifies if the described weather is occurring near the airport.
|
|
|
|
Vicinity bool `json:"vicinity,omitempty"`
|
|
|
|
|
|
|
|
// Modifier indicates the severity of the weather conditions.
|
|
|
|
Modifier Modifier `json:"modifier,omitempty"`
|
|
|
|
|
|
|
|
// Descriptor provides details about the specific type of expected weather.
|
|
|
|
Descriptor Descriptor `json:"descriptor,omitempty"`
|
|
|
|
|
|
|
|
// Precipitation indicates the anticipated type of precipitation.
|
2023-08-21 23:56:17 +00:00
|
|
|
Precipitation Precipitation `json:"precipitation,omitempty"`
|
2023-08-25 21:38:19 +00:00
|
|
|
|
|
|
|
// Obscuration describes any potential atmospheric obscurations expected.
|
|
|
|
Obscuration Obscuration `json:"obscuration,omitempty"`
|
|
|
|
|
|
|
|
// Phenomenon contains anticipated weather phenomena.
|
|
|
|
Phenomenon Phenomenon `json:"phenomenon,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// TemperatureType represents different types of temperature data, like "High" or "Low".
|
2023-08-21 23:56:17 +00:00
|
|
|
type TemperatureType string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Temperature Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-23 00:34:26 +00:00
|
|
|
High TemperatureType = "High"
|
|
|
|
Low TemperatureType = "Low"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Temperature represents temperature-related details in the forecast.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Temperature struct {
|
2023-08-25 21:38:19 +00:00
|
|
|
// Type specifies if this temperature is a high or low value.
|
|
|
|
Type TemperatureType `json:"type,omitempty"`
|
|
|
|
|
|
|
|
// Value holds the anticipated temperature in degrees Celsius.
|
|
|
|
Value int `json:"value,omitempty"`
|
|
|
|
|
|
|
|
// Time indicates the expected time for this temperature.
|
|
|
|
Time time.Time `json:"time,omitempty"`
|
2023-08-21 23:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// ChangeType represents different types of changes in weather conditions.
|
2023-08-21 23:56:17 +00:00
|
|
|
type ChangeType string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Change Types
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-25 21:38:19 +00:00
|
|
|
// From indicates a rapid change.
|
|
|
|
From ChangeType = "From"
|
|
|
|
// Becoming indicates a slow or gradual change.
|
|
|
|
Becoming ChangeType = "Becoming"
|
|
|
|
// Temporary indicates that a change is expected to last generally less than an hour.
|
2023-08-23 00:34:26 +00:00
|
|
|
Temporary ChangeType = "Temporary"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Flag represents special flags for specific weather conditions.
|
2023-08-21 23:56:17 +00:00
|
|
|
type Flag string
|
|
|
|
|
2023-08-25 21:38:19 +00:00
|
|
|
// Flags
|
2023-08-21 23:56:17 +00:00
|
|
|
const (
|
2023-08-25 21:38:19 +00:00
|
|
|
// CeilingAndVisibilityOK indicates that visibility is over 10km, that
|
|
|
|
// there are no significant clouds, and no significant weather
|
2023-08-23 00:34:26 +00:00
|
|
|
CeilingAndVisibilityOK Flag = "CeilingAndVisibilityOK"
|
2023-08-21 23:56:17 +00:00
|
|
|
)
|