Skip to content

Commit

Permalink
address edge case in which intersection_2 is empty; add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gshiroma committed Sep 1, 2023
1 parent b2f7f50 commit 457097f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/rtc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,28 @@ def check_ancillary_inputs(check_ancillary_inputs_coverage,
logger.info(f' left side (-180 -> +180): {check_1_str}')

# Right side of the antimeridian crossing: +180 -> +360
ancillary_polygon_2 = _get_ogr_polygon(
#
# Get the intersection between the geogrid and the right side
# of the antimeridian (with a litter buffer represented by
# ANTIMERIDIAN_CROSSING_RIGHT_SIDE_TEST_BUFFER)
antimeridian_right_side_polygon = _get_ogr_polygon(
ancillary_xf + ANTIMERIDIAN_CROSSING_RIGHT_SIDE_TEST_BUFFER,
90, ancillary_xf + 360, -90, ancillary_srs)
intersection_2 = geogrid_polygon.Intersection(ancillary_polygon_2)

intersection_2 = geogrid_polygon.Intersection(
antimeridian_right_side_polygon)

# Create a polygon representing the ancillary dataset
# at the right side of the antimeridian
ancillary_polygon_2 = _get_ogr_polygon(
ancillary_x0 + 360, ancillary_y0,
ancillary_xf + 360, ancillary_yf,
ancillary_srs)
flag_2_ok = intersection_2.Within(ancillary_polygon_2)

# Check if the geogrid-intersected area (if valid) is within
# the ancillary polygon
flag_2_ok = (intersection_2.IsEmpty() or
intersection_2.Within(ancillary_polygon_2))
check_2_str = 'ok' if flag_2_ok else 'fail'
logger.info(f' right side (+180 -> +360): {check_2_str}')

Expand Down

0 comments on commit 457097f

Please sign in to comment.