Show information about airports in decoded reports

This commit is contained in:
Elara 2023-08-22 17:45:03 -07:00
parent 35c5c70b25
commit d5d2f35b15
3 changed files with 320714 additions and 14 deletions

320696
airports/airports.go Normal file

File diff suppressed because it is too large Load Diff

6
taf.go
View File

@ -11,6 +11,7 @@ import (
"time" "time"
"github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2"
"go.elara.ws/taf/airports"
"go.elara.ws/taf/internal/parser" "go.elara.ws/taf/internal/parser"
"go.elara.ws/taf/units" "go.elara.ws/taf/units"
) )
@ -77,7 +78,10 @@ func ParseWithOptions(r io.Reader, opts Options) (*Forecast, error) {
for _, item := range ast.Items { for _, item := range ast.Items {
switch { switch {
case item.ID != nil: case item.ID != nil:
setField(out, "Identifier", *item.ID) fc.Identifier = *item.ID
if a, ok := airports.Airports[fc.Identifier]; ok {
fc.Airport = a
}
case item.Time != nil: case item.Time != nil:
t, err := parseTime(*item.Time) t, err := parseTime(*item.Time)
if err != nil { if err != nil {

View File

@ -3,13 +3,13 @@ package taf
import ( import (
"time" "time"
"go.elara.ws/taf/airports"
"go.elara.ws/taf/units" "go.elara.ws/taf/units"
) )
const None = ""
type Forecast struct { type Forecast struct {
Identifier string `json:"identifier,omitempty"` Identifier string `json:"identifier,omitempty"`
Airport airports.Airport `json:"airport,omitempty"`
PublishTime time.Time `json:"publish_time,omitempty"` PublishTime time.Time `json:"publish_time,omitempty"`
Valid ValidPair `json:"valid,omitempty"` Valid ValidPair `json:"valid,omitempty"`
Visibility Visibility `json:"visibility,omitempty"` Visibility Visibility `json:"visibility,omitempty"`