Skip to content

Commit

Permalink
Make static method a function
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Jun 28, 2023
1 parent 814ad27 commit 44af636
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2595,8 +2595,8 @@ def get_area_slices(self, area_to_cover, shape_divisible_by=None):
y_slice = _ensure_integer_slice(y_slice)
return x_slice, y_slice

data_boundary = self._get_area_to_cover_boundary(self)
area_boundary = self._get_area_to_cover_boundary(area_to_cover)
data_boundary = _get_area_boundary(self)
area_boundary = _get_area_boundary(area_to_cover)
intersection = data_boundary.contour_poly.intersection(
area_boundary.contour_poly)
if intersection is None:
Expand All @@ -2618,16 +2618,6 @@ def get_area_slices(self, area_to_cover, shape_divisible_by=None):
return (check_slice_orientation(x_slice),
check_slice_orientation(y_slice))

@staticmethod
def _get_area_to_cover_boundary(area_to_cover: AreaDefinition) -> Boundary:
try:
if area_to_cover.is_geostationary:
return Boundary(*get_geostationary_bounding_box_in_lonlats(area_to_cover))
boundary_shape = max(max(*area_to_cover.shape) // 100 + 1, 3)
return area_to_cover.boundary(frequency=boundary_shape, force_clockwise=True)
except ValueError:
raise NotImplementedError("Can't determine boundary of area to cover")

def crop_around(self, other_area):
"""Crop this area around `other_area`."""
xslice, yslice = self.get_area_slices(other_area)
Expand Down Expand Up @@ -2727,6 +2717,16 @@ def geocentric_resolution(self, ellps='WGS84', radius=None):
return res


def _get_area_boundary(area_to_cover: AreaDefinition) -> Boundary:
try:
if area_to_cover.is_geostationary:
return Boundary(*get_geostationary_bounding_box_in_lonlats(area_to_cover))
boundary_shape = max(max(*area_to_cover.shape) // 100 + 1, 3)
return area_to_cover.boundary(frequency=boundary_shape, force_clockwise=True)
except ValueError:
raise NotImplementedError("Can't determine boundary of area to cover")


def _make_slice_divisible(sli, max_size, factor=2):
"""Make the given slice even in size."""
rem = (sli.stop - sli.start) % factor
Expand Down

0 comments on commit 44af636

Please sign in to comment.