weather

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MPSToKT      = 1.944
	MetersToFeet = 3.281
)

Variables

View Source
var CloudPresets map[string][]CloudPreset = map[string][]CloudPreset{
	"FEW": {
		{`"Preset1"`, 840, 4200},
		{`"Preset2"`, 1260, 2520},
	},
	"SCT": {
		{`"Preset3"`, 840, 2520},
		{`"Preset4"`, 1260, 2520},
		{`"Preset5"`, 1260, 4620},
		{`"Preset6"`, 1260, 4200},
		{`"Preset7"`, 1680, 5040},
		{`"Preset8"`, 3780, 5460},
		{`"Preset9"`, 1680, 3780},
		{`"Preset10"`, 1260, 4200},
		{`"Preset11"`, 2520, 5460},
		{`"Preset12"`, 1680, 3360},
	},
	"BKN": {
		{`"Preset13"`, 1680, 3360},
		{`"Preset14"`, 1680, 3360},
		{`"Preset15"`, 840, 5040},
		{`"Preset16"`, 1260, 4200},
		{`"Preset17"`, 0, 2520},
		{`"Preset18"`, 0, 3780},
		{`"Preset19"`, 0, 2940},
		{`"Preset20"`, 0, 3780},
	},
	"OVC": {
		{`"Preset21"`, 1260, 4200},
		{`"Preset22"`, 420, 4200},
		{`"Preset23"`, 840, 3360},
		{`"Preset24"`, 420, 2520},
		{`"Preset25"`, 420, 3360},
		{`"Preset26"`, 420, 2940},
		{`"Preset27"`, 420, 2520},
	},
	"OVC+RA": {
		{`"RainyPreset1"`, 420, 2940},
		{`"RainyPreset2"`, 840, 2520},
		{`"RainyPreset3"`, 840, 2520},
	},
}
View Source
var (
	DecodePreset = map[string][]Cloud{
		`"Preset1"`:      {{"FEW", "070"}},
		`"Preset2"`:      {{"FEW", "080"}, {"SCT", "230"}},
		`"Preset3"`:      {{"SCT", "080"}, {"FEW", "210"}},
		`"Preset4"`:      {{"SCT", "080"}, {"SCT", "240"}},
		`"Preset5"`:      {{"SCT", "140"}, {"FEW", "270"}, {"BKN", "400"}},
		`"Preset6"`:      {{"SCT", "080"}, {"FEW", "400"}},
		`"Preset7"`:      {{"BKN", "075"}, {"SCT", "210"}, {"SCT", "400"}},
		`"Preset8"`:      {{"SCT", "180"}, {"FEW", "360"}, {"FEW", "400"}},
		`"Preset9"`:      {{"BKN", "075"}, {"SCT", "200"}, {"FEW", "410"}},
		`"Preset10"`:     {{"SCT", "180"}, {"FEW", "360"}, {"FEW", "400"}},
		`"Preset11"`:     {{"BKN", "180"}, {"BKN", "320"}, {"FEW", "410"}},
		`"Preset12"`:     {{"BKN", "120"}, {"SCT", "220"}, {"FEW", "410"}},
		`"Preset13"`:     {{"BKN", "120"}, {"BKN", "260"}, {"FEW", "410"}},
		`"Preset14"`:     {{"BKN", "070"}, {"FEW", "410"}},
		`"Preset15"`:     {{"SCT", "140"}, {"BKN", "240"}, {"FEW", "400"}},
		`"Preset16"`:     {{"BKN", "140"}, {"BKN", "280"}, {"FEW", "400"}},
		`"Preset17"`:     {{"BKN", "070"}, {"BKN", "200"}, {"BKN", "320"}},
		`"Preset18"`:     {{"BKN", "130"}, {"BKN", "250"}, {"BKN", "380"}},
		`"Preset19"`:     {{"OVC", "090"}, {"BKN", "230"}, {"BKN", "310"}},
		`"Preset20"`:     {{"BKN", "130"}, {"BKN", "280"}, {"FEW", "380"}},
		`"Preset21"`:     {{"BKN", "070"}, {"OVC", "170"}},
		`"Preset22"`:     {{"OVC", "070"}, {"BKN", "170"}},
		`"Preset23"`:     {{"OVC", "110"}, {"BKN", "180"}, {"SCT", "320"}},
		`"Preset24"`:     {{"OVC", "030"}, {"OVC", "170"}, {"BKN", "340"}},
		`"Preset25"`:     {{"OVC", "120"}, {"OVC", "220"}, {"OVC", "400"}},
		`"Preset26"`:     {{"OVC", "090"}, {"BKN", "230"}, {"SCT", "320"}},
		`"Preset27"`:     {{"OVC", "080"}, {"BKN", "250"}, {"BKN", "340"}},
		`"RainyPreset1"`: {{"OVC", "030"}, {"OVC", "280"}, {"FEW", "400"}},
		`"RainyPreset2"`: {{"OVC", "030"}, {"SCT", "180"}, {"FEW", "400"}},
		`"RainyPreset3"`: {{"OVC", "060"}, {"OVC", "190"}, {"SCT", "340"}},
	}
)
View Source
var SelectedBase int
View Source
var SelectedPreset string

Functions

func CelsiusToFahrenheit added in v1.11.0

func CelsiusToFahrenheit(c float64) float64

func GenerateMETAR added in v1.11.0

func GenerateMETAR(wx WeatherData) (string, error)

GenerateMETAR generates a metar based on the weather settings added to the DCS miz

Types

type Barometer

type Barometer struct {
	Hg  float64 `json:"hg"`
	HPa float64 `json:"hpa"`
	KPa float64 `json:"kpa"`
	MB  float64 `json:"mb"`
}

type Ceiling

type Ceiling struct {
	BaseFeetAGL   float64 `json:"base_feet_agl"`
	BaseMetersAGL float64 `json:"base_meters_agl"`
	Code          string  `json:"code"`
	Feet          float64 `json:"feet"`
	Meters        float64 `json:"meters"`
	Text          string  `json:"text"`
}

type Cloud added in v1.11.0

type Cloud struct {
	Name string
	Base string
}

type CloudPreset added in v1.3.0

type CloudPreset struct {
	Name    string
	MinBase int
	MaxBase int
}

type Clouds

type Clouds struct {
	BaseFeetAGL   float64 `json:"base_feet_agl"`
	BaseMetersAGL float64 `json:"base_meters_agl"`
	Code          string  `json:"code"`
	Feet          float64 `json:"feet"`
	Meters        float64 `json:"meters"`
	Text          string  `json:"text"`
}

type Conditions

type Conditions struct {
	Code string `json:"code"`
	Text string `json:"text"`
}

type Data

type Data struct {
	Barometer      Barometer      `json:"barometer"`
	Ceiling        Ceiling        `json:"ceiling"`
	Clouds         []Clouds       `json:"clouds"`
	Conditions     []Conditions   `json:"conditions"`
	Dewpoint       Dewpoint       `json:"dewpoint"`
	Elevation      Elevation      `json:"elevation"`
	FlightCategory FlightCategory `json:"flight_category"`
	Humidity       Humidity       `json:"humidity"`
	ICAO           string         `json:"icao"`
	ID             string         `json:"id"`
	Location       Location       `json:"location"`
	Observed       string         `json:"observed"`
	RawText        string         `json:"raw_text"`
	Station        Station        `json:"station"`
	Temperature    Temperature    `json:"temperature"`
	Visibility     Visibility     `json:"visibility"`
	Wind           Wind           `json:"wind"`
}

type Dewpoint

type Dewpoint struct {
	Celsius    float64 `json:"celsius"`
	Fahrenheit float64 `json:"fahrenheit"`
}

type Elevation

type Elevation struct {
	Feet   float64 `json:"feet"`
	Meters float64 `json:"meters"`
}

type FlightCategory

type FlightCategory string

type Humidity

type Humidity struct {
	Percent float64 `json:"percent"`
}

type Location

type Location struct {
	Coordinates []float64 `json:"coordinates"`
	Type        string    `json:"type"`
}

type Station

type Station struct {
	Name string `json:"name"`
}

type Temperature

type Temperature struct {
	Celsius    float64 `json:"celsius"`
	Fahrenheit float64 `json:"fahrenheit"`
}

type Visibility

type Visibility struct {
	Meters      string  `json:"meters"`
	MetersFloat float64 `json:"meters_float"`
	Miles       string  `json:"miles"`
	MilesFloat  float64 `json:"miles_float"`
}

type WeatherData

type WeatherData struct {
	Data       []Data `json:"data"`
	NumResults int    `json:"results"`
}
var DefaultWeather WeatherData = WeatherData{
	Data: []Data{
		{
			Wind: Wind{
				SpeedMPS: 1.25,
				Degrees:  270,
				GustMPS:  3,
			},
			Temperature: Temperature{
				Celsius: 15,
			},
			Barometer: Barometer{
				Hg: 29.92,
			},
			Clouds: []Clouds{
				{
					Code: "CLR",
				},
			},
			Observed: time.Now().Format("2006-01-02T15:04:05"),
		},
	},
	NumResults: 1,
}

func GetWeather

func GetWeather() (WeatherData, error)

type Wind

type Wind struct {
	Degrees  float64 `json:"degrees"`
	SpeedKPH float64 `json:"speed_kph"`
	SpeedKTS float64 `json:"speed_kts"`
	SpeedMPH float64 `json:"speed_mph"`
	SpeedMPS float64 `json:"speed_mps"`
	GustKPH  float64 `json:"gust_kph"`
	GustKTS  float64 `json:"gust_kts"`
	GustMPH  float64 `json:"gust_mph"`
	GustMPS  float64 `json:"gust_mps"`
}

Jump to

Keyboard shortcuts

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