alexander-albers / tripkit

Swift library for querying data from public transport providers.
MIT License
81 stars 8 forks source link

DB Provider uses ID as name #83

Closed victorlobe closed 1 year ago

victorlobe commented 1 year ago

This issue is only present in DB Provider, the getUniqueShortName functions returns the ID for a station while the .id returns as slightly different id.

This is the .id output: A=1@O=Vorstadtschule, Ratzeburg@X=10789779@Y=53700506@U=80@L=705453@

And this the .getUniqueShortName: A=1@O=Vorstadtschule, Ratzeburg@X=10789779@Y=53700506@u=104@U=80@L=705453@

alexander-albers commented 1 year ago

getUniqueShortName only returns the id if the location does not have a name associated with it. In your case, it should return Vorstadtschule. Where did you get the Location object from?

victorlobe commented 1 year ago

I am sorry, I just reviewed my code again and came to the conclusion that its not the getUniqueShortName but its the way I get the .id value. I have the following array in my searchVC.
var resultsArray = [SuggestedLocation]() This is how I get the .id value: resultsArray[indexPath.row].location.id And this is the output: A=1@O=Vorstadtschule, Ratzeburg@X=10789779@Y=53700506@u=81@U=80@L=705453@

This is my AbfahrtenVC: var stationDeparturesArray = [StationDepartures]() This is how I get the .id value: stationDeparturesArray[0].stopLocation.id And this is the output: A=1@O=Vorstadtschule, Ratzeburg@X=10789779@Y=53700506@u=92@U=80@L=705453@

The one from AbfahrtenVC has always a different u= number while the one from searchVC is always the same.

alexander-albers commented 1 year ago

I actually don't know what the u number means. I always thought it could be the location's z-location (the height), but it shouldn't change in that case. According to ChatGPT, it could be related to usage, i.e. how frequently the location is used as a transit point in the public transport network. But I honestly don't know. There is another old issue related to this here: https://github.com/public-transport/hafas-client/issues/98

You can always just use the shorter form of the ids by extracting only the last part (705453). TripKit uses long format ids because in cases where they change, this gives the server enough information to resolve the location anyway.

victorlobe commented 1 year ago

I always forget your api is based on hafas, so I should look there first for any issues. Thanks for your help!