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

9
taf.go
View File

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