public-transport / hafas-client

JavaScript client for HAFAS public transport APIs.
ISC License
262 stars 52 forks source link

Expose warning status of remarks #141

Open debfx opened 4 years ago

debfx commented 4 years ago

The DB website shows some status remarks with a red exclamation icon instead of a gray one. However the hafas-client journeys() response doesn't expose this distinction.

Example:

"remL": [
    // ...
    {
        "type":"M",
        "code":"",
        "icoX":5,
        "txtS":"ICE 9572: Karlsruhe Hbf: Störung.",
        "txtN":"Aufgrund eines Notarzteinsatzes am Gleis in Vaihingen(Enz) kommt es zu erheblichen Beeinträchtigungen. Der Zug umgeleitet. Mit einer Reisezeitverlängerung von bis zu 910 Minuten muss gerechnet werden. Auch müssen Sie mit Teilausfällen rechnen Bitte prüfen Sie Ihre Reiseverbindung. (Letzte Aktualisierung 14:25)",
        "sIdx":0
    }
    // ...
]

Corresponding icon: {"res":"HimWarn"}

hafas-client response:

            {
              "type": "status",
              "summary": "ICE 9572: Stuttgart Hbf->Karlsruhe Hbf: Störung.",
              "code": null,
              "text": "Aufgrund eines Notarzteinsatzes am Gleis in Vaihingen(Enz) kommt es zu erheblichen Beeinträchtigungen. Der Zug umgeleitet. Mit einer Reisezeitverlängerung von bis zu 910 Minuten muss gerechnet werden. Auch müssen Sie mit Teilausfällen rechnen Bitte prüfen Sie Ihre Reiseverbindung. (Letzte Aktualisierung 14:25)"
            }

The easiest solution would be to add HimWarn: 'warning' to codesByIcon in parse/hint.js but I'm not sure if this would be appropriate to put it into the code field.

derhuerst commented 4 years ago

Thanks for reporting this, I'd definitely like to expose the info that the remark is something like a "warning"!

The easiest solution would be to add HimWarn: 'warning' to codesByIcon in parse/hint.js but I'm not sure if this would be appropriate to put it into the code field.

In type, I wanted to try to answer the question "What is the remark about?". Having type: 'warning' wouldn't tell me that the remark is about the status of a train/connection, even though the content of the remark might actually be.

But right now, hafas-client doesn't parse the remarks in a meaningful way, and I'm planning to overhaul the remarks parsing anyways in order to handle the sheer variety of messages out there. See #5, #90 and #131.

derhuerst commented 4 years ago

PR welcome!

derhuerst commented 3 years ago

related: The Deutsche Bahn official Timetable API docs have codes on the last 2 pages.