Skip to main content
APIs 4 min read

Creating Eco-Friendly Commutes with HERE Intermodal Routing

HERE Intermodal Routing

As we work towards reducing our carbon footprint and creating more sustainable communities, transportation plays a major role. In this blog post, we will delve into the HERE Intermodal Routing API, which offers advanced routing capabilities across urban areas by integrating public transit with other sustainable transportation options, such as biking, walking, and carpooling.

With the Intermodal Routing API v8, you can choose from 13 different modes of travel. Each route is a concatenation of multiple transport types. You can either let the intermodal router choose the optimal combination of transport types at the time of request with available modes of transport, or you can include only the modes of travel you want and exclude the ones you don't need. You can specify the start and end mode of travel for more granular routing options.

Example

Let’s understand this further by creating a Park and Ride route. We will start from a location in East of Berlin and find an intermodal route to reach the Brandenburg Gate. We prefer starting with a car –

             vehicle[enable]=routeHead & vehicle[modes]=car

We want to end the route with transit or walking –

             transit[enable]=routeTail

We want to exclude rented cars, so we will assign empty value –

             rented[enable]= 

Using these preferences, the request looks like:

Copied
        GET https://intermodal.router.hereapi.com/v8/routes?destination=52.51633411995804,13.377960353160027&origin=52.39198842179989,13.546096392290362&vehicle[modes]=car&vehicle[enable]=routeHead&transit[enable]=routeTail&rented[enable]=&apiKey={YOUR_REST_API_KEY}
  

 

Intermodal Routing API Response

Copied
        {
  "routes": [
    {
      "id": "R0",
      "sections": [
        {
          "id": "R0-S0",
          "type": "vehicle",
          "postActions": [
            {
              "action": "park",
              "duration": 300
            }
          ],
          "departure": . . . // time, name, location, id 
          "arrival":   . . . // time, name, location, id
          "transport": {
            "mode": "car"
          }
        },
        {
          "id": "R0-S1",
          "type": "pedestrian",
          "departure": . . . // time, name, location, id 
          "arrival":   . . . // time, name, location, id
          "transport": {
            "mode": "pedestrian"
          }
        },
        {
          "id": "R0-S2",
          "type": "transit",
          "departure": . . . // time, name, location, id 
          "arrival":   . . . // time, name, location, id
          "transport": {
            "mode": "cityTrain",
            "name": "S9",
            "category": "Suburban Railway",
            "color": "#992746",
            "headsign": "S Spandau Bhf",
            "shortName": "S9"
          },
          "agency": {
            "id": "49030_d643a9d",
            "name": "S-Bahn Berlin GmbH",
            "website": "https://sbahn.berlin"
          }
        },
        {
          "id": "R0-S3",
          "type": "pedestrian",
          . . . 
        }
      ]
    }
  ]
}

  

In this response, we drive to a suitable parking space, walk to the station, take a city train operated by S-Bahn Berlin, and walk to the Brandenburg Gate. For the transit, this not only provides real-time and timetable departures, but also includes service delays and disruption information provided by transit authorities.

In the next blog post on intermodal routing, we will show how to visualize this route with HERE Maps API for JavaScript. We will need flexible polyline geometry in response. That can be added by the request parameter –

        return=polyline

Response

Copied
        {
  "id": "R0-S3",
  "type": "transit",
  "departure": {
    "time": "2023-04-28T16:36:00+02:00",
    "place": {
      "name": "U Mehringdamm",
      "type": "station",
      "location": {
        "lat": 52.493567,
        "lng": 13.38814
      },
      "id": "216004468"
    }
  },
  "arrival": {
    "time": "2023-04-28T16:42:00+02:00",
    "place": {
      "name": "U Unter den Linden",
      "type": "station",
      "location": {
        "lat": 52.516996,
        "lng": 13.388876
      },
      "id": "216005756"
    }
  },
  "polyline": "BHwsxnpf4wur_HsxBsiBgxEw_DkwGo_Fs0M4oKsqHwnFkhG0wC0rC8uBsqCw_DoxHkvJo6KknN49C0_CsqCw0B44C8uBk1L0zDoVgF44H08BokG8GkiSzeokpBn9G8xjC_1JohKn2Ck_Qr5Cw9ErT0xTnsCg8Lj6BkpWj2DsxQn5D40YnjEw2Fze0vFjXg3BvH08G3c4jF7L8kVrtDo0I3pCguS39CguDrO40E_E4gYn5DslCnL",
  "transport": {
    "mode": "subway",
    "name": "U6",
    "category": "Urban Railway Service",
    "color": "#6d61f2",
    "headsign": "Kurt-Schumacher-Platz",
    "shortName": "U6"
  },
  "agency": {
    "id": "49030_24a9adb",
    "name": "Berliner Verkehrsbetriebe",
    "website": "http://www.bvg.de"
  }
}

  

Similarly, it is also possible to get fare information (if present) and turn-by-turn navigation in the response. It is also useful to set departureTime if you are planning the trip for a later time, or set the value of changes parameters, that limits the number of changes allowed in a route. I believe most people would prefer to avoid changing buses or trains frequently.

The request can be easily modified for other use cases such as bike and ride or taxi and ride. The respective parameters of these will be –

           taxi[enable]=routeHead&taxi[modes]=car

           vehicle[modes]=bicycle&vehicle[enable]=routeHead

 

Conclusion

We, as developers, can built sustainable solutions for cities to encourage commuters to use more sustainable transportation options to reduce traffic congestion and air pollution. HERE Intermodal Routing can help by making it easier for commuters to create eco-friendly routes.

Resources: 

HERE Intermodal Routing Developer Guide

HERE Intermodal Routing API Reference

Mohini Todkari

Mohini Todkari

Sr. Developer Evangelist

Have your say

Sign up for our newsletter

Why sign up:

  • Latest offers and discounts
  • Tailored content delivered weekly
  • Exclusive events
  • One click to unsubscribe