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

Adds zoom_adjust to add_basemap #228

Merged

Conversation

tristannew
Copy link
Contributor

This PR seeks to resolve this issue #188. It is currently in progress and needs to be tested but if anyone sees this and has comments on my approach so far, any feedback would be appreciated 🙂 Also, there are some interim changes that will be removed, they are just there at the moment for testing, and since I was having some conda issues so it was quicker for me to create a local venv.

@tristannew tristannew marked this pull request as draft October 31, 2023 17:42
@martinfleis
Copy link
Member

if anyone sees this and has comments on my approach so far, any feedback would be appreciated

looks reasonable from a quick skim

@tristannew
Copy link
Contributor Author

@martinfleis Thank you for having a look! I am having one issue at the moment. With the changes, the code seems to get hung up on line 261 (256 without the changes).

arrays = Parallel(n_jobs=n_connections, prefer=preferred_backend)(
delayed(fetch_tile_fn)(tile_url, wait, max_retries) for tile_url in tile_urls)

If I don't pass zoom_adjust to add_basemap it works as expected, if I do pass it as an argument it is either very slow or keeps running until the kernel times out.

I can't think why adding an integer value to zoom would affect anything else, but I must surely be missing something. Any ideas?

@martinfleis
Copy link
Member

If the adjustment is larger than 1 or 2 zoom levels, you need to download a lot more tiles than before. That may take some time. But I can have a look at the code if you think it is something in there.

@tristannew
Copy link
Contributor Author

Ah that makes sense! It is taking a while on my machine so I think I'll spend some time trying to see if it can be sped up at all. Otherwise, from a user perspective, my implementation of zoom_adjust becomes a bit difficult to use

@martinfleis
Copy link
Member

This is useful to adjust the zoom level by ±1. Nothing else makes much sense. And for these cases, it works as expected (just tested). It also works with 2, though it takes a bit. And it is exactly the same as implemented in Place. So I would go ahead with this and add a note to the docstring instructing users that anything else than 1 or -1 is not recommended.

This exists because sometimes the data extent is just on the verge of two zoom levels and you may prefer the other one that was selected automatically.

@tristannew tristannew marked this pull request as ready for review November 10, 2023 09:34
@tristannew
Copy link
Contributor Author

Perfect, that is all done then I think. My most recent commit just includes the changes we have been discussing and an additional note in the docstrings. Is there a changelog that I should add to? Thank you so much for the help and guidance here!

@martinfleis
Copy link
Member

We use Github release notes as a changelog so no need to add anything now.

What would be nice, though, is a test. Can you add some small test, checking if the keyword works as intended? No need for anything special but we should ensure that we're loading higher or lower number of tiles than by default.

@tristannew
Copy link
Contributor Author

Sure thing, I can do that 🙂

@tristannew
Copy link
Contributor Author

Sorry it has taken me a while to get back to this - I added the test a while ago but the changes seem to violate the test_add_basemape_query test. The values seem to have changed slightly, so I have edited them to get the tests passing. But I wouldn't be able to say whether that is an destructive change that I have made. If it isn't, then should be good to go!

@martinfleis martinfleis merged commit 58b140a into geopandas:main Dec 29, 2023
10 checks passed
@martinfleis
Copy link
Member

Thanks. lot!

weiji14 added a commit to GenericMappingTools/pygmt that referenced this pull request Dec 30, 2023
The zoom_adjust parameter is used to adjust the automatic zoom level by integer increments. This was added in contextily=1.5.0, see geopandas/contextily#228.
weiji14 added a commit to GenericMappingTools/pygmt that referenced this pull request Dec 30, 2023
The zoom_adjust parameter is used to adjust the automatic zoom level by integer increments. This was added in contextily=1.5.0, see geopandas/contextily#228.
weiji14 added a commit to GenericMappingTools/pygmt that referenced this pull request Jan 8, 2024
…map (#2934)

The zoom_adjust parameter is used to adjust the automatic zoom level by integer increments.
This was added in contextily=1.5.0, see geopandas/contextily#228.

* Document that zoom_adjust requires contextily>=1.5.0
* Raise error if zoom_adjust parameter is used with contextily<1.5.0
* Add type hint for zoom_adjust parameter
* Fix typecheck by using np.array constructor instead of np.uint8

Fixes `error: Argument 1 to "unsignedinteger" has incompatible type "list[int]";
expected "SupportsInt | str | bytes | SupportsIndex"  [arg-type]`

* Change directive for zoom_adjust from versionadded to note
* Use note and important admonitions in other parts of the docstring
* Rely on sphinx-autodoc-typehints

---------

Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@tristannew tristannew deleted the features/zoom_adjust__add_basemap branch January 10, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants