Skip to content

Commit 15eed0e

Browse files
nilsnoldenilsnolde
authored andcommitted
[bugfix] #30 boundary.country Pelias & change isochrone defaults (#31)
* [bugfix] #29 boundary.country Pelias + change isochrone default params
1 parent a93c3ac commit 15eed0e

File tree

8 files changed

+27
-31
lines changed

8 files changed

+27
-31
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### v1.1.7
2+
3+
- fix boundary.country for pelias_search (#30)
4+
- change isochrone defaults (#31)
5+
16
### v1.1.6
27

38
- fix boolean parameters (#28)

openrouteservice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# the License.
1818
#
1919

20-
__version__ = "1.1.6"
20+
__version__ = "1.1.7"
2121

2222
# Make sure QGIS plugin can import openrouteservice-py
2323

openrouteservice/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Client(object):
4747

4848
def __init__(self, key=None,
4949
base_url=_DEFAULT_BASE_URL,
50-
timeout=None,
50+
timeout=60,
5151
retry_timeout=60,
5252
requests_kwargs=None,
5353
queries_per_minute=40,

openrouteservice/geocode.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def pelias_search(client, text,
7575
for details.
7676
:type layers: list of strings
7777
78-
:param country: Constrain query by country. Accepts alpha-2 or alpha-3
79-
digit ISO-3166 country codes.
80-
:type country: list of strings
78+
:param country: Constrain query by country. Accepts a alpha-2 or alpha-3
79+
digit ISO-3166 country code.
80+
:type country: str
8181
8282
:param size: The amount of results returned. Default 10.
8383
:type size: integer
@@ -125,7 +125,7 @@ def pelias_search(client, text,
125125
params['layers'] = convert._comma_list(layers)
126126

127127
if country:
128-
params['country'] = country
128+
params['boundary.country'] = country
129129

130130
if size:
131131
params['size'] = size
@@ -170,9 +170,9 @@ def pelias_autocomplete(client, text,
170170
:param rect_max_y: Max latitude by which to constrain request geographically.
171171
:type rect_max_y: float
172172
173-
:param country: Constrain query by country. Accepts alpha-2 or alpha-3
173+
:param country: Constrain query by country. Accepts a alpha-2 or alpha-3
174174
digit ISO-3166 country codes.
175-
:type country: list of strings
175+
:type country: str
176176
177177
:param sources: The originating source of the data. One or more of
178178
['osm', 'oa', 'wof', 'gn']. Currently only 'osm', 'wof' and 'gn' are
@@ -345,9 +345,9 @@ def pelias_reverse(client, point,
345345
for details.
346346
:type layers: list of strings
347347
348-
:param country: Constrain query by country. Accepts alpha-2 or alpha-3
348+
:param country: Constrain query by country. Accepts a alpha-2 or alpha-3
349349
digit ISO-3166 country codes.
350-
:type country: list of strings
350+
:type country: str
351351
352352
:param size: The amount of results returned. Default 10.
353353
:type size: integer
@@ -377,7 +377,7 @@ def pelias_reverse(client, point,
377377
params['layers'] = convert._comma_list(layers)
378378

379379
if country:
380-
params['country'] = country
380+
params['boundary.country'] = country
381381

382382
if size:
383383
params['size'] = size

openrouteservice/isochrones.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
def isochrones(client, locations,
2424
profile='driving-car',
25-
range_type=None,
26-
intervals=[60],
27-
segments=30,
25+
range_type='time',
26+
intervals=None,
27+
segments=None,
2828
units=None,
2929
location_type=None,
3030
smoothing=None,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def readme():
2020
return f.read()
2121

2222
setup(name='openrouteservice',
23-
version='1.1.6',
23+
version='1.1.7',
2424
description='Python client for requests to openrouteservice API services',
2525
long_description=readme(),
2626
classifiers=[

test/test_geocode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_full_search(self):
8383

8484
self.assertEqual(1, len(responses.calls))
8585
self.assertURLEqual(
86-
'https://api.openrouteservice.org/geocode/search?boundary.circle.lat=49.418431&boundary.circle.lon=8.675786&boundary.circle.radius=50&boundary.rect.max_lon=8.79405&boundary.rect.max_lat=49.459693&boundary.rect.min_lat=49.351764&boundary.rect.min_lon=8.573179&country=de&focus.point.lat=49.418431&focus.point.lon=8.675786&layers=locality%2Ccounty%2Cregion&size=5&sources=osm%2Cwof%2Cgn&text=Heidelberg&api_key=sample_key'.format(
86+
'https://api.openrouteservice.org/geocode/search?boundary.circle.lat=49.418431&boundary.circle.lon=8.675786&boundary.circle.radius=50&boundary.rect.max_lon=8.79405&boundary.rect.max_lat=49.459693&boundary.rect.min_lat=49.351764&boundary.rect.min_lon=8.573179&boundary.country=de&focus.point.lat=49.418431&focus.point.lon=8.675786&layers=locality%2Ccounty%2Cregion&size=5&sources=osm%2Cwof%2Cgn&text=Heidelberg&api_key=sample_key'.format(
8787
self.key),
8888
responses.calls[0].request.url)
8989

@@ -131,6 +131,6 @@ def test_full_reverse(self):
131131

132132
self.assertEqual(1, len(responses.calls))
133133
self.assertURLEqual(
134-
'https://api.openrouteservice.org/geocode/reverse?boundary.circle.radius=50&country=de&layers=locality%2Ccounty%2Cregion&point.lat=49.418431&point.lon=8.675786&size=5&sources=osm%2Cwof%2Cgn&api_key=sample_key'.format(
134+
'https://api.openrouteservice.org/geocode/reverse?boundary.circle.radius=50&boundary.country=de&layers=locality%2Ccounty%2Cregion&point.lat=49.418431&point.lon=8.675786&size=5&sources=osm%2Cwof%2Cgn&api_key=sample_key'.format(
135135
self.key),
136136
responses.calls[0].request.url)

test/test_isochrones.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import openrouteservice
2323

2424

25-
class DistanceMatrixTest(_test.TestCase):
25+
class IsochronesTest(_test.TestCase):
2626

2727
def setUp(self):
2828
self.key = 'sample_key'
@@ -41,12 +41,13 @@ def test_basic_params(self):
4141
status=200,
4242
content_type='application/json')
4343

44-
isochrone = self.client.isochrones(self.coords_valid[0])
44+
isochrone = self.client.isochrones(self.coords_valid[0],
45+
intervals=[60])
4546

4647
self.assertEqual(1, len(responses.calls))
4748
self.assertURLEqual('https://api.openrouteservice.org/isochrones?api_key={}&'
4849
'locations=9.970093%2C48.477473&'
49-
'profile=driving-car&range=60&interval=30'.format(self.key),
50+
'profile=driving-car&range=60&range_type=time'.format(self.key),
5051
responses.calls[0].request.url)
5152

5253
@responses.activate
@@ -67,16 +68,6 @@ def test_all_params(self):
6768
attributes=['area', 'reachfactor']
6869
)
6970

70-
iso_parameter = {'locations': [[9.970093, 48.477473], [9.207916, 49.153868]],
71-
'profile': 'cycling-regular',
72-
'range_type': 'distance',
73-
'range': [1000, 2000],
74-
'units': 'm',
75-
'location_type': 'destination',
76-
'attributes': ['area', 'reachfactor'],
77-
'interval': [30]
78-
}
79-
8071
self.assertEqual(1, len(responses.calls))
8172
self.assertURLEqual('https://api.openrouteservice.org/isochrones?api_key={}&'
8273
'locations=9.970093%2C48.477473%7C9.207916'
@@ -85,5 +76,5 @@ def test_all_params(self):
8576
'range_type=distance&range=1000%2C2000&'
8677
'units=m&location_type=destination&'
8778
'smoothing=0.5&'
88-
'attributes=area|reachfactor&interval=30'.format(self.key),
79+
'attributes=area|reachfactor'.format(self.key),
8980
responses.calls[0].request.url)

0 commit comments

Comments
 (0)