Get the Shape of a Transit Route

User Story

You want to request a transit route from Terminal 1 of Roma Fiumicino International Airport to the Roma Termini central station using public transit. You also want to obtain the shape of the route.

Request

To obtain the shape of a route, specify return=polyline after the required origin and destination parameters in your route request. This will result in a polyline field in each section. This polyline is encoded using Flexible Polyline. This polyline can be easily decoded in many major languages using examples available in the Flexible Polyline repository.

The decoded polyline will be a series of coordinates that you can use for rendering the route (for example using the Maps API for Javascript).

The following request will calculate a transit route with shape information:

GET https://transit.router.hereapi.com/v8/routes
    ?origin=41.79457,12.25473
    &destination=41.90096,12.50243
    &return=polyline
Authorization: Bearer 

Note

For more information on the currently available authentication methods, see Authentication and Authorization Developer Guide.

The optional parameter alternatives represents the number of alternative routes to return aside from the optimal route. By default, alternatives=0, thus only one optimal route is returned if not set.

Response

If the route calculation was successful, the /routes response contains the requested details about the calculated route:

  • one optimal transit route, unless alternatives is greater than zero
  • multiple transit sections with each segment (representing either a pedestrian or a transit segment) containing departure/arrival times, duration and coordinates
  • the transit segment shows the actual stops or stations of departure and arrival. Optionally, all intermediate stops in between can be also requested using the parameter return=intermediate
  • a set of operators that run the services included in the alternatives, including operator code, operator name and links to operator websites, if any
  • the shape of the route in the polyline field encoded using Flexible Polyline
{
  "routes": [
    {
      "id": "R00132f-C0",
      "sections": [
        {
          "id": "R00132f-C0-S0",
          "type": "pedestrian",
          "polyline": "BHkrsl9Y6503pHq9Gr1O9uB9uBhjCjmEAz1BjUp8B_1Kr2T5hKw0JruFxoKk6Dl-D",
          "departure": {
            "time": "2020-04-22T12:17:00+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 41.79457,
                "lng": 12.25473
              }
            }
          },
          "arrival": {
            "time": "2020-04-22T12:23:00+02:00",
            "place": {
              "name": "Fiumicino Aeroporto",
              "type": "station",
              "location": {
                "lat": 41.793466,
                "lng": 12.251997
              },
              "id": "415713377"
            }
          }
        },
        {
          "id": "R00132f-C0-S1",
          "type": "transit",
          "polyline": "BHsq1k9Yow_1pHr9sEk8sEzjGooJ7wFw9J_mE0iJngDg1Hn9Bw_IvC8jJkcg1H08BkkHgj9Bkh3E0rhDkriHoi6Nkl9egmqB4g3D4qJ49vBz9D0isB3-d89qI8gIwr_Bw2oB87_Ds9oB41oEgvUoyoD0xJ4rjE7jEgqjBrhiBs8jF4Swqa8sHghlBkm4BwngF8x-B4m3Ekq7BsixCgw0B8rmC4gTolrB8oE04rBngIgo8E_qHsqwD44CktyBs4KoppB0mgBg7sBgggF8vnD88sBoyY0k3F41kB88Y0mMgzSstXs4tB8jgCsorB40YkhpB7zBos-BnppBwlQrpF08V0rC8zV8kLo-NgsTolIw-a4hGwrkCoGgkDoGo4BA4rBoGo4Bg9D464B4SoyJAo4B4rBgxTo4B45YojEol9CoG4vEnG4vEvMwienGgvFv3CowU_xBolSn4BolS_nG4qsBnrKohhCn8E4zgB_6Oo8oDAo1FAoxCAg9DvMw2UwM4zyCnGw3CoG4mQ4rBw9TwwDw9TofwiFg-KgyaozQgxToqc41Vg9D4rBg7OwuOg-K40Ow3Cw7FwiFg-KghHo8doxCwpd4kCw9sBoqDw_hBgvFwzY4rBwwD4So4BofwiFgvFo9L4kbgmqB4yZw1mBsvHs9K03asuUoyd0oLk0J3D8mK7nCoiHvjCs9ZzkNwhcrtSsyDnzGw5QnrjBw3C_uFwla3uvBgZ3rBomZ3gxB4kCvpE4_Q36fgyB39C4kC_8Dkmaz10Bwlfn75Boh6Cz-zD48Pjha",
          "departure": {
            "time": "2020-04-22T12:23:00+02:00",
            "place": {
              "name": "Fiumicino Aeroporto",
              "type": "station",
              "location": {
                "lat": 41.793466,
                "lng": 12.251997
              },
              "id": "415713377"
            }
          },
          "arrival": {
            "time": "2020-04-22T12:55:00+02:00",
            "place": {
              "name": "Roma Termini",
              "type": "station",
              "location": {
                "lat": 41.90054,
                "lng": 12.502168
              },
              "id": "415712984"
            }
          },
          "transport": {
            "mode": "regionalTrain",
            "name": "LE",
            "category": "Regional Train",
            "color": "#4C8DC1",
            "textColor": "#000000",
            "headsign": "Roma Termini"
          },
          "agency": {
            "id": "aDmtre00",
            "name": "Trenitalia",
            "website": "http://www.trenitalia.com/"
          },
          "attributions": [
            {
              "id": "R00132f-C0-S1-link-0",
              "href": "http://creativecommons.org/licenses/by/3.0/it/",
              "text": "Some line names used in this product or service were edited to align with official transportation maps.",
              "type": "disclaimer"
            }
          ]
        },
        {
          "id": "R00132f-C0-S2",
          "type": "pedestrian",
          "polyline": "BHyvnm_YgztuuHw8GsqH",
          "departure": {
            "time": "2020-04-22T12:55:00+02:00",
            "place": {
              "name": "Roma Termini",
              "type": "station",
              "location": {
                "lat": 41.90054,
                "lng": 12.502168
              },
              "id": "415712984"
            }
          },
          "arrival": {
            "time": "2020-04-22T12:56:00+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 41.90096,
                "lng": 12.50243
              }
            }
          }
        }
      ]
    }
  ]
}

results matching ""

    No results matching ""