Repository: mapbox/mapbox-sdk-py
Pull request #83 (2015-12-04 10:14:12)

use compact separators to keep json overlay small


Patch:
diff --git a/docs/geocoding.md b/docs/geocoding.md
index 4e48f9b..05d5a7d 100644
--- a/docs/geocoding.md
+++ b/docs/geocoding.md
@@ -160,7 +160,7 @@ Places at a longitude, latitude point may be found using `Geocoder.reverse()`.
 ...     print('{place_name}: {id}'.format(**f))
 Atlas Installation, 124 E 13th St, New York, New York 10003, United States: poi.2701346205
 Gramercy-Flatiron, New York, 10003, New York, United States: neighborhood.21161
-New York, New York, United States: place.37501
+New York, New York, United States: place.34530
 10003, New York, United States: postcode.2254639497
 New York, United States: region.628083222
 United States: country.4150104525
diff --git a/mapbox/services/static.py b/mapbox/services/static.py
index 8e9febe..211f4dc 100644
--- a/mapbox/services/static.py
+++ b/mapbox/services/static.py
@@ -30,7 +30,8 @@ class Static(Service):
 
         if features:
             values['overlay'] = json.dumps({'type': 'FeatureCollection',
-                                            'features': features})
+                                            'features': features},
+                                           separators=(',', ':'))
 
             if len(values['overlay']) > 4087:  # limit is 4096 minus the 'geojson()'
                 raise ValueError("geojson is too large for the static maps API, "


Test patch:
diff --git a/tests/test_staticmaps.py b/tests/test_staticmaps.py
index 548ab2f..ce672d1 100644
--- a/tests/test_staticmaps.py
+++ b/tests/test_staticmaps.py
@@ -56,7 +56,7 @@ def test_staticmap_lonlatz_only():
 def test_staticmap_lonlatz_features(points):
 
     overlay = json.dumps({'type': 'FeatureCollection',
-                          'features': points})
+                          'features': points}, separators=(',', ':'))
     overlay = quote(overlay)
     url = ('https://api.mapbox.com/v4/mapbox.satellite/geojson({0})/'
            '-61.7,12.1,12/600x600.png256?access_token=pk.test'.format(overlay))
@@ -69,15 +69,15 @@ def test_staticmap_lonlatz_features(points):
         content_type='image/png')
 
     res = mapbox.Static(access_token='pk.test').image('mapbox.satellite',
-                                                          -61.7, 12.1, 12,
-                                                          points)
+                                                      -61.7, 12.1, 12,
+                                                      points)
     assert res.status_code == 200
 
 @responses.activate
 def test_staticmap_auto_features(points):
 
     overlay = json.dumps({'type': 'FeatureCollection',
-                          'features': points})
+                          'features': points}, separators=(',', ':'))
     overlay = quote(overlay)
     url = ('https://api.mapbox.com/v4/mapbox.satellite/geojson({0})/'
            'auto/600x600.png256?access_token=pk.test'.format(overlay))
@@ -90,7 +90,7 @@ def test_staticmap_auto_features(points):
         content_type='image/png')
 
     res = mapbox.Static(access_token='pk.test').image('mapbox.satellite',
-                                                          features=points)
+                                                      features=points)
     assert res.status_code == 200