Repository: GIScience/openrouteservice-py

Issue:
Implement smoothing parameter for isochrone endpoint

Discussion:

Patch:
diff --git a/openrouteservice/isochrones.py b/openrouteservice/isochrones.py
index 5e6850c..14a8d73 100644
--- a/openrouteservice/isochrones.py
+++ b/openrouteservice/isochrones.py
@@ -20,16 +20,17 @@ from openrouteservice import convert
 
 
 def isochrones(client, locations,
-                    profile='driving-car',
-                    range_type=None,
-                    intervals=[60],
-                    segments=30,
-                    units=None,
-                    location_type=None,
-                    attributes=None,
-                    #options=None,
-                    intersections=None,
-                    dry_run=None):
+               profile='driving-car',
+               range_type=None,
+               intervals=[60],
+               segments=30,
+               units=None,
+               location_type=None,
+               smoothing=None,
+               attributes=None,
+               # options=None,
+               intersections=None,
+               dry_run=None):
     """ Gets travel distance and time for a matrix of origins and destinations.
 
     :param locations: One pair of lng/lat values.
@@ -65,6 +66,10 @@ def isochrones(client, locations,
         'destination' as goal. Default 'start'.
     :type location_type: string
 
+    :param smoothing: Applies a level of generalisation to the isochrone polygons generated.
+        Value between 0 and 1, whereas a value closer to 1 will result in a more generalised shape.
+    :type smoothing: float
+
     :param attributes: 'area' returns the area of each polygon in its feature
         properties. 'reachfactor' returns a reachability score between 0 and 1.
         'total_pop' returns population statistics from https://ghsl.jrc.ec.europa.eu/about.php.
@@ -120,6 +125,9 @@ def isochrones(client, locations,
     if location_type:
         params["location_type"] = location_type
 
+    if smoothing:
+        params["smoothing"] = convert._format_float(smoothing)
+
     if attributes:
         params["attributes"] = convert._pipe_list(attributes)
 


Test patch:
diff --git a/test/test_client.py b/test/test_client.py
index e45e60d..12aeb1a 100644
--- a/test/test_client.py
+++ b/test/test_client.py
@@ -74,19 +74,13 @@ class ClientTest(_test.TestCase):
         # Assume more queries_per_minute than allowed by API policy and 
         # don't allow retries if API throws 'rate exceeded' error, which 
         # should be caught.
-        queries_per_minute = 60
+        queries_per_minute = 110
         query_range = range(queries_per_minute * 2)
-        
-        for _ in query_range:
-            responses.add(responses.GET,
-                          'https://api.openrouteservice.org/directions',
-                          body='{"status":"OK","results":[]}',
-                          status=200,
-                          content_type='application/json')
             
-        client = openrouteservice.Client(key='58d904a497c67e00015b45fcb6f22c2dd2774733ad9f56f9662de7d3',
+        client = openrouteservice.Client(key='5b3ce3597851110001cf624870cf2f2a58d44c718542b3088221b684',
                                    queries_per_minute=queries_per_minute,
                                    retry_over_query_limit=False)
+        
         with self.assertRaises(openrouteservice.exceptions._OverQueryLimit):
             for _ in query_range:
                 client.directions(self.coords_valid)
diff --git a/test/test_distance_matrix.py b/test/test_distance_matrix.py
index db4c0f9..46d8f86 100644
--- a/test/test_distance_matrix.py
+++ b/test/test_distance_matrix.py
@@ -56,7 +56,7 @@ class DistanceMatrixTest(_test.TestCase):
                                      destinations=destinations)
 
         self.assertEqual(1, len(responses.calls))
-        self.assertURLEqual('https://api.openrouteservice.org/matrix?api_key={}'.format(self.key),
+        self.assertURLEqual('https://api.openrouteservice.org/matrix?api_key={}&profile=driving-car'.format(self.key),
                             responses.calls[0].request.url)
 
     @responses.activate
@@ -93,6 +93,6 @@ class DistanceMatrixTest(_test.TestCase):
         resp = self.client.distance_matrix(**query)
 
         self.assertEqual(1, len(responses.calls))
-        self.assertURLEqual('https://api.openrouteservice.org/matrix?api_key={}'.format(self.key),
+        self.assertURLEqual('https://api.openrouteservice.org/matrix?api_key={}&profile=cycling-regular'.format(self.key),
                             responses.calls[0].request.url)
         self.assertEqual(resp, payload)
\ No newline at end of file
diff --git a/test/test_isochrones.py b/test/test_isochrones.py
index 0f9b574..b83bb21 100644
--- a/test/test_isochrones.py
+++ b/test/test_isochrones.py
@@ -71,6 +71,7 @@ class DistanceMatrixTest(_test.TestCase):
                                            intervals=[1000,2000],
                                            units='m',
                                            location_type='destination',
+                                           smoothing=0.5,
                                            attributes=['area', 'reachfactor']
                                            )
 
@@ -81,5 +82,6 @@ class DistanceMatrixTest(_test.TestCase):
                             '%2C38.106467%7C8.34234%2C48.23424&profile=cycling-regular&'
                             'range_type=distance&range=1000%2C2000&'
                             'units=m&location_type=destination&'
+                            'smoothing=0.5&'
                             'attributes=area|reachfactor&interval=30'.format(self.key),
                             responses.calls[0].request.url)
\ No newline at end of file