Skip to content

Commit bc475ea

Browse files
koebiMichaelsJP
andauthored
feat: add options parameter to isochrone request (#77)
Co-authored-by: Julian Psotta <[email protected]>
1 parent 604949a commit bc475ea

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

openrouteservice/isochrones.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def isochrones(
3030
interval=None,
3131
units=None,
3232
location_type=None,
33+
options=None,
3334
smoothing=None,
3435
attributes=None,
3536
validate=True,
@@ -75,6 +76,12 @@ def isochrones(
7576
'destination' as goal. Default 'start'.
7677
:type location_type: string
7778
79+
:param options: Additional options for the isochrones request. Refer to
80+
https://openrouteservice.org/dev/#/api-docs/v2/isochrones/{profile}/post
81+
for detailed documentation. Expects a dict(). Will be converted to JSON
82+
automatically.
83+
:type options: dict
84+
7885
:param smoothing: Applies a level of generalisation to the isochrone polygons generated.
7986
Value between 0 and 1, whereas a value closer to 1 will result in a more generalised shape.
8087
:type smoothing: float
@@ -129,6 +136,9 @@ def isochrones(
129136
if attributes: # pragma: no cover
130137
params["attributes"] = attributes
131138

139+
if options: # pragma: no cover
140+
params["options"] = options
141+
132142
return client.request(
133143
"/v2/isochrones/" + profile + "/geojson",
134144
{},

test/test_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"location_type": "destination",
5353
"attributes": ["area", "reachfactor"],
5454
"interval": [PARAM_INT_SMALL],
55+
"options": {"avoid_features": ["highways", "tollways"]},
5556
},
5657
"distance_matrix": {
5758
"locations": PARAM_LINE,

test/test_isochrones.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import responses
1919
import test as _test
2020
from test.test_helper import ENDPOINT_DICT
21+
import pytest
2122

2223

2324
class IsochronesTest(_test.TestCase):
@@ -39,3 +40,8 @@ def test_isochrones(self):
3940

4041
self.assertEqual(1, len(responses.calls))
4142
self.assertEqual(resp, query)
43+
44+
def test_isochrones_must_fail(self):
45+
query = ENDPOINT_DICT["isochrones"]
46+
query.update({"foo": {"bar": "baz"}})
47+
self.assertRaises(TypeError, self.client.isochrones, **query)

0 commit comments

Comments
 (0)