Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
use compact separators to keep json overlay small
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygeo committed Dec 4, 2015
1 parent a04cb61 commit 49834d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion mapbox/services/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def image(self, mapid, lon=None, lat=None, z=None, features=None,

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, "
Expand Down
10 changes: 5 additions & 5 deletions tests/test_staticmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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


Expand Down

0 comments on commit 49834d3

Please sign in to comment.