Show information about airports in decoded reports
This commit is contained in:
parent
35c5c70b25
commit
d5d2f35b15
320696
airports/airports.go
Normal file
320696
airports/airports.go
Normal file
File diff suppressed because it is too large
Load Diff
6
taf.go
6
taf.go
@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/participle/v2"
|
||||
"go.elara.ws/taf/airports"
|
||||
"go.elara.ws/taf/internal/parser"
|
||||
"go.elara.ws/taf/units"
|
||||
)
|
||||
@ -77,7 +78,10 @@ func ParseWithOptions(r io.Reader, opts Options) (*Forecast, error) {
|
||||
for _, item := range ast.Items {
|
||||
switch {
|
||||
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:
|
||||
t, err := parseTime(*item.Time)
|
||||
if err != nil {
|
||||
|
26
types.go
26
types.go
@ -3,23 +3,23 @@ package taf
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.elara.ws/taf/airports"
|
||||
"go.elara.ws/taf/units"
|
||||
)
|
||||
|
||||
const None = ""
|
||||
|
||||
type Forecast struct {
|
||||
Identifier string `json:"identifier,omitempty"`
|
||||
PublishTime time.Time `json:"publish_time,omitempty"`
|
||||
Valid ValidPair `json:"valid,omitempty"`
|
||||
Visibility Visibility `json:"visibility,omitempty"`
|
||||
Wind Wind `json:"wind,omitempty"`
|
||||
SkyCondition []SkyCondition `json:"sky_condition,omitempty"`
|
||||
Temperature []Temperature `json:"temperature,omitempty"`
|
||||
Weather []Weather `json:"weather,omitempty"`
|
||||
Probabilities []*Probability `json:"probabilities,omitempty"`
|
||||
Changes []*Change `json:"changes,omitempty"`
|
||||
Flags []Flag `json:"flags,omitempty"`
|
||||
Identifier string `json:"identifier,omitempty"`
|
||||
Airport airports.Airport `json:"airport,omitempty"`
|
||||
PublishTime time.Time `json:"publish_time,omitempty"`
|
||||
Valid ValidPair `json:"valid,omitempty"`
|
||||
Visibility Visibility `json:"visibility,omitempty"`
|
||||
Wind Wind `json:"wind,omitempty"`
|
||||
SkyCondition []SkyCondition `json:"sky_condition,omitempty"`
|
||||
Temperature []Temperature `json:"temperature,omitempty"`
|
||||
Weather []Weather `json:"weather,omitempty"`
|
||||
Probabilities []*Probability `json:"probabilities,omitempty"`
|
||||
Changes []*Change `json:"changes,omitempty"`
|
||||
Flags []Flag `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
type Change struct {
|
||||
|
Loading…
Reference in New Issue
Block a user