Skip to content

Commit

Permalink
test googlestatic scale (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Feb 20, 2018
1 parent 7fe2dca commit 97d5080
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/examples/plot_googlestatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# I you need to do a lot of maps you might want
# to use an API key and set it here with key='YOUR_API_KEY'
g = GoogleVisibleMap(x=[shp.min_x, shp.max_x], y=[shp.min_y, shp.max_y],
scale=2, # scale is for more details
maptype='satellite') # try out also: 'terrain'

# the google static image is a standard rgb image
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/plot_hydrosheds.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
# Get the google map which encompasses all geometries
g = salem.GoogleVisibleMap(x=[gdf.min_x.min(), gdf.max_x.max()],
y=[gdf.min_y.min(), gdf.max_y.max()],
maptype='satellite', size_x=400, size_y=400)
maptype='satellite', scale=2,
size_x=400, size_y=400)
ggl_img = g.get_vardata()

# Get each level draining into the lake, then into the last level, and so on
Expand Down
3 changes: 3 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Enhancements
vector to raster masks (TODO: example showing its use)
- new projection for WRF files: polar stereographic
- one can now add a scale bar to maps (see :py:func:`~Map.set_scale_bar`)
- google static maps now support the `scale` kwarg for higher resolution
images (:pull:`91`).
By `tbridel <https://github.com/tbridel>`_
- each salem version is now pinned to a certain commit of the sample-data
repository. This is more robust and will avoid future tests to fail
for the wrong reasons.
Expand Down
15 changes: 14 additions & 1 deletion salem/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,13 @@ def test_center(self):
img[np.nonzero(gm.roi == 0)] /= 2.
rmsd = np.sqrt(np.mean((ref - img)**2))
self.assertTrue(rmsd < 0.2)
# assert_allclose(ref, img, atol=2e-2)

gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13,
size_x=500, size_y=500)
gm2 = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13,
size_x=500, size_y=500, scale=2)
assert (gm.grid.nx * 2) == gm2.grid.nx
assert gm.grid.extent == gm2.grid.extent

@requires_internet
@requires_motionless
Expand Down Expand Up @@ -499,6 +505,13 @@ def test_visible(self):
rmsd = np.sqrt(np.mean((ref-img)**2))
self.assertTrue(rmsd < 5e-1)

gm = GoogleVisibleMap(x=i, y=j, crs=d.grid,
size_x=500, size_y=500)
gm2 = GoogleVisibleMap(x=i, y=j, crs=d.grid, scale=2,
size_x=500, size_y=500)
assert (gm.grid.nx * 2) == gm2.grid.nx
assert gm.grid.extent == gm2.grid.extent


class TestWRF(unittest.TestCase):

Expand Down

0 comments on commit 97d5080

Please sign in to comment.