-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question regarding cancelled Trains/Bus #2
Comments
I would have said that „reachable“ would be equal to False in that case but that doesn‘t seem to be the case. I will have a look into that this evening. |
So I looked into it but it doesn't seem like the data you get from the api tells you if a train/bus is cancelled or can't stop at a certain stop point. I guess that if a bus or train is cancelled, it will just disappear from the data or it will not move so the lateness will increase until a certain point where the bus/train won't be shown anyway and the lateness will be deleted. |
Thanks for your answer. |
I don't think that its the field "prognosisType". I believe that this field only tells us if the Bus has already started its tour and the information we have here is prognosed based on its current location so the lateness of the bus would be prognosed based on where it is and how long it takes it to get to that station you fetch the data from. Because when looking at the data from a station, the busses with the "prognosisType" field have all started their tour and all the busses that have not yet started driving don't have the "prognosisType" field. |
I looked at the stop "Steinfort, Gemeng" (id:191104004) and this is the data I get for the bus 832: as you can see it has the "prognosisType" field and it started its tour at 12:05, I called the API at 12:16 or so. |
Correct. |
For the bus 741 there is no "prognosisType" field as it only starts its tour at 12:24 so after I called the API: |
Thats what I would say, every bus that has not started yet is missing the fields "prognosisType", "rtTime" and "rtDate" |
I'm logging all payloads received since this morning (for Trains Bascharage-Lux & Lux-Bascharage) But as i gave up taking trains, in favor of my car, i will have to check regularly, or maybe someone in the public Facebook group will post a message. |
Yeah, altough it would actually be great to have some sort of documentation for the api to see what some fields mean. |
There are some lines that are not working today |
Les courses 655 3406, 4126, 4846, 5566, 3791, 4511 et 5231 seront supprimées. |
Do you have an easy way to take the station id from the nearest_stop api? Searching by coordinates and google maps is annoying ;-) |
{ |
there you have the "key":"cancelled" |
and also "reachable": false |
yes because maybe reachable is also used in case a bus won't drive to a certain stop so its set to false for that stop but the bus is not cancelled |
Just ask the api which stops exist: (replace with your key) https://cdt.hafas.de/opendata/apiserver/location.nearbystops?accessId=&originCoordLong=6.09528&originCoordLat=49.77723&maxNo=5000&r=100000&format=json and in the browser pres F3 to search and enter the name like Leudelangen, Wäschbuer then look for "extid" or "id" somewhere around the higlighted text and enter it in the next api call where you replace with the id you found: (and ) https://cdt.hafas.de/opendata/apiserver/departureBoard?accessId=&lang=fr&format=json&id= |
i usually have one tab where all the stops are and one where i just replace the id when i want to look at another stop |
i take the Application Postman for all API stuff. Great app when using with variables. |
oh yeah i know it, used it for some other projects but i created this project with the mobiliteit.lu api nearly a year ago and back then I was less experienced so everything was done a bit rough as you can maybe see in my code, its a bit of a mess. |
Btw I created a repository fo a documentation and I invite you to add any information thats missing or wrong or you think would be useful for people who don't know the api so that in the end there is at least some documentation available for it. |
Tried to commit some small changes: |
yes you cannot push directly to the repository. |
Well if in your request you filter by arrival/departure you would have to add thr other one too. But if you just do a simple request without telling it if you want departures or arrivals only and without saying that you only want trains going to a certain direction, then you wouldn't need to check for departures and arrivals. |
Altough it is weird that all trains coming from LUX to Bascharage have 0 lateness. I can't really believe that. I will have a look this evening if I have time, otherwise maybe on Sunday. |
Strange, the payload received at 12:00:00 was without rttime (so i'm putting time in mysql) |
Maybe the trains had not started yet at that time. Then there is no rtTime field. |
Yes in the json you sent, the first departure seems to be at 12:04 |
This is the first train in your json and it starts at LUX gare but only at 12:04 so 4 minutes after you retrieved the data. So at that time there is not yet rtTime, it will be available at 12:04 If it had already been driving it would have had the rtTime attribute. |
So maybe your data was based on trains that had not yet departed? And I guess that at the start point (LUX gare) the train cannot be late as it just started. |
I rescheduled my requests to every minute now (instead of */5 ). |
What you could do is have a dictionary in which you put the lines. So after each request you check if the line is alteady in the dict and if yes, check if it already has the rtTime attribute, if yes and the new lateness is bigger than the old one, replace the lateness with the new one, otherwise just skip it. That way you can fetch the data continuously and you can just wait until the rtTime tag is there. Or when you do a request just filter all the lines out that do not have an rtTime tag. |
Possibly my issue is: Therefor i'm only checking departure Ettelbrück with destination Lux. (direction) Without the direction, i would receive departure Ettelbrück, but not arrival Lux. Only departure Lux, but this would change the Train number again. (A train arrived at Lux will (probably) return to Ettelbrück with a different train number) |
yeah but then you have to do the same request as your first one but with the ids inverted to get the lateness for trains from LUX to Ettelbrück. You can't use the same request for both directions. |
Btw, I wrote to the API people on Tuesday to ask if there is an official documentation and not only the xml defintion on the api site. |
Of course I'm always using 2 requests: But as said, you only have the departure when leaving station Ettelbrück, Lux, or Bascharage. Regarding email: |
As for the email, back when I was asking for the API key, I did some research and found it: [email protected] |
And as for the delay, you will have to make a request at the final destination and check the final delay there, or at each stop as the delay changes between stops. |
It would be helpful if there was a feature where you could just enter your line and then get all the information like all stops, how late it is etc., but I asked them last year and they said that it is not possible but they would discuss it internally. But I am sure they didn't implement it as they bought the system from HAFAS and probably never touched it afterwards. The API keys are probably even given by HAFAS, so they ask HAFAS for a key when you ask them for a key. |
Because in the xml definition there are some errors and its so incomplete that you can't tell me someone worked with/on that. |
According to I completely agree with you. They probably payed the company (hafas) to implement this, and never touched after. |
Oooohhh thanks for the link, there is some more documentation for the api even if its not exactly the same. |
And yes if you look at other countries or other enterprises which use this API they usually have way more functions than the 2 we have. And yes that is quite possible that they don't actually want you to have too much information. |
Indeed. |
I will have a look at the js code maybe tomorrow if I have time, otherwise on Sunday and I'll also look at the link you sent before more in detail. Maybe I can extract some knowledge from the js code altough I'm no fan either :) I would actually love to know what tools the Leetstell is working with https://www.mobiliteit.lu/en/about-us/leetstell/ |
I found a folder of data which mobiliteit.lu has to upload to hafas for the api so based on what is in there one can understand a bit more about the api and what the return values mean. |
Its the 'opendata' folder |
Don't understand what you mean with the opendata folder. Sry |
You have probably already looked at the Hafas documentation (the link I sent in the comment)? |
My bad, missed the opendata folder on git here ;-) |
Salut,
i created a similar script for trains. (pushing data to mysql to view in grafana).
By hazard, do you know how to identify a cancelled trains/bus ?
Unfortunately the documentation provided on opendata is poor.
Villmols Merci.
The text was updated successfully, but these errors were encountered: