Skip to content

Initial implementation of GTFS support - #99

Closed
initdch wants to merge 8 commits into
graphhopper:masterfrom
initdch:feature/GTFS
Closed

initdch wants to merge 8 commits into
graphhopper:masterfrom
initdch:feature/GTFS

Conversation

@initdch

@initdch initdch commented Aug 22, 2013

Copy link
Copy Markdown

It is a simple implementation to support public transport and GTFS import. I tested it with Dijkstra and real world data and it works very well.

The GTFSReader uses GraphStorage to generate a time-expanded graph from a gtfs file. The time is encoded in the graph structure. Therefore, for each station multiple nodes are created which represents the station at a given time. The distance between nodes are the time difference in seconds.

For GTFS import the onebusaway-gtfs library is used. But trips which uses frequencies.txt are not yet supported.

GHPublicTransit is modeled after GraphHopper and can be used as high level interface.
There is also PublicTransitMiniUI which can be used to test and debug GTFS files.

tbuerli added 5 commits August 22, 2013 23:16
Add GTFSReader which generates time-expanded graph from gtfs files. New
encoder and filter which are needed for traversing the graph. Support
for basic routing.
Implement LocationTime2IdIndex with Ntree. Add new flags for exit and
entry edges. Split test in GTFS and index test. Add a DebugUI with
public transit support.
@karussell

Copy link
Copy Markdown
Member

Thanks a lot! Which real world data did you test (link?) and what is a command or class to see it in action?

@initdch

initdch commented Aug 25, 2013

Copy link
Copy Markdown
Author

I worked with data which isn't public available, but I also tested it with http://gtfs.s3.amazonaws.com/gbrail.info_20130817_2226.zip which is from http://www.gtfs-data-exchange.com/agency/virgin-trains/ and work fine.

I use it in my own web application and had not yet the time to implement properly in graphhoppers-web. Therefore, the easiest way to see it in action is to run PublicTransitMiniUI.java. But I added GHPublicTransitTest which shows how it can be used.

I also forgot to mention that at the moment only one service day is supported and tested.

@karussell

Copy link
Copy Markdown
Member

Ok, I got the PublicTransitMiniUI running (with 2gb of RAM). But I fear this approach won't get it into production as even only one provider requires this much memory. I think we need a more compact data represenation and faster algorithm then. But I would somehow avoid to abandon your work as it could be really useful for certain people. Maybe you can separate your modified classes into a separate 'simple-transit' sub project which uses 'core' as dependency?

If you can make this happen would you mind signing a CLA or modifying the header to the graphhopper ones?

@initdch

initdch commented Aug 28, 2013

Copy link
Copy Markdown
Author

Yes it needs lot of RAM... I would also prefer to have it in the main repo so people can use it a as base and build up on it. I thought about a 'transit' branch but a sub project would be the better solution (also regarding maintainability).

If it's okay with you I will split it into a sub project and also change the header so it fits the the graphhopper ones.

@karussell

Copy link
Copy Markdown
Member

Would be nice!

@neogeomat

Copy link
Copy Markdown

Hi initdch,

Is there a wiki on how to implement it in web and android?

@initdch

initdch commented Aug 30, 2013

Copy link
Copy Markdown
Author

Hi amritkarma,

No I haven't documented it yet but it has mainly the same API as Graphhopper.
Here a example how it can be used:

// Setup GHPublicTransit instance
GHPublicTransit instance = new GHPublicTransit().forServer();
instance.setGraphHopperLocation("transit-graph-folder").setGtfsFile("gtfs.zip");
instance.importOrLoad();

// To make a request
int startTime = 22800; // seconds after midnight  06:20
TransitRequest request = new TransitRequest(36.905697, -116.76218, startTime, 36.914944, -116.761472);
request.setVehicle("PUBLIC");
request.setAlgorithm("dijkstra");
GHResponse ph = instance.route(request);

Has that answered your question?

@karussell

Copy link
Copy Markdown
Member

For now closing, will be retried in some months.

@karussell karussell closed this Jul 23, 2014
@dtamm

dtamm commented Jun 8, 2015

Copy link
Copy Markdown

Any intentions on reloading this pull request? I am very interested in working with this kind of code (maybe even contribute to it).

@karussell

Copy link
Copy Markdown
Member

We rely here entirely on the community and this PR is very old. But we highly appreciate all contributions.

@dtamm

dtamm commented Jun 8, 2015

Copy link
Copy Markdown

Then i will try myself with implementing the old files (which were coded for graphhopper-0.1.1) for the latest version of graphhopper and test it with some GTFS Data i got.

@karussell

Copy link
Copy Markdown
Member

Thanks! If you need help, just ask on the mailing list

@dtamm

dtamm commented Jun 8, 2015

Copy link
Copy Markdown

Thanks, will do! Already tried myself on implementing the files this morning for graphhopper-0.4.1 and got some errors (due to missing classes)... will list them all and ask for help on the mailing list (after some tries of myself).

dabiih pushed a commit to dabiih/graphhopper that referenced this pull request Jan 7, 2025
* fix for graphhopper#97

* fallback if locale is unknown but lang is known
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants