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

[core] Fix get_bounds behavior in core #2012

Merged
merged 5 commits into from
Jun 14, 2024

Conversation

naschmitz
Copy link
Collaborator

Also:

  • added alias for getBounds,
  • fixed an issue where geemap crashed without a helpful message if the map hadn't been added to the screen, and
  • added some unit tests.

The behavior was correct in geemap non-core.

Also:
- added alias for getBounds,
- fixed an issue where geemap crashed without a helpful message if the map hadn't been added to the screen, and
- added some unit tests.

The behavior was correct in geemap non-core.
@naschmitz naschmitz requested a review from giswqs May 14, 2024 20:53
@naschmitz naschmitz changed the title [core] Fix get_bounds behavior in core. [core] Fix get_bounds behavior in core Jun 14, 2024
geemap/core.py Outdated
@@ -488,9 +488,29 @@ def set_zoom(self, value: int) -> None:
def get_center(self) -> Sequence:
return self.center

def get_bounds(self) -> Sequence:
def get_bounds(self, as_geo_json: bool = False) -> Sequence:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change as_geo_json to as_geojson?

geemap/core.py Outdated
# https://ipyleaflet.readthedocs.io/en/latest/map_and_basemaps/map.html#ipyleaflet.Map.fit_bounds
coords = [bounds[0][1], bounds[0][0], bounds[1][1], bounds[1][0]]

if as_geo_json:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_geojson?

return coords

getBounds = get_bounds
return super().get_bounds(as_geo_json=asGeoJSON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_geojson?


mock_bounds.__get__ = Mock(return_value=())
with self.assertRaisesRegex(RuntimeError, "Map bounds are undefined"):
self.core_map.get_bounds(as_geo_json=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_geojson?

geemap/core.py Outdated
"""Returns the bounds of the current map view.

Args:
as_geo_json (bool, optional): If true, returns map bounds as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_geojson?

@giswqs giswqs merged commit c0fc89f into gee-community:master Jun 14, 2024
14 checks passed
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