Skip to content

Commit

Permalink
Add workaround for pyresample polygon intersection anti-meridian hand…
Browse files Browse the repository at this point in the history
…ling
  • Loading branch information
djhoese committed Dec 3, 2024
1 parent 10599dd commit f2b904f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion polar2grid/filters/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def boundary_for_area(area_def: PRGeometry) -> Boundary:
try:
adp = area_def.boundary()
adp.decimate(int(freq_fraction * area_def.shape[0]))
if adp.contour_poly.area() < 0:
if adp.contour_poly.area() < 0 or ((adp.vertices[:, 0] > 170).any() and (adp.vertices[:, 0] < -170).any()):

Check warning on line 56 in polar2grid/filters/_utils.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Conditional

boundary_for_area has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
# https://github.com/ssec/polar2grid/issues/696
# https://github.com/ssec/polar2grid/issues/722

Check warning on line 58 in polar2grid/filters/_utils.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

boundary_for_area has a cyclomatic complexity of 10, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
raise ValueError("Failed to generate valid polygon for area. Polygon has a negative area.")
except ValueError:
if not isinstance(area_def, SwathDefinition):
Expand Down

0 comments on commit f2b904f

Please sign in to comment.