Skip to content

Instantly share code, notes, and snippets.

@echeipesh
Last active August 29, 2015 14:07
Show Gist options
  • Save echeipesh/0346576e3b52e9719c84 to your computer and use it in GitHub Desktop.
Save echeipesh/0346576e3b52e9719c84 to your computer and use it in GitHub Desktop.

ROOT: /scenarios/:scenarioId

Connects the request to app to approrpriate scenario database

GET/routes

  • 200: [route.json]

GET /routes/:routeId/trips

returns

  • 200: [[tripId]]
  • 404: No such route exists

The list contains all trips in the route, grouped by their unique path. In order to be unique the path has to follow the same stops with the same timings.

GET /route/:routeId/trips/:tripId

returns

  • 200: trip.json
  • 404: No trip exists given trip_id and route_id

Returns combined record of trip, stop times, stops and requencies.

DELETE /route/:routeId/trips/:tripId

returns

  • 200: If trip is deleted
  • 404: No trip exists given trip_id and route_id

This will delete the single trip with specified ID, not the whole path group.

POST /route/:routeId/trips/:tripId

accepts trip.json returns

  • 201: If update is accepted
  • 404: If :tripId and :routeId are not matched in

This request will perform the same grouping operation as a GET on /route/:routeId. All trips in the same group as the trip specified by the :tripId will be deleted and the provided trip will be saved to the database in their place.

service_id

All trips must be saved with a valid service_id. However, this API does not have any concept of service_id and no way to expose this information. Hypothetically if the service client was performing a replacing POST they could send back service_id unmodified it would preserve the trips presence in the service calendar when a TransitSystem is later generated. However, there is no such recourse for inserting POST request.

Therefore, at time of scenario creation a new CalendarRecord with value of 'ALWAYS' will be created with start and end dates of the scenario and enabled on every weekday. All incomming POST requests will be re-written to reference the 'ALWAYS' service.

Stops

When updating or inserting a new Trip record the user is able to specify the location of the stop. These can not be interpreted as location updates of already existing stops because it would potentially change the characteristics of trips other than those currently being replaced by the POST request.

Therefore, at time of insertiong or update the stops will be given a new name with a 'magic' prefix (ex: TEMP-{trip_id}-{sequence_id}). Accordingly on update the service will attempt to delete all such stops associated with the TripRecords being replaced.

{
"id": "AIR",
"shortName": "Airport Line",
"longName": "Airport Line",
"routeType": "Rail",
"agencyId": "SEPTA",
"description": "",
"url": "http://www.septa.org/schedules/rail/index.html",
"color": "91456C",
"textColor": "FFFFFF"
}
{
"trip_id": "AIR_4708_V5",
"route_id": "AIR",
"headsign": "Center City Philadelphia",
"stop_times": [
{
"stop_sequence": 1,
"arrival_time": "05:39:00",
"departure_time": "05:39:00",
"stop": {
"stop_id": "90401",
"name": "Airport Terminal E F",
"lat": 39.8794444,
"long": -75.2397222
}
},
{
"stop_sequence": 2,
"arrival_time": "05:41:00",
"departure_time": "05:41:00",
"stop": {
"stop_id": "90402",
"name": "Airport Terminal C D",
"lat": 39.8780556,
"long": -75.24
}
},
{
"stop_sequence": 3,
"arrival_time": "05:42:00",
"departure_time": "05:42:00",
"stop": {
"stop_id": "90403",
"name": "Airport Terminal B",
"lat": 39.8772222,
"long": -75.2413889
}
},
{
"stop_sequence": 4,
"arrival_time": "05:43:00",
"departure_time": "05:43:00",
"stop": {
"stop_id": "90404",
"name": "Airport Terminal A",
"lat": 39.8761111,
"long": -75.2452778
}
},
{
"stop_sequence": 7,
"arrival_time": "05:47:00",
"departure_time": "05:47:00",
"stop": {
"stop_id": "90405",
"name": "Eastwick",
"lat": 39.8927778,
"long": -75.2438889
}
},
{
"stop_sequence": 13,
"arrival_time": "05:57:00",
"departure_time": "05:57:00",
"stop": {
"stop_id": "90406",
"name": "University City",
"lat": 39.9480556,
"long": -75.1902778
}
},
{
"stop_sequence": 16,
"arrival_time": "06:00:00",
"departure_time": "06:00:00",
"stop": {
"stop_id": "90004",
"name": "30th Street Station",
"lat": 39.9566667,
"long": -75.1816667
}
},
{
"stop_sequence": 20,
"arrival_time": "06:05:00",
"departure_time": "06:05:00",
"stop": {
"stop_id": "90005",
"name": "Suburban Station",
"lat": 39.9538889,
"long": -75.1677778
}
},
{
"stop_sequence": 22,
"arrival_time": "06:10:00",
"departure_time": "06:10:00",
"stop": {
"stop_id": "90006",
"name": "Market East",
"lat": 39.9525,
"long": -75.1580556
}
},
{
"stop_sequence": 25,
"arrival_time": "06:14:00",
"departure_time": "06:14:00",
"stop": {
"stop_id": "90007",
"name": "Temple University",
"lat": 39.9813889,
"long": -75.1494444
}
}
],
"frequencies": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment