Skip to content

Cannot parse METARs with both COR and AUTO modifiers #15

@varyamereon

Description

@varyamereon

Description:

ICAO-format METARs commonly have both correction (COR) and automation (AUTO) modifiers together, but SwiftMETAR's Observer enum can only represent one state:

public enum Observer: String, Codable {
    case human = ""
    case automated = "AUTO"
    case corrected = "COR"
}

Current Behavior:

// ✅ Works
try await METAR.from(string: "EGLL 172050Z AUTO 08005KT 9999 NCD 03/M03 Q1016")
// observer = .automated

// ✅ Works
try await METAR.from(string: "EGLL 172050Z COR 08005KT 9999 NCD 03/M03 Q1016")
// observer = .corrected

// ❌ Fails with badFormat error
try await METAR.from(string: "EGLL 172050Z COR AUTO 08005KT 9999 NCD 03/M03 Q1016")

Expected Behavior:

Should parse successfully and preserve both pieces of information. The actual weather data (wind, temperature, QNH, etc.) is valid - the parser shouldn't fail entirely just because both modifiers are present.

Real-World Impact:

Many European automated weather stations issue corrected reports with this format. Currently, all such METARs fail to parse even though the weather data itself is perfectly valid.

Suggested Approaches:

  1. Separate boolean properties (simplest):
public var isAutomated: Bool
public var isCorrected: Bool
  1. OptionSet (more flexible):
public struct ObserverFlags: OptionSet {
    public let rawValue: Int
    public static let automated = ObserverFlags(rawValue: 1 << 0)
    public static let corrected = ObserverFlags(rawValue: 1 << 1)
}
public var observerFlags: ObserverFlags
  1. Graceful degradation (quickest fix):
    Parse either modifier and succeed, even if we can only store one. Parsing COR AUTO and only capturing .automated is better than failing completely.

References:

  • ICAO Annex 3 / Doc 8896 allows multiple modifiers
  • Example: Many UK automated stations (EGLL, EGKK, EGGD) regularly issue COR AUTO reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions