public-transport / hafas-client

JavaScript client for HAFAS public transport APIs.
ISC License
278 stars 54 forks source link

Provide prodCtx.catOut field #242

Closed yu-re-ka closed 3 years ago

yu-re-ka commented 3 years ago

I would call it line.productName in the output. It contains something like "ICE", "IC", "S", "U", "Tram", "Bus", but also sometimes things that are not part of the profile product map like "ECE", "EST", "EN", "NJ", "HLB", "BRB". This is useful for displaying which products are used in a connection. It also seems to be consistent across different profiles.

screenshot1

On the DB profile I can split off (with space as delimiter) the first part of line.name and it is the same as catOut, but that seems like a hack and it doesn't work on other profiles like VBB and BVG.

derhuerst commented 3 years ago

That's a good idea, but I would first like to know if catOut is actually being used consistently across all endpoints.

Can you check how other endpoints make use of this field? Make sure to pick a mix of local, regional and national providers.

yu-re-ka commented 3 years ago

Extracted from the test fixtures:

      1 "catOut":"ALT     "
      1 "catOut":"D       "
      1 "catOut":"Fähre   "
      1 "catOut":"FEX     "
      1 "catOut":"IL      "
      1 "catOut":"IRE     "
      1 "catOut":"Lift    "
      1 "catOut":"LT      "
      1 "catOut":"S1      "
      1 "catOut":"S10     "
      1 "catOut":"S2      "
      1 "catOut":"S6      "
      1 "catOut":"ssb     "
      1 "catOut":"THA     "
      2 "catOut":"DPF     "
      2 "catOut":"L       "
      3 "catOut":"BRB"
      3 "catOut":"Togbus  "
      4 "catOut":"Fern    "
      4 "catOut":"Rufbus  "
      4 "catOut":"SEV     "
      4 "catOut":"WB      "
      5 "catOut":"EC"
      5 "catOut":"ECE     "
      5 "catOut":"Métro   "
      6 "catOut":"EN      "
      8 "catOut":"B"
      8 "catOut":"Bus (LT)"
      8 "catOut":"R       "
      8 "catOut":"T       "
      9 "catOut":"NJ      "
      9 "catOut":"REX     "
     10 "catOut":""
     10 "catOut":"CJX     "
     10 "catOut":"IR"
     11 "catOut":"ag "
     11 "catOut":"RNV"
     11 "catOut":"RUF     "
     11 "catOut":"U-Bahn  "
     12 "catOut":"S-Tog   "
     12 "catOut":"TER     "
     14 "catOut":"TGV     "
     15 "catOut":"B       "
     16 "catOut":"EC      "
     16 "catOut":"Tramway "
     21 "catOut":"O-Bus   "
     23 "catOut":"Citybus "
     30 "catOut":"RJ      "
     32 "catOut":"ICE"
     40 "catOut":"AST     "
     40 "catOut":"ICL     "
     42 "catOut":"RJX     "
     44 "catOut":"Re      "
     47 "catOut":"RT      "
     50 "catOut":"ICE     "
     52 "catOut":"DPN     "
     55 "catOut":"RE"
     59 "catOut":"Bus"
     60 "catOut":"RB"
     60 "catOut":"S-Bahn  "
     60 "catOut":"U"
     62 "catOut":"Str     "
     62 "catOut":"Zug     "
     64 "catOut":"Trm     "
     69 "catOut":"STR"
     75 "catOut":"IC"
    132 "catOut":"STR     "
    139 "catOut":"IC      "
    162 "catOut":"Tram    "
    230 "catOut":"RB      "
    238 "catOut":"S       "
    265 "catOut":"RE      "
    268 "catOut":"S"
    365 "catOut":"U       "
   2645 "catOut":"Bus     "

The "catOut":"" cases are all in VAO or ZVV fixtures. I would set line.productName to null when catOut is an empty string after trimming.

derhuerst commented 3 years ago

Alright, PR welcome!

yu-re-ka commented 3 years ago

Is there an automated way to update the test fixtures (the output)? Something like the snapshot functionality of tap?

derhuerst commented 3 years ago

No, it's a manual process, somewhat on purpose.

For the E2E tests within test/e2e, it's actually even more tedious, as you need to update the mocked date+time to a value that works with all endpoints. Then you would do rm test/e2e/fixtures/* && npm run test-integration:record; It will record up-to-date response fixtures as files in test/e2e/fixtures.