Skip to content

Commit

Permalink
Merge pull request #92 from jan-bausch/support_graphhopper_post
Browse files Browse the repository at this point in the history
Fix Graphhopper POST
  • Loading branch information
chrstnbwnkl committed Mar 27, 2023
2 parents efe820a + 3e2b4b1 commit 2b4d5ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
11 changes: 6 additions & 5 deletions routingpy/routers/graphhopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,13 @@ def directions( # noqa: C901

params = {"vehicle": profile}

for coordinate in locations:
coord_lnglat = ([convert.format_float(f) for f in coordinate])
params["points"] = ",".join(coord_lnglat)
if locations is not None:
params["points"] = locations

get_params = {}

if self.key is not None:
params["key"] = self.key
get_params["key"] = self.key

if format is not None:
params["type"] = format
Expand Down Expand Up @@ -358,7 +359,7 @@ def directions( # noqa: C901
params.update(direction_kwargs)

return self.parse_directions_json(
self.client._request("/route", post_params=params, dry_run=dry_run),
self.client._request("/route", get_params=get_params, post_params=params, dry_run=dry_run),
algorithm,
elevation,
points_encoded,
Expand Down
48 changes: 17 additions & 31 deletions tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,11 @@
"graphhopper": {
"directions": {
"vehicle": "car",
"points": "8.780916,49.445776",
"key": "sample_key",
"points": [
[8.688641, 49.420577],
[8.680916, 49.415776],
[8.780916, 49.445776]
],
"type": "json",
"optimize": True,
"instructions": False,
Expand All @@ -1101,37 +1104,20 @@
"points_encoded": True,
"calc_points": False,
"debug": True,
"point_hints": [
"OSM Street",
"Graphhopper Lane",
"Routing Broadway"
],
"snap_preventions": [
"trunk",
"ferry"
],
"curbsides": [
"any",
"right"
],
"details": [
"tolls",
"time"
],
"point_hints": ["OSM Street", "Graphhopper Lane", "Routing Broadway"],
"snap_preventions": ["trunk", "ferry"],
"curbsides": ["any", "right"],
"details": ["tolls", "time"],
"ch.disable": True,
"custom_model": {
"speed": [
{
"if": "true",
"limit_to": "100"
}
],
"priority": [
{
"if": "road_class == MOTORWAY",
"multiply_by": "0"
}
],
"speed": [{
"if": "true",
"limit_to": "100"
}],
"priority": [{
"if": "road_class == MOTORWAY",
"multiply_by": "0"
}],
"distance_influence": 100
},
"heading_penalty": 100,
Expand Down

0 comments on commit 2b4d5ef

Please sign in to comment.