Skip to content

Commit 6b36880

Browse files
author
nilsnolde
committed
add optimization to basic examples
1 parent 4f74ec8 commit 6b36880

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Basic example
122122
client = openrouteservice.Client(key='') # Specify your personal API key
123123
routes = client.directions(coords)
124124
125-
print routes
125+
print(routes)
126126
127127
For convenience, all request performing module methods are wrapped inside the ``client`` class. This has the
128128
disadvantage, that your IDE can't auto-show all positional and optional arguments for the
@@ -132,14 +132,29 @@ The slightly more verbose alternative, preserving your IDE's smart functions, is
132132

133133
.. code:: python
134134
135-
import openrouteservice
136-
from openrouteservice.directions import directions
135+
import openrouteservice
136+
from openrouteservice.directions import directions
137137
138138
coords = ((8.34234,48.23424),(8.34423,48.26424))
139139
140140
client = openrouteservice.Client(key='') # Specify your personal API key
141141
routes = directions(client, coords) # Now it shows you all arguments for .directions
142142
143+
Optimize route
144+
^^^^^^^^^^^^^^^^^^^^^^^^^^
145+
If you want to optimize the order of multiple waypoints in a simple `Traveling Salesman Problem <https://en.wikipedia.org/wiki/Travelling_salesman_problem>`_,
146+
you can pass a ``optimize_waypoints`` parameter:
147+
148+
.. code:: python
149+
150+
import openrouteservice
151+
152+
coords = ((8.34234,48.23424),(8.34423,48.26424), (8.34523,48.24424), (8.41423,48.21424))
153+
154+
client = openrouteservice.Client(key='') # Specify your personal API key
155+
routes = client.directions(coords, profile='cycling-regular', optimize_waypoints=True)
156+
157+
print(routes)
143158
144159
Decode Polyline
145160
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -160,7 +175,7 @@ To decode to a ``dict``, which is a GeoJSON geometry object, simply do
160175
161176
decoded = convert.decode_polyline(geometry)
162177
163-
print decoded
178+
print(decoded)
164179
165180
Dry run
166181
^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)