Skip to content

Commit

Permalink
Refactor area boundary generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Jun 28, 2023
1 parent f325262 commit 814ad27
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from pyresample import CHUNK_SIZE
from pyresample._spatial_mp import Cartesian, Cartesian_MP, Proj_MP
from pyresample.area_config import create_area_def
from pyresample.boundary import AreaDefBoundary, Boundary, SimpleBoundary
from pyresample.boundary import Boundary, SimpleBoundary
from pyresample.utils import check_slice_orientation, load_cf_area
from pyresample.utils.proj4 import (
get_geostationary_height,
Expand Down Expand Up @@ -2595,10 +2595,7 @@ def get_area_slices(self, area_to_cover, shape_divisible_by=None):
y_slice = _ensure_integer_slice(y_slice)
return x_slice, y_slice

if not self.is_geostationary:
data_boundary = self.boundary(frequency=100)
else:
data_boundary = Boundary(*get_geostationary_bounding_box_in_lonlats(self))
data_boundary = self._get_area_to_cover_boundary(self)
area_boundary = self._get_area_to_cover_boundary(area_to_cover)
intersection = data_boundary.contour_poly.intersection(
area_boundary.contour_poly)
Expand Down Expand Up @@ -2626,7 +2623,8 @@ 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))
return AreaDefBoundary(area_to_cover, 100)
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")

Expand Down

0 comments on commit 814ad27

Please sign in to comment.