Fix issue where a sky condition without an altitude broke the interpreter

This commit is contained in:
Elara 2023-08-21 21:37:40 -07:00
parent 4e31390079
commit 6116c1d9b7

5
taf.go
View File

@ -107,10 +107,13 @@ func ParseWithOptions(r io.Reader, opts Options) (*Forecast, error) {
Precipitation: Precipitation(item.Vicinity.Precipitation), Precipitation: Precipitation(item.Vicinity.Precipitation),
}) })
case item.SkyCondition != nil: case item.SkyCondition != nil:
altitude, err := strconv.Atoi(item.SkyCondition.Altitude) var altitude int
if item.SkyCondition.Altitude != "" {
altitude, err = strconv.Atoi(item.SkyCondition.Altitude)
if err != nil { if err != nil {
return nil, participle.Errorf(item.SkyCondition.Pos, "sky: %s", err) return nil, participle.Errorf(item.SkyCondition.Pos, "sky: %s", err)
} }
}
appendField(out, "SkyCondition", SkyCondition{ appendField(out, "SkyCondition", SkyCondition{
Altitude: altitude * 100, // Scale factor for altitude is 100 Altitude: altitude * 100, // Scale factor for altitude is 100