GTFS agency id versus feed id

467 views
Skip to first unread message

me...@polito.it

unread,
Feb 22, 2017, 5:07:06 AM2/22/17
to OpenTripPlanner Users
The problem has been raised before, but I haven'r found a definite answer to my specific question..
When  in transit you want to refer to a route or trip or stop, e.g.  in banning one of them, you have to concatenate the agency id with route, trip or stop id.
It is a little confusing the use of the real agency id or the id of the feed containing that agency. Some time OTP accepts both, some time only the feed id.
Well, understood that, my question is: from the real agency id (the only one that I'm able to refer) how to find the feed id?
In the building of the graph in the console I see the association that is casual, depending on the order (alphabetic?) that the feeds are processed, but where this dictionay is available inside the program?
Giuseppe
 

me...@polito.it

unread,
Feb 22, 2017, 6:48:14 AM2/22/17
to OpenTripPlanner Users
I found the answer to my previous question, it may be of interest to someone:

from an object of the class Graph getFeedIds() returns the collections of feedIds (1,2,3..) in the form of String, then with one of those feedId from the same object of the class Graph with getAgency(feedId) you get the id of the agency.
In the class PlannerResource before entering in the GraphPathFinder  the object graph is a public member of router (class Router) directly available.
Giuseppe
 

Andrew Byrd

unread,
Feb 22, 2017, 8:48:11 AM2/22/17
to me...@polito.it, OpenTripPlanner Users
Hello,

On 22 Feb 2017, at 11:07, me...@polito.it wrote:
When  in transit you want to refer to a route or trip or stop, e.g.  in banning one of them, you have to concatenate the agency id with route, trip or stop id. It is a little confusing the use of the real agency id or the id of the feed containing that agency. Some time OTP accepts both, some time only the feed id.

At this point, all GTFS entities referred to in OTP API requests should be scoped (prefixed) with the feed ID, never an agency ID. Anywhere that accepts an agency ID should be considered a bug and fixed. Can you list any specific places that accept/require agency IDs rather than feed IDs?

Well, understood that, my question is: from the real agency id (the only one that I'm able to refer) how to find the feed id?

What you can do is get a list of the available feed IDs, then for each feed ID fetch the available agency IDs. These two pieces of information together allow you to create a truly unique (i.e. “scoped”) agency ID. Assuming your OTP instance is running on localhost:8080, try this:


That will give you a list of all feeds. Then, for each feed you can list the agencies it contains. If the above call told you you had one feed with the ID TriMet, you could then look at:


This shows me three agencies within the TriMet feed with the IDs PSC, TRIMET, and TRAM. I could then refer to these agencies throughout the API using the fully qualified names TriMet:PSC, TriMet:TRIMET, and TriMet:TRAM.

Unfortunately for your case, the API endpoint http://localhost:8080/otp/routers/default/index/agencies, which you might expect to list all agencies across all feeds is not defined. You’ll need to manually call the endpoint for every feed you have loaded, adding the feed ID to the end of the URL for each feed.

In the building of the graph in the console I see the association that is casual, depending on the order (alphabetic?) that the feeds are processed, but where this dictionay is available inside the program?

The generation of feed IDs is just a backup measure. It is much preferred to have a unique feed ID inside the feed. You can edit the feed_info.txt file inside the GTFS .zip file to add a feed_id column (some text editors even allow you to transparently edit text files inside .zip files). The ideal is to ask the producer of your GTFS data to include a feed ID in their feed. Note that the feed ID extension to GTFS has support among people working on the feed spec, but has not yet been officially adopted.

Andrew

me...@polito.it

unread,
Feb 22, 2017, 1:31:34 PM2/22/17
to OpenTripPlanner Users

Andrew,
you was great. You disclosed me one of the best kept secrets of OTP.
Because I'm dealing with a simulation and I'm producing my own GTFS feeds, I solved my problem in this way.
each feed contains only one agency, and I give to the feed the same  id  of the agency.
I noted that if the feed id is given by the concatenation by underscore of two words, the program drops the underscore, CHINA_RAIL becomes CHINARAIL.
It is out of topic, but tell me how to ask through http on the same way routes trips and stops of a transit.
Thank you very much
Giuseppe

   

Andrew Byrd

unread,
Feb 24, 2017, 3:31:19 AM2/24/17
to me...@polito.it, OpenTripPlanner Users
On 22 Feb 2017, at 19:31, me...@polito.it wrote:
you was great. You disclosed me one of the best kept secrets of OTP.

It’s too bad this is a secret - I need to update the documentation then! This should go in a second, more advanced tutorial.

Because I'm dealing with a simulation and I'm producing my own GTFS feeds, I solved my problem in this way.
each feed contains only one agency, and I give to the feed the same  id  of the agency.

That’s the right idea. I know if you have only one agency in your feed this can seem redundant, but the system needs to be made for people combining feeds from arbitrary producers who don’t use unique agency IDs.

I noted that if the feed id is given by the concatenation by underscore of two words, the program drops the underscore, CHINA_RAIL becomes CHINARAIL.


It is out of topic, but tell me how to ask through http on the same way routes trips and stops of a transit.

The API for getting data about the transit service is documented at:
Routes are at /routers/{routerId}/index/routes and trips are at /routers/{routerId}/index/routes/{routeId}/trips.
I think you can’t get all the stops at once, you need to specify a location and radius.

-Andrew


Reply all
Reply to author
Forward
0 new messages