Skip to content

Commit

Permalink
add option to keep extent as-is when setting a geometry-frame
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelquast committed Apr 8, 2024
1 parent 99548b8 commit 00d7c1c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions eomaps/eomaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5450,7 +5450,7 @@ def refetch_wms_on_size_change(self, *args, **kwargs):
"""Set the behavior for WebMap services on axis or figure size changes."""
refetch_wms_on_size_change(*args, **kwargs)

def _set_gdf_path_boundary(self, gdf):
def _set_gdf_path_boundary(self, gdf, set_extent=True):
geom = gdf.to_crs(self.crs_plot).unary_union.boundary

Check warning on line 5454 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5454

Added line #L5454 was not covered by tests

if geom.geom_type == "MultiLineString":
Expand All @@ -5471,17 +5471,17 @@ def _set_gdf_path_boundary(self, gdf):
path = mpath.Path(vertices, codes)

Check warning on line 5471 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5471

Added line #L5471 was not covered by tests

self.ax.set_boundary(path, self.ax.transData)
if set_extent:
x0, y0 = np.min(vertices, axis=0)
x1, y1 = np.max(vertices, axis=0)

Check warning on line 5476 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5473-L5476

Added lines #L5473 - L5476 were not covered by tests

x0, y0 = np.min(vertices, axis=0)
x1, y1 = np.max(vertices, axis=0)

self.set_extent([x0, x1, y0, y1], gdf.crs)
self.set_extent([x0, x1, y0, y1], gdf.crs)

Check warning on line 5478 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5478

Added line #L5478 was not covered by tests

if multi:

Check warning on line 5480 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5480

Added line #L5480 was not covered by tests
# TODO apply fix for multi-path geometries (see cartopy PR #2362)
_fix_multipath_GeoSpine()

Check warning on line 5482 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5482

Added line #L5482 was not covered by tests

def set_frame(self, rounded=0, gdf=None, **kwargs):
def set_frame(self, rounded=0, gdf=None, set_extent=True, **kwargs):
"""
Set the properties of the map boundary and the background patch.
Expand Down Expand Up @@ -5553,7 +5553,7 @@ def set_frame(self, rounded=0, gdf=None, **kwargs):
self.ax.spines["geo"].update(kwargs)

if gdf is not None:
self._set_gdf_path_boundary(self._handle_gdf(gdf))
self._set_gdf_path_boundary(self._handle_gdf(gdf), set_extent=set_extent)

Check warning on line 5556 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L5556

Added line #L5556 was not covered by tests

elif rounded:
assert (
Expand Down

0 comments on commit 00d7c1c

Please sign in to comment.