Hello dev list,
Probably more than any other part of OTP, the Transit Index API is the
result of the unorchestrated accumulation of patches. I've had various
reports that it "doesn't work right", some of the responses are
constructed in a convoluted manner, and overall the API is not as clean
and coherent as it should be.
As part of my work on profile routing (searching over a wide range of
times rather than a specific time) I needed a uniform notion of stop
patterns (JourneyPatterns) throughout OTP. This need is expressed in
ticket #1320, and work is progressing on branch 1320_patterns. With the
unified pattern concept in place, we obtain the "missing link" in the
GTFS data model and a coherent, nicely structured REST-ish transit index
falls into place. See
https://github.com/opentripplanner/OpenTripPlanner/blob/1320_patterns/otp-core/src/main/java/org/opentripplanner/index/IndexAPI.java
In summary, it looks like this:
/index/agencies
/index/agencies/{id}
/index/stops?lat=y&lon=x&radius=r
/index/stops/{id}
/index/stops/{id}/routes
/index/stops/{id}/patterns
/index/stops/{id}/stoptimes (not implemented yet, will be realtime!)
/index/routes
/index/routes/{id}
/index/routes/{id}/patterns
/index/routes/{id}/stops
/index/routes/{id}/trips
/index/trips (Results are too voluminous. Constrain with x/y/radius?)
/index/trips/{id}
/index/trips/{id}/stops
/index/trips/{id}/stoptimes
/index/patterns
/index/patterns/{id}
/index/patterns/{id}/trips
/index/patterns/{id}/stops
to be continued...
Besides the hierarchical naming of endpoints in accordance with GTFS
terms, another change is lazy-initializing the internal transit index
objects rather than requiring an additional graph builder module and
serializing the index into the Graph file. Building the index is not
particularly time consuming and can be done on demand.
As the patches making up the existing Transit Index were all created to
"scratch an itch", that set of endpoints does effectively tell us what
kind of supplemental information people need to fetch about transit
feeds. I will be extending the new index API to cover those same use
cases. Ideally this new layout will be the one included in OTP's 1.0
API, so if anyone has any suggestions on endpoints to include, or no
longer uses an endpoint they once added to the old transit index, please
let me know.
-Andrew