Skip to content

Commit 2402b5a

Browse files
author
nilsnolde
committed
add mybinder environment.yml
1 parent 8716388 commit 2402b5a

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

README.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
.. image:: https://badge.fury.io/py/openrouteservice.svg
1414
:target: https://badge.fury.io/py/openrouteservice
1515
:alt: PyPI version
16+
1617
.. image:: https://anaconda.org/nilsnolde/openrouteservice/badges/installer/conda.svg
1718
:target: https://conda.anaconda.org/nilsnolde/openrouteservice
1819
:alt: Conda install
1920

21+
.. image:: https://mybinder.org/badge_logo.svg
22+
:target: https://mybinder.org/v2/gh/GIScience/openrouteservice-py/master?filepath=examples%2Fbasic_example.ipynb
23+
:alt: MyBinder
24+
2025
Quickstart
2126
==================================================
2227

@@ -111,6 +116,8 @@ If you want to run the unit tests, see Requirements_. ``cd`` to the library dire
111116
Usage
112117
---------------------------------
113118

119+
For an interactive Jupyter notebook have a look on `mybinder.org <https://mybinder.org/v2/gh/GIScience/openrouteservice-py/master?filepath=examples%2Fbasic_example.ipynb>`_.
120+
114121
Basic example
115122
^^^^^^^^^^^^^^^^^^^^
116123
.. code:: python
@@ -147,49 +154,48 @@ By default, the directions API returns `encoded polylines <https://developers.go
147154
To decode to a ``dict``, which is a GeoJSON geometry object, simply do
148155

149156
.. code:: python
150-
151157
import openrouteservice
152-
from openrouteservice import convert
158+
from openrouteservice import convert
153159
154-
coords = ((8.34234,48.23424),(8.34423,48.26424))
160+
coords = ((8.34234,48.23424),(8.34423,48.26424))
155161
156-
client = openrouteservice.Client(key='') # Specify your personal API key
162+
client = openrouteservice.Client(key='') # Specify your personal API key
157163
158-
# decode_polyline needs the geometry only
159-
geometry = client.directions(coords)['routes'][0]['geometry']
164+
# decode_polyline needs the geometry only
165+
geometry = client.directions(coords)['routes'][0]['geometry']
160166
161-
decoded = convert.decode_polyline(geometry)
167+
decoded = convert.decode_polyline(geometry)
162168
163-
print decoded
169+
print decoded
164170
165171
Dry run
166172
^^^^^^^^^^^^^^^^^^^^
167173
Although errors in query creation should be handled quite decently, you can do a dry run to print the request and its parameters:
168174

169175
.. code:: python
170176
171-
import openrouteservice
177+
import openrouteservice
172178
173-
coords = ((8.34234,48.23424),(8.34423,48.26424))
179+
coords = ((8.34234,48.23424),(8.34423,48.26424))
174180
175-
client = openrouteservice.Client()
176-
client.directions(coords, dry_run='true')
181+
client = openrouteservice.Client()
182+
client.directions(coords, dry_run='true')
177183
178184
Local ORS instance
179185
^^^^^^^^^^^^^^^^^^^^
180186
If you're hosting your own ORS instance, you can alter the ``base_url`` parameter to fit your own:
181187

182188
.. code:: python
183189
184-
import openrouteservice
190+
import openrouteservice
185191
186-
coords = ((8.34234,48.23424),(8.34423,48.26424))
192+
coords = ((8.34234,48.23424),(8.34423,48.26424))
187193
188-
# key can be omitted for local host
189-
client = openrouteservice.Client(base_url='http://localhost/ors')
194+
# key can be omitted for local host
195+
client = openrouteservice.Client(base_url='http://localhost/ors')
190196
191-
# Only works if you didn't change the ORS endpoints manually
192-
routes = client.directions(coords)
197+
# Only works if you didn't change the ORS endpoints manually
198+
routes = client.directions(coords)
193199
194200
# If you did change the ORS endpoints for some reason
195201
# you'll have to pass url and required parameters explicitly:

environment.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# for https://mybinder.org
2+
# from https://github.com/binder-examples/python-conda_pip/blob/master/environment.yml
3+
name: orspy-examples
4+
channels:
5+
- conda-forge
6+
dependencies:
7+
- python
8+
- folium
9+
- pip:
10+
- openrouteservice

openrouteservice/directions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def directions(client,
164164
of the minified options object. Will be converted to json automatically.
165165
:type options: dict
166166
167+
:param optimize_waypoints: If True, a `Vroom <https://github.com/VROOM-Project/vroom>`_ instance (ORS optimization
168+
endpoint) will optimize the `via` waypoints, i.e. all coordinates between the first and the last. It assumes
169+
the first coordinate to be the start location and the last coordinate to be the end location. Only requests with
170+
a minimum of 4 coordinates can be optimized. Default False.
171+
:type optimize_waypoints: bool
172+
167173
:param validate: Specifies whether parameters should be validated before sending the request. Default True.
168174
:type validate: bool
169175

0 commit comments

Comments
 (0)