Closed hypervtechnics closed 4 years ago
On https://developers.google.com/transit/gtfs/reference/#stopstxt you have the type Station. A station groups more than one stop (e.g. a huge railway station) into one and keeping the platforms (which are separate stops) as its children.
All stops would then be:
stops.Where(s => s.LocationType == LocationType.Station) + stops.Where(s => s.LocationType == LocationType.Stop && s.ParentStation == null)
So you would want to view the departures from every stop under a station in the one call?
Yes, exactly.
Ok - will look into this over the next couple of days :)
@hypervtechnics would you want to be able to pass in the ID of the station and then it loops through all the child stops of the station, putting all the departures together in order of departure? Also - do you have an example feed that shows parent stations etc?
Yeah, that's it basically. I have one - but not valid anymore due to calendar.txt... 😜
I will think about what would be the best way to offer this functionality. I can't decide whether this feature should be implicitly or explicitly called by the user. I think it would be the best to first check if the stop id is a parent stop aka station.
I started a little last night on adding the parent station and location type fields to the stop class to expose if there is a parent or not. Was thinking of a new endpoint of GetServicesByParentStation which would pass in the ID of the station and go through the children for the departures.
Maybe we can utilize GTFS as a dependency and use their model for this library. Those use the appropiate data types (#18) and would provide us with all needed information?
That’s probably a good idea - probably worth while making that change first and then moving forward with the parent stations as will be easier when data types are correct - I will see if I can make a start on it later tonight.
I will later look into this too. Also will look into optimizing the LINQ. As its taking too long for my understanding. Also there are some errors/results for me which seem incorrect/incomplete.
@hypervtechnics I have almost completed the conversion to the GTFS classes but i'm struggling with the method below:
ExceptionType = dataReader.GetString(1),
ExceptionType is either ExceptionType.Added or ExceptionType.Removed - how can I do that conversion?
I have created a string extension to make the conversion from the string that comes from the database. I should have this finished over the next few days and will then do some testing and push my changes - in the meantime if you want to look at the LINQ to see if improvements can be made that would be great!
ExceptionType is given as an enum in the GTFS library Enum.GetName
might help you there.
I think to gain a lot performance the initial loading of the GTFS feed into memory would be the best option. Then we could prepare (e.g. sort) the data and perform operations much quicker using e.g. binarysearch.
Initial testing is going well for the GTFS storage using the GTFS classes - probably going to take this opportunity over the weekend to use the same classes in the database project as that probably makes sense too at this stage.
I have added a new endpoint GetStopsByParentStationAsync - you can pass in a parent Id and get all the stops under that station. From there you can use GetServicesByStopAsync passing in each stop id returned from GetStopsByParentStationAsync to get all the departures across the station and order it how the user needs too.
I'm not sure if the library needs a specific endpoint to get all the departures for a station or let the user do that themselves using the existing endpoint and the new one to get all the stops under a station.
Seems like a good approach for now, but I will look further into what might be useful.
Close this then?
And: What do you think of the idea of preloading everything?
And: What do you think of the idea of preloading everything?
I think at the moment agencies, calendarDates and stops are being preloaded - is the only other thing left to preload stopTimes and if so wont that take a long time to preload that table as they can be massive in some feeds?
Depends also on the hardware of the client. My local feed takes about 1 GB RAM.
It wouldn't be too bad using GTFS storage but if using the SQL Server Storage or anything else in future that pulls from a remote source it could take a long time to download all the stopTimes table.
I will close this issue for the parent station - if we need too we can re-open the preload issue for further discussion around preloading.
Just a FYI - I decided to make a new endpoint GetServicesByParentStationAsync - if you pass in the parent station ID it will show all departures from all the stops under the station ordered by departure time. It's in the dev branch and will come into the next release.
Hey. Sorry for being inactive. Will be helping here again if I get to have some time free.
@hypervtechnics can you give a brief explanation / example of this as i'm not sure I understand what asking for.