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?
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.
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).