Ero sivun ”GTFS-RT” versioiden välillä

ITS Factory Developer Wikistä
Rivi 6: Rivi 6:
please see https://developers.google.com/transit/gtfs-realtime/ for more information on GTFS-RT.
please see https://developers.google.com/transit/gtfs-realtime/ for more information on GTFS-RT.


===Vechile Positions===
===Vehicle Positions===
* Vehicle positions feed (JSON) is accessible at http://data.itsfactory.fi/journeys/api/1/gtfs-rt/vehicle-positions/json
* Vehicle positions feed (JSON) is accessible at http://data.itsfactory.fi/journeys/api/1/gtfs-rt/vehicle-positions/json
* Vehicle positions feed (Protobuf) is accessible at http://data.itsfactory.fi/journeys/api/1/gtfs-rt/vehicle-positions
* Vehicle positions feed (Protobuf) is accessible at http://data.itsfactory.fi/journeys/api/1/gtfs-rt/vehicle-positions

Versio 26. helmikuuta 2016 kello 11.10

Concept

GTFS-RT is a lightweight API which allows developers to access public transport data via Google Protobuf protocol (over HTTP). Also JSON over HTTP interface is provided. Following GTFS-RT related feeds are implemented:

  • Vechile Positions
  • Service Alerts

please see https://developers.google.com/transit/gtfs-realtime/ for more information on GTFS-RT.

Vehicle Positions

Please note that Protobuf is binary protocol, so your browser probably will trigger download dialog if you use the protobuf URL. Below is a sample of vehicle positions (JSON) feed:

{
  "header": {
    "gtfs_realtime_version": "1.0",
    "incrementality": "FULL_DATASET",
    "timestamp": 1452109419
  },
  "entity": [
    {
      "id": "0",
      "vehicle": {
        "trip": {
          "start_time": "21:58:00",
          "start_date": "20160106",
          "route_id": "3"
        },
        "position": {
          "latitude": 61.527477,
          "longitude": 23.706625,
          "bearing": 237
        },
        "vehicle": {
          "id": "TKL_41"
        }
      }
    }
	...
  ]
}

The feed provides a JSON "entity" list, where each entity represents a monitored vehicle (bus). For each vehicle, following information is provided:

  • trip information: trip's start date, start time and the route id (which in Tampere data corresponds to the line name displayed in the bus head sign)
  • position information: the vehicle's latitude and longitude as well as the bearing (in degrees, rotated clockwise, 0 equals north)
  • vehicle id, which identifies the actual vehicle (bus) in question

The timestamp field in the header section identifies the time when the response was generated on the server.

Service alerts

Please note that Protobuf is binary protocol, so your browser probably will trigger download dialog if you use the protobuf URL. Below is a sample of service alerts (JSON) feed:

{
  "header": {
    "gtfs_realtime_version": "1.0",
    "incrementality": "FULL_DATASET",
    "timestamp": 1452107062
  },
  "entity": [
    {
      "id": "0",
      "alert": {
        "active_period": [
          {
            "start": 1316466000000,
            "end": 1316552340000
          }
        ],
        "description_text": {
          "translation": [
            {
              "text": "Hämeensilta poikki"
            }
          ]
        }
      }
    }
    ...
  ]
}

The feed provides a JSON "entity" list, where each entity represents a service alert. For each service alert, following information is provided:

  • active_period: the time during which the alert is valid
  • description_text: a description of the alert

The timestamp field in the header section identifies the time when the response was generated on the server. Also, please note that if no alerts are active, the API returns only the headers.