JoshuaJLi / cmpt362-wtb

4 stars 0 forks source link

Integrate GTFS Static #1

Open bryanjhdang opened 2 weeks ago

bryanjhdang commented 2 weeks ago

Use the TransLink Open API and to grab both GTFS Realtime and GTFS Static Data. Developers should be able to easily grab bus schedules according to a specific stop number.

GTFS ("General Transit Feed Specification") is a common format for public transportation schedules.

bryanjhdang commented 2 weeks ago

Splitting this into 2 tasks as the scope is pretty big - one for static data and one for real-time.

toastjpg commented 2 weeks ago

Reference for GTFS file types: https://gtfs.org/documentation/schedule/reference/

Static data downloaded from translink needs to cleaned + transformed to match our data model.

Doing it here: https://github.com/toastjpg/gtfs-static-cleaning/tree/main

toastjpg commented 2 weeks ago

Proposed object structure for a merged + cleaned data file:


{
  "id": 9952,
  "code": 59316,
  "name": "Production Station @ Bay 3",
  "location": {
    "lat": 49.254032,
    "lon": -122.918229
  },
  "nextBusses": [
    {
      "routeId": 6646,
      "tripId": 14015208,
      "arrivalTime": "20:21:00"
    },
    {
      "routeId": 6654,
      "tripId": 14018619,
      "arrivalTime": "21:00:00"
    },
    {
     ...
    }
  ],
  "routes": [
    {
      "id": 6654,
      "shortName": "136",
      "longName": "Lougheed Station/Brentwood Station",
      "trip_headsign": "136 Brentwood Station", 
      "tripIds": [14018605, 14018606, ...]
    },
    {
      "id": 6646,
      "shortName": "110",
      "longName": "Lougheed Station/Metrotown Station",
      "trip_headsign": "110 Lougheed Station",
      "tripIds": [14015208, 14015209, ...]
    }
  ]
}
toastjpg commented 2 weeks ago

Blocked/no progress until there's a cleaner method to associate date/time to an bus arrival time. Bus schedules are not regular and differ on holidays. Some bus routes are also infrequent/special and run on certain days only.

toastjpg commented 7 hours ago

Dropping the arrival time and trip information from the object. Relying on real time data for that information.

Static data will hold information for bus stops and what bus routes go to each stop.

stops.json

{
    "stop_id":1,
    "stop_code":50001,
    "stop_name":"Westbound Davie St @ Bidwell St",
    "stop_lat":49.286458,
    "stop_lon":-123.140424,
    "route_id":[
      30055
    ]
}

routes.json

{
  {
    "route_id":10232,
    "route_short_name":"256",
    "route_long_name":"Whitby Estate\/Park Royal\/Spuraway"
  }
}