Skip to content

Commit

Permalink
fix: preference parameter for isochrones and matrix with Valhalla (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthh committed Oct 26, 2023
1 parent e5eb103 commit 2f0594b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## **Unreleased**

### Fixed

- Fixes taking into account the `preference` parameter when calculating isochrones and matrix with Valhalla ([#120](https://github.com/gis-ops/routingpy/issues/120))

## [v1.3.0](https://pypi.org/project/routingpy/1.3.0/)

### Added
Expand Down
4 changes: 2 additions & 2 deletions routingpy/routers/valhalla.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def get_isochrone_params( # noqa: C901
"contours": contours,
}

if options:
if options or preference:
params["costing_options"] = dict()
profile = profile if profile != "multimodal" else "transit"
params["costing_options"][profile] = dict()
Expand Down Expand Up @@ -619,7 +619,7 @@ def get_matrix_params(
dest_coords = [dest_coords]
params["targets"] = dest_coords

if options:
if options or preference:
params["costing_options"] = dict()
profile = profile if profile != "multimodal" else "transit"
params["costing_options"][profile] = dict()
Expand Down
17 changes: 14 additions & 3 deletions tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@
},
"profile": "auto",
"id": "wacko",
"preference": "fastest",
"preference": "shortest",
"intervals": [600, 1200],
"colors": ["ff0000", "00FF00"],
"polygons": True,
Expand All @@ -1097,6 +1097,7 @@
"profile": "auto",
"units": "mi",
"id": "wacko",
"preference": "shortest",
},
"expansion": {
"expansion_properties": ["distances", "durations", "costs"],
Expand Down Expand Up @@ -1210,7 +1211,12 @@
"locations": [{"lat": PARAM_POINT[1], "lon": PARAM_POINT[0]}],
"costing": "auto",
"costing_options": {
"auto": {"maneuver_penalty": 50, "toll_booth_cost": 50, "country_crossing_penalty": 50}
"auto": {
"maneuver_penalty": 50,
"toll_booth_cost": 50,
"country_crossing_penalty": 50,
"shortest": True,
}
},
"contours": [{"time": 10, "color": "ff0000"}, {"time": 20, "color": "00FF00"}],
"avoid_locations": [{"lon": 8.34234, "lat": 48.23424}],
Expand All @@ -1233,7 +1239,12 @@
],
"costing": "auto",
"costing_options": {
"auto": {"maneuver_penalty": 50, "toll_booth_cost": 50, "country_crossing_penalty": 50}
"auto": {
"maneuver_penalty": 50,
"toll_booth_cost": 50,
"country_crossing_penalty": 50,
"shortest": True,
}
},
"avoid_locations": [{"lon": 8.34234, "lat": 48.23424}],
"id": "wacko",
Expand Down

0 comments on commit 2f0594b

Please sign in to comment.