Migration Journey from HERE Isoline Routing v7 to v8 in our EV Range Isoline Application
Happy New Year! As we ushered in 2024, we embarked on an exciting journey of migration, upgrading some of our Location Data Storytelling assets. Specifically, we transitioned from the legacy HERE Location Services to the latest HERE Location Services. In this blog post, I'm thrilled to share the personal narrative of how we transformed the EV Range Isoline application, originally utilizing HERE Isoline Routing v7, into the latest and more advanced HERE Isoline Routing v8.
For a complete Isoline Routing migration guide, please refer to this documentation guide.
Legacy Isoline Routing v7
Let's take a stroll down memory lane to understand the roots of our application. The EV Range Isoline asset played a crucial role in allowing users to explore the potential travel distances from any point for various electric vehicle types, including Compact, midsize, sports car, and SUV/pickup. This was made possible through the implementation of HERE Isoline Routing, a system that considered the actual distance traveled on known roads rather than a simple radius. The initial version of our application was crafted using the HERE Maps API for Javascript, leveraging the legacy HERE Isoline Routing V7, as reflected in the code snippet below:
const router = platform.getRoutingService()
const params = {
mode: `shortest;car`,
start: `geo!${position[0]},${position[1]}`,
range: range * 1000,
rangetype: "distance",
}
return new Promise((resolve, reject) => {
router.calculateIsoline(params, success(resolve), failure(reject))
})
const success = (resolve) => (res) => {
var isoline = res.response.isoline[0].component[0].shape.map((z) =>
z.split(",").map((x) => +x)
)
...
resolve({isoline, bbox});
}
const failure = (reject) => (err) => reject(err)
Latest Isoline Routing v8
Fast forward to the present, our migration to HERE Isoline Routing v8 involved updates in three key areas of the codebase:
- The service endpoint
Easily accomplished by specifying the version number when initializing the H.service.RoutingService8, as illustrated below:
// Latest Isoline Routing v8 - Service endpoint update
const router = platform.getRoutingService(null, 8);
- The request parameters
Several changes occurred in the request parameters from v7 to v8, such as the replacement of the start parameter with origin. For a comprehensive guide on the updated parameters, please refer to the API Reference.
// Latest Isoline Routing v8 - Request parameters
const params = {
'transportMode': 'car',
'routingMode':'short',
'origin': position[0] + ',' + position[1],
'range[values]': range * 1000,
'range[type]': 'distance',
};
- The response
In Isoline Routing v8, geocoordinates in the returned isolines are encoded as Flexible Polylines. To handle this, we used the decoder using H.geo.LineString.fromFlexiblePolyline()
// Latest Isoline Routing v8 - Response handling
const success = (resolve) => (result) => {
// Flexible Polylines decoder
const isoline = H.geo.LineString.fromFlexiblePolyline(result.isolines[0].polygons[0].outer);
const bbox = isoline.getBoundingBox();
resolve({ isoline, bbox });
};
EV Range Isoline Application
The culmination of our efforts is showcased in the latest version of the EV Range Isoline Application. Check out the revamped application, now powered by HERE Isoline Routing v8:
Resources
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