|
13 | 13 | .. image:: https://badge.fury.io/py/openrouteservice.svg
|
14 | 14 | :target: https://badge.fury.io/py/openrouteservice
|
15 | 15 | :alt: PyPI version
|
| 16 | + |
16 | 17 | .. image:: https://anaconda.org/nilsnolde/openrouteservice/badges/installer/conda.svg
|
17 | 18 | :target: https://conda.anaconda.org/nilsnolde/openrouteservice
|
18 | 19 | :alt: Conda install
|
19 | 20 |
|
| 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 | + |
20 | 25 | Quickstart
|
21 | 26 | ==================================================
|
22 | 27 |
|
@@ -111,6 +116,8 @@ If you want to run the unit tests, see Requirements_. ``cd`` to the library dire
|
111 | 116 | Usage
|
112 | 117 | ---------------------------------
|
113 | 118 |
|
| 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 | + |
114 | 121 | Basic example
|
115 | 122 | ^^^^^^^^^^^^^^^^^^^^
|
116 | 123 | .. code:: python
|
@@ -147,49 +154,48 @@ By default, the directions API returns `encoded polylines <https://developers.go
|
147 | 154 | To decode to a ``dict``, which is a GeoJSON geometry object, simply do
|
148 | 155 |
|
149 | 156 | .. code:: python
|
150 |
| -
|
151 | 157 | import openrouteservice
|
152 |
| - from openrouteservice import convert |
| 158 | + from openrouteservice import convert |
153 | 159 |
|
154 |
| - coords = ((8.34234,48.23424),(8.34423,48.26424)) |
| 160 | + coords = ((8.34234,48.23424),(8.34423,48.26424)) |
155 | 161 |
|
156 |
| - client = openrouteservice.Client(key='') # Specify your personal API key |
| 162 | + client = openrouteservice.Client(key='') # Specify your personal API key |
157 | 163 |
|
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'] |
160 | 166 |
|
161 |
| - decoded = convert.decode_polyline(geometry) |
| 167 | + decoded = convert.decode_polyline(geometry) |
162 | 168 |
|
163 |
| - print decoded |
| 169 | + print decoded |
164 | 170 |
|
165 | 171 | Dry run
|
166 | 172 | ^^^^^^^^^^^^^^^^^^^^
|
167 | 173 | Although errors in query creation should be handled quite decently, you can do a dry run to print the request and its parameters:
|
168 | 174 |
|
169 | 175 | .. code:: python
|
170 | 176 |
|
171 |
| - import openrouteservice |
| 177 | + import openrouteservice |
172 | 178 |
|
173 |
| - coords = ((8.34234,48.23424),(8.34423,48.26424)) |
| 179 | + coords = ((8.34234,48.23424),(8.34423,48.26424)) |
174 | 180 |
|
175 |
| - client = openrouteservice.Client() |
176 |
| - client.directions(coords, dry_run='true') |
| 181 | + client = openrouteservice.Client() |
| 182 | + client.directions(coords, dry_run='true') |
177 | 183 |
|
178 | 184 | Local ORS instance
|
179 | 185 | ^^^^^^^^^^^^^^^^^^^^
|
180 | 186 | If you're hosting your own ORS instance, you can alter the ``base_url`` parameter to fit your own:
|
181 | 187 |
|
182 | 188 | .. code:: python
|
183 | 189 |
|
184 |
| - import openrouteservice |
| 190 | + import openrouteservice |
185 | 191 |
|
186 |
| - coords = ((8.34234,48.23424),(8.34423,48.26424)) |
| 192 | + coords = ((8.34234,48.23424),(8.34423,48.26424)) |
187 | 193 |
|
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') |
190 | 196 |
|
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) |
193 | 199 |
|
194 | 200 | # If you did change the ORS endpoints for some reason
|
195 | 201 | # you'll have to pass url and required parameters explicitly:
|
|
0 commit comments