OpendataCH / Transport

Swiss public transport API
http://transport.opendata.ch/
MIT License
241 stars 50 forks source link

different name and number for the same train when calling /connections /stationboard apis #122

Closed awahed closed 8 years ago

awahed commented 8 years ago

Hi,

When I call

/stationboard

I got this as the information of a train name: "S 60", category: "S", subcategory: "S", categoryCode: 5, number: "60", operator: "FLP", to: "Ponte Tresa",

/connections

if I call the /connections I get the following as the info for the same train journey: { name: "S 60 22", category: "S", subcategory: null, categoryCode: 5, number: "22", operator: "FLP", to: "Ponte Tresa",

please notice also the name and number field.

Can you please let me know what is the logic behind this or if it is possibile to fix it. Regards

http://transport.opendata.ch/v1/connections?direct=1&limit=6&transportations%5B%5D=ec_ic&transportations%5B%5D=ice_tgv_rj&transportations%5B%5D=ir&transportations%5B%5D=re_d&transportations%5B%5D=s_sn_r&from=8505300&to=008505398&date=2016-04-07&time=16%3A20

http://transport.opendata.ch/v1/stationboard?transportations%5B%5D=ec_ic&transportations%5B%5D=ice_tgv_rj&transportations%5B%5D=ir&transportations%5B%5D=re_d&transportations%5B%5D=s_sn_r&station=8505391&datetime=2016-04-07+17%3A25

fabian commented 8 years ago

The code responsible for the train information is located in Journey.php. As you can see the we don't try to parse the train name/number ourself but just pass the information from SBB on.

A good test is usually also to try the same thing in the official SBB app. Judging from the following screenshots it seems there is some inconsistency in the SBB database with the names "S 60 22" and "S 60":

Looking at the actual XML response confirms this the value for <Attribute type="NAME"> differs for the two responses. Here's the relevant part of the response for /connections:

screenshot 2016-04-07 17 50 53

And here for /stationboard:

screenshot 2016-04-07 17 51 03

screenshot 2016-04-07 17 51 14

Would it help you if we would also parse the LINE attribute which would give you the number "60" for the /stationboard? Note that LINE would still be missing from /connections.