qutescoop / qutescoop

QuteScoop is a status indicator for the online flight simulation community VATSIM, compatible with Windows, Linux and (if you build it yourself) MacOS.
GNU General Public License v3.0
33 stars 15 forks source link

New ICAO aircraft type field needs parser change #7

Closed droesen closed 4 years ago

droesen commented 4 years ago

Hi,

VATSIM opened up a new pre-filing form on my.vatsim.net in ICAO format, asking for equipment codes etc and then putting ATYP, equipment and transponder codes together into the VATSIM data feed aircraft type field.

What was "T/B744/H" or similar before (FAA style) is now something like "B744/H-SDE3FGHIM1M2RWYY/LB1" when filed thru the new interface, as is now being used by SimBrief on VATSIM's explicit request.

While display is OK in the "flight" dialog (full details shown):

image

the "airport overview" dialog Arrivals/Departures lists are broken as they display only the WTC plus equipment code string (essentially: what it finds between the two "/" in aircraft type field).

image

To support both FAA- and ICAO-style ATYP fields, I suggest to use following parser logic:

If ATYP contains two slashes ("/"), check wether 2nd character of the string between the slashes is a hyphen "-", then you got an ICAO-style ATYP. In that case, use the part before the first slash as aircraft type to list in Arrivals/Departues "Type" column. Otherwise, use the string between the slashes as before (FAA-style ATYP).

Best regards, Daniel

droesen commented 4 years ago

The method that needs fixing/extending seems to be Pilot::aircraftType() in src/Pilot.cpp:

    if(network == VATSIM) {
        // VATSIM can be a real PITA.
        if(acftSegments.size() == 2 && acftSegments[0].length() > 2)
            return acftSegments[0];
        else if(acftSegments.size() >= 2)
            return acftSegments[1];
    }

suggested replacement:

    // VATSIM can be a real PITA, really
    if(network == VATSIM) {
        // FAA-style without WTC prefix (e.g. "B737/G")
        if(acftSegments.size() == 2 && acftSegments[0].length() > 2)
            return acftSegments[0];
        // ICAO-style (e.g. "A320/M-SDE2E3FGHIJ1RWXY/LB2")
        if(acftSegments.size() == 3 && acftSegments[0].length() > 2)
            return acftSegments[0];
        // FAA-style with ("H/B763/L") or without equipment suffix ("H/B763")
        else if(acftSegments.size() >= 2)
            return acftSegments[1];
    }

Sorry, no pull request... have no compile/build environment to even check for syntax...

Best regards, Daniel

jonaseberle commented 4 years ago

Thank you! That seems easy to fix. I hope to find the time for an automated build environment with Github actions so that we can actually release a new version.

droesen commented 4 years ago

BTW, Olli G pointed out that those two "acftSegments[0].length() > 2" seem botched, should be either "> 1" or ">= 2" as there are ICAO aircraft designators with just two letters. Seemed fishy to me as well but decided not to "fix" it in the same change, for one thing to keep things separate (different issue), and I'm not sure wether someone had a good reason for that... didn't want to break something en passent :-)

jonaseberle commented 4 years ago

Can you give an example for a string where this yields a wrong aircraftType?

ogruetzmann commented 4 years ago

There's AC-Types like A1, B2, C2 which won't match where they should. Example: B2/L Won't match if(acftSegments.size() == 2 && acftSegments[0].length() > 2) While B738/L will (and both should)

Also, B2/M-SDE2E3FGHIJ1RWXY/LB2 will not match if(acftSegments.size() == 3 && acftSegments[0].length() > 2)

See ICAO Doc 8643 https://www.icao.int/publications/DOC8643/Pages/Search.aspx

jonaseberle commented 4 years ago

I combined your input @droesen and @ogruetzmann. Thank you.

image

Maybe someone would like to help with https://github.com/qutescoop/qutescoop/issues/15?