'How to decode polyline from HERE Routing API 8?
In ABAP, we need to fetch detailed route from HERE API https://router.hereapi.com/v8/routes?transportMode=car&origin=21.11336,39.21516&destination=21.52779,39.25381&return=polyline&app_id={APPID}&apiKey={APIKEY}
.
This API returns polyline which we need to decode to get GeoCordinates. We tried to decode using the algorithm given at https://github.com/heremaps/flexible-polyline, but it does not provide correct coordinates.
Can I get exact algorithm that HERE is using to encode polyline, so that to decode polyline in ABAP?
Solution 1:[1]
I know this is a bit old but found this answer on HERE help pages. An example of an encoded polyline is:
BGo9llkDg_rzZkF0G8LoQ4NoQgP8QoLgKgyB0tB4XoVoLsJ0K4IwWoQsOsJ8LwHoLoGkS0KkN8GsJ0F8GgF4D4DsE0FwHoLUgK8BkIkDkI7B0eTgUT0KjDkhBvCoa7BsT3DwgBvCoVnGg8BjNg4D3D8zB_EsxBjDwgBzFs2BrEgyBvC8V7G8uB7G4wBnBwMkI8BoBnLgP_hEgKz1CsE_nBsJrjD4E1tB
I found the following on developer.here.com page:
"This polyline is encoded using a flexible polyline. You can encode this polyline easily in many major languages using examples available in the flexible polyline repository."
GitHub repo: https://github.com/heremaps/flexible-polyline
"HERE Maps API for Javascript provides wrappers which can do the decoding for you."
I am not using HERE on the client side (even thought it is awesome), I am using some legacy mapping plugin.
I was able to use this code in this file to figure out how to decode the polyline.
https://github.com/heremaps/flexible-polyline/blob/master/javascript/index.js
My code takes the encoded polyline, sends it through the decode method and I end up with a cute object that contains the polyline array as expected.
Below is a screenshot of the console.log of the decoded object pasted above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |