"Points" field of a Routing API return is gibberish

I’m trying to make a simple routing API request from Python.

import requests
import json 
data = {"points":[[-122.2903517,47.8531816],[-122.1941137, 47.5832976]],
        "vehicle":"car"
       }
headers = {'Content-type': 'application/json'}
r = requests.post(url = url, data = json.dumps(data), headers=headers)

The resulting route makes sense, however the points of the route are gibberish. Not sure if it’s some strange encoding? I’ll post the first part of the result below. Any idea what’s gone awry?

[{'distance': 37391.125,
   'weight': 2370.386134,
   'time': 1809432,
   'transfers': 0,
   'points_encoded': True,
   'bbox': [-122.291575, 47.583295, -122.179641, 47.86828],
   'points': 'wkacH|}kiVDF_@dBiAu@kAaAeEuDgCuB_GgFsAuAyDqD_O}M{@m@K]eBgBcHeGsAwAYCcKaJiIuHyAgCI_@?Y@ULYTYbEiD~BaBpAu@jCiAzBo@tAk@fAStE]pdAg@th@IdDKfCSzB[lDq@dCq@fDeAdBu@pBcA~BuAlA{@bA{@nEmEdCwCpCwDvBwDjAyBxPc\\nCcFfMkVhAoBjAiB`AkAjBkBxKeKdBwBp@aAt@sAtAwCz@}Bv@mChIq]|@cDv@yB|@uB`AuBlAyB`IwLpEwHhRs^`A_B~@uAhAuAdAkAp@o@xBaBxCeBzAq@tUiIpF_CjWwM~BuArC_CnBwBdAuA`AwA~AwCxBgFlD_Jdc@afA|Rif@lBcEbAqBpCoEzAsBpCiDrAuAvBmBzAmApCkBfBcAjc@{UxAq@bCy@bCk@tg@qG`ASrBo@nAk@vMsIpMyI`@]pEuCjAe@jA]xA[xAMdBCbAB`BNpCp@dExA~GhDvAf@JPzG~AfCd@jGv@tCRrBFpUFfSGlKDdEFpDPfYhChL|@jMnA`MlBlLzBzCZ|BHxB?lCMhCc@xBe@lDiA`SyIvQyIxRsJdYcOnIoDxBu@~DaApAUdBO|DQlB?vBJnRbBxHj@`b@zDbY~ErI|BhYpGrD`@vCLnOBhD`@~DfAxBjAbKvDnCx@fDf@pBRlGH`K@vLErFHzSIzd@BbMKnFAjEDnNK|GAfFIjKk@lISdIBjICbEBrAHjBXtEdAlGbBzGrAlKfApG`@hKZtUAdIEl[\\|UQ|FIrFSvAKtDk@jDw@`DaAtCyAtD_CzFqDnFyDdCyAlC~HLt@Xz@`@r@XrAX`BPfC?lCBfB?`EVTvF?d@B|@PTJf@`@tIhLt@z@^Zn@`@fMdEtBp@r@NNAnA_AbUuN`A]j@MpO}C~@[n@_@DLHFpNDBxOV?',
   'instructions': [{'distance': 46.488,
     'heading': 223.38,
     'sign': 0,
     'interval': [0, 2],
     'text': 'Continue',
     'time': 16734,
     'street_name': ''}

The points are encoded: Documentation - GraphHopper Directions API

See the JS code to decode them or set points_encoded=false if you can accept a larger response.

Ah excellent, that did the trick. Thanks!

While you’re here… do you know why “street_name” is so often empty? My use case is that I want to see whether routes/alternate routes use a specific highway, but that highway never shows up as a street name. My current plan is to match the coordinates to the shape of the highway, but it’d be nice to cut out this extra step.

Do you have a link? It might be that the information is not in the name tag but the ref tag, and 2 years ago we stopped merging both properties and will hopefully find some time to store this separately. See the issue and effort here: Split street_name into street_name and street_ref · Issue #1322 · graphhopper/graphhopper · GitHub

Ah, got it. I don’t have a link, but if you run the same request as I posted above you’ll see that most of the street names are blank. It’s okay though – fortunately I don’t have that many routes that I’d need to map-match to the highway.

Yes, unfortunately this is the issue I mentioned (Way: ‪WA 525‬ (‪368554578‬) | OpenStreetMap) and we need to store the ref information so that it can be retrieved e.g. using the path details. (btw using path details is also possible for street_name without the minor overhead of the instructions if you do not need them)

If you just need a temporary way to match two route segment you could use the edge_id path detail: Driving Directions - GraphHopper Maps note, that edge_id can change at any time even between two requests as it changes after 1-3 days (our update cycle).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.