0

Iam testing routing API(https://developer.here.com/documentation/routing-api/api-reference-swagger.html) and all seems to be working as expect except polyline.

Here I share my service invocation curl --location --request GET 'https://router.hereapi.com/v8/routes?transportMode=car&origin=3.4844257,-76.5256287&destination=3.478483,-76.517984&routingMode=fast&return=elevation,polyline,actions,instructions,summary&apiKey=1234'

As part of response we have the next field:

"polyline": "B2Fkt10Grm4-xE8yTU4mBnBnG8pBAzP0tBAjD4IA_E8LAvMokBT3IkXTzF8QTnG8QTvMsiBTrJjDA3_BjXoB_sB_OAriB3NAzKjDAnLsTAnLkhBnBzKsdA_J8fTnLkcT3DwHAvC8GArJoQAnL8QA7LsTA7V0jBT_M8UA",

As you know the polyline field is encoded. According to documentation I proceeded to decoded it with a library/code suggested from:

https://github.com/heremaps/flexible-polyline/tree/master/java

The result of decode the field in not correct. The list of points (Lat,Long,Elevation) returned are not matched with the correct location. In the example, the coordinates are from Colombia and the results, after decodification, returns a list of points in a middle of the Atlanthic ocean.

Further, in order to discard library issues I was checking decoding de polyline with other decoder as:

And the result is the same.

So, seems to be the problems is HereAPI side(API routing v8)

Any ideas? Maybe I am invoking the API in the incorrect way

2 Answers2

0

I would suggest removing your API key from the get request you posted in your question.

Using the polyline that you provided gets decoded into the following, which is in Columbia. As a result, I think you need to check the decoder you are using and/or what is being fed into it.

Index Lat Lon Elev
0 3.48437 -76.52567 1003
1 3.48438 -76.52505 1001
2 3.48428 -76.52438 1001
3 3.48403 -76.52365 1001
4 3.48398 -76.52351 1001
5 3.4839 -76.52332 1001
6 3.4837 -76.52274 1000
7 3.48356 -76.52237 999
8 3.48347 -76.5221 998
9 3.48337 -76.52183 997
10 3.48317 -76.52128 996
11 3.48302 -76.52133 996
12 3.482 -76.5217 998
13 3.48128 -76.52194 998
14 3.48073 -76.52216 998
15 3.48056 -76.52221 998
16 3.48038 -76.5219 998
17 3.4802 -76.52137 996
18 3.48003 -76.5209 996
19 3.47987 -76.52039 995
20 3.47969 -76.51994 994
21 3.47963 -76.51982 994
22 3.47959 -76.51971 994
23 3.47944 -76.51945 994
24 3.47926 -76.51918 994
25 3.47907 -76.51887 994
26 3.47872 -76.5183 993
27 3.478512 -76.517966 993
realdrive
  • 36
  • 4
0

The decoder on https://github.com/heremaps/flexible-polyline/tree/master/java works correct, see please code with your encoded string:

private void testSOLatLngDecoding() {
        List<LatLngZ> computed = decode("B2Fkt10Grm4-xE8yTU4mBnBnG8pBAzP0tBAjD4IA_E8LAvMokBT3IkXTzF8QTnG8QTvMsiBTrJjDA3_BjXoB_sB_OAriB3NAzKjDAnLsTAnLkhBnBzKsdA_J8fTnLkcT3DwHAvC8GArJoQAnL8QA7LsTA7V0jBT_M8UA");
        List<String> seqCrds = new ArrayList<>();
        for (int i = 0; i < computed.size(); ++i) {
            LatLngZ c = computed.get(i);
            List<String> crds = new ArrayList<>();
            crds.add(String.valueOf(c.lat));
            crds.add(String.valueOf(c.lng));
            crds.add(String.valueOf(c.z));
            seqCrds.add(String.join(",", crds));
            //assertEquals(computed.get(i), pairs.get(i));
        }
        System.out.println(String.join(",", seqCrds));
    }

We have a javascript tool "Encode/Decode to/from Flexible polyline" on https://demo.support.here.com/examples/v3.1/enc_dec_flexible_polyline

see please result:

enter image description here

Please double check code on your side.