Skip to content

Commit

Permalink
CMR-4722: Bounding box constraint matching granules outside of boundi…
Browse files Browse the repository at this point in the history
…ng box.
  • Loading branch information
ygliuvt committed Apr 20, 2018
1 parent 6b16b9e commit 89ede54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions orbits-lib/resources/orbits/geometry_backtracking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def fast_bounding_rectangle_crossing_range(lat_range, north_deg, west_deg, south
return [[lat_range, LongitudeCoverage.full]]
end

# Shift north and south off start latitude a bit if there is an exact match,
# so that math could work.
north = start_lat_rad - EPSILON if north == start_lat_rad
south = start_lat_rad + EPSILON if south == start_lat_rad

# If the northern part of the bounding rectangle is above the orbit's starting latitude
# and the southern part is below, split into two bounding rectangles, one entirely above
# and one entirely below and backtrack each
Expand Down
7 changes: 4 additions & 3 deletions orbits-lib/resources/orbits/orbit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def horizontal_swath_edges(coord, ascending)
# the swath width is measured perpendicular to the orbit, but the
# Java code makes this assumption. This case should almost never
# happen. When it does, the numbers are likely close enough.
if coord.phi == 0

if coord.phi.abs <= EPSILON
return [Coordinate.phi_theta(0, coord.theta - swath_width_rad / 2),
Coordinate.phi_theta(0, coord.theta + swath_width_rad / 2)]
end
Expand Down Expand Up @@ -415,7 +416,7 @@ def horizontal_swath_edges(coord, ascending)
# We can't just compute constants for the line, because `b` could be near 0.
# Let's deal with that special case first.

if b.abs < 0.000001
if b.abs < EPSILON

# If `b = 0`, then the plane's equation is:
#
Expand All @@ -429,7 +430,7 @@ def horizontal_swath_edges(coord, ascending)
# case, we have an orbit that follows the equator. If coord lies within the
# swath, then every orbit will cover the point, otherwise no orbits will.

if a.abs < 0.000001
if a.abs < EPSILON
if coord.phi.abs < swath_width_rad / 2
return [Coordinate.phi_theta(0, -PI), Coordinate.phi_theta(0, PI)]
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@
[granule] [150 70 170 60]

"Rectangle not crossing the equator that should not find the granule"
[] [-128.32 53.602 -46.758 1.241]))))
[] [-128.32 53.602 -46.758 1.241]

;; Test that needs to be fixed with CMR-4722
; "CMR-4722: Search crossing the equator should not erroneously find the granule"
; [] [-128.32 53.602 -46.758 -1.241]))))
"CMR-4722: Search crossing the equator should not erroneously find the granule"
[] [-128.32 53.602 -46.758 -1.241]))))

;; This tests searching for bounding boxes or polygons that cross the start circular
;; latitude of the collection with fractional orbit granules. This was added to test
Expand Down Expand Up @@ -223,9 +222,9 @@
matches?)

"Orbits crossing a rectangle over the equator and anti-meridian"
[g2 g7 g9] [145 45 -145 -45] nil
[g2 g7] [145 45 -145 -45] nil
"Orbits crossing a rectangle over the equator and meridian"
[g1 g3 g8 g9] [-45 45 45 -45] nil
[g1 g3 g8] [-45 45 45 -45] nil
"Orbits crossing a rectangle in the western hemisphere near the north pole"
[g5] [-90 89 -45 85] nil
"Orbits crossing a rectangle in the southern hemisphere crossing the anti-meridian"
Expand Down

0 comments on commit 89ede54

Please sign in to comment.