Skip to content

Commit dc0746b

Browse files
committed
add alternative_routes and skip_segments to directions
1 parent e8eb1e0 commit dc0746b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

openrouteservice/directions.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ def directions(client,
3737
geometry_simplify=None,
3838
instructions=None,
3939
instructions_format=None,
40+
alternative_routes=None,
4041
roundabout_exits=None,
4142
attributes=None,
4243
maneuvers=None,
4344
radiuses=None,
4445
bearings=None,
46+
skip_segments=None,
4547
continue_straight=None,
4648
elevation=None,
4749
extra_info=None,
@@ -103,6 +105,12 @@ def directions(client,
103105
One of ["text", "html"]. Default "text".
104106
:type instructions_format: string
105107
108+
:param alternative_routes: Specifies whether alternative routes are computed,
109+
and parameters for the algorithm determining suitable alternatives. Expects
110+
3 keys: share_factor (float), target_count (int), weight_factor (float).
111+
More on https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/geojson/post.
112+
:type alternative_routes: dict[int|float]
113+
106114
:param roundabout_exits: Provides bearings of the entrance and all passed
107115
roundabout exits. Adds the 'exit_bearings' array to the 'step' object
108116
in the response. Default False.
@@ -137,6 +145,11 @@ def directions(client,
137145
waypoint may be reached.
138146
:type bearings: list or tuple or lists or tuples
139147
148+
:param skip_segments: Specifies the segments that should be skipped in the route calculation.
149+
A segment is the connection between two given coordinates and the counting starts with 1
150+
for the connection between the first and second coordinate.
151+
:type skip_segments: list[int]
152+
140153
:param continue_straight: Forces the route to keep going straight at waypoints
141154
restricting u-turns even if u-turns would be faster. This setting
142155
will work for all profiles except for driving-*. In this case you will
@@ -159,7 +172,7 @@ def directions(client,
159172
:param optimized: If set False, forces to not use Contraction Hierarchies.
160173
:type optimized: bool
161174
162-
:param options: Refer to https://go.openrouteservice.org/documentation for
175+
:param options: Refer to https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/geojson/post for
163176
detailed documentation. Construct your own dict() following the example
164177
of the minified options object. Will be converted to json automatically.
165178
:type options: dict
@@ -222,6 +235,9 @@ def directions(client,
222235
if instructions_format:
223236
params["instructions_format"] = instructions_format
224237

238+
if alternative_routes:
239+
params["alternative_routes"] = alternative_routes
240+
225241
if roundabout_exits is not None:
226242
params["roundabout_exits"] = roundabout_exits
227243

@@ -237,6 +253,9 @@ def directions(client,
237253
if bearings:
238254
params["bearings"] = bearings
239255

256+
if skip_segments:
257+
params["skip_segments"] = skip_segments
258+
240259
if continue_straight is not None:
241260
params["continue_straight"] = continue_straight
242261

test/test_helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@
2727
'suppress_warnings': False,
2828
'instructions': 'false',
2929
'instructions_format': 'html',
30+
'alternative_routes': {
31+
'share_factor': 0.6,
32+
'target_count': 2,
33+
'weight_factor': 1.4
34+
},
3035
'roundabout_exits': 'true',
3136
'attributes': ['avgspeed'],
3237
'radiuses': PARAM_LIST_ONE,
3338
'bearings': PARAM_LIST_TWO,
39+
'skip_segments': [0, 1],
3440
'elevation': 'true',
3541
'extra_info': ['roadaccessrestrictions'],
3642
'optimized': 'false',

0 commit comments

Comments
 (0)