Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in auto computation of zoom levels #214

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contextily/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def _calculate_zoom(w, s, e, n):
# Calculate the zoom
zoom_lon = np.ceil(np.log2(360 * 2.0 / lon_length))
zoom_lat = np.ceil(np.log2(360 * 2.0 / lat_length))
zoom = np.max([zoom_lon, zoom_lat])
zoom = np.min([zoom_lon, zoom_lat])
return int(zoom)


Expand Down
10 changes: 5 additions & 5 deletions tests/test_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ def test_add_basemap_auto_zoom():
4891969.810251278,
)
assert_array_almost_equal(ax_extent, ax.images[0].get_extent())
assert ax.images[0].get_array()[:, :, :3].sum() == 563185119
assert ax.images[0].get_array().sum() == 830571999
assert ax.images[0].get_array().shape == (1024, 1024, 4)
assert ax.images[0].get_array()[:, :, :3].sum() == 141378723
assert ax.images[0].get_array().sum() == 208225443
assert ax.images[0].get_array().shape == (512, 512, 4)
assert_array_almost_equal(
ax.images[0].get_array()[:, :, :3].mean(), 179.03172779083252
ax.images[0].get_array()[:, :, :3].mean(), 179.772343
)
assert_array_almost_equal(ax.images[0].get_array().mean(), 198.023796)
assert_array_almost_equal(ax.images[0].get_array().mean(), 198.579257)


@pytest.mark.network
Expand Down