Skip to content

Commit

Permalink
Add more test points.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGayno-NOAA committed Nov 26, 2024
1 parent c15de74 commit 35c06bd
Showing 1 changed file with 106 additions and 13 deletions.
119 changes: 106 additions & 13 deletions tests/orog/ftst_inside_polygon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@ program inside_polygon

implicit none

integer, parameter :: npts=4
integer, parameter :: npts=4

real, parameter :: D2R = 3.14159265358979/180.
logical :: inside
real, parameter :: D2R = 3.14159265358979/180.

real :: lon1, lat1
real :: lon2(npts), lat2(npts)
logical :: inside

! Test to trip the first 'if' range check
real :: lon1, lat1
real :: lon2(npts), lat2(npts)

! The first part of the function checks if the test point is outside
! the neighborhood of the polygon - i.e., a gross check. There
! are six separate checks. The first six tests are designed
! so that the polygon is far enough from the test point that
! each check is tripped.

! Test to trip the first 'if' gross check. Is point outside the
! neighborhood in the plus 'x' direction?

print*, "Test point 1"

lon1 = 90.0 * D2R
lon1 = 90.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 94.0 * D2R
lon2(1) = 94.0 * D2R ! Polygon.
lat2(1) = -1.0 * D2R
lon2(2) = 94.0 * D2R
lat2(2) = 1.0 * D2R
Expand All @@ -30,16 +38,17 @@ program inside_polygon

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 2
if (inside) stop 2 ! Test point should be outside polygon.

! Test to trip the second 'if' range check
! Test to trip the second 'if' gross check. Is point outside the
! neighborhood in the minus 'x' direction?

print*, "Test point 2"

lon1 = 90.0 * D2R
lon1 = 90.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 84.0 * D2R
lon2(1) = 84.0 * D2R ! Polygon.
lat2(1) = -1.0 * D2R
lon2(2) = 84.0 * D2R
lat2(2) = 1.0 * D2R
Expand All @@ -50,7 +59,91 @@ program inside_polygon

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 4
if (inside) stop 4 ! Test point should be outside polygon.

! Test to trip the third 'if' gross check. Is point outside the
! neighborhood in the plus 'y' direction?

print*, "Test point 3"

lon1 = 0.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 354.0 * D2R ! Polygon.
lat2(1) = -1.0 * D2R
lon2(2) = 354.0 * D2R
lat2(2) = 1.0 * D2R
lon2(3) = 355.0 * D2R
lat2(3) = 1.0 * D2R
lon2(4) = 355.0 * D2R
lat2(4) = -1.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 6 ! Test point should be outside polygon.

! Test to trip the fourth 'if' gross check. Is point outside the
! neighborhood in the minus 'y' direction?

print*, "Test point 4"

lon1 = 0.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 4.0 * D2R ! Polygon.
lat2(1) = -1.0 * D2R
lon2(2) = 4.0 * D2R
lat2(2) = 1.0 * D2R
lon2(3) = 5.0 * D2R
lat2(3) = 1.0 * D2R
lon2(4) = 5.0 * D2R
lat2(4) = -1.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 8 ! Test point should be outside polygon.

! Test to trip the fifth 'if' gross check. Is point outside the
! neighborhood in the plus 'z' direction?

print*, "Test point 5"

lon1 = 0.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 359.0 * D2R ! Polygon.
lat2(1) = -6.0 * D2R
lon2(2) = 359.0 * D2R
lat2(2) = -5.0 * D2R
lon2(3) = 1.0 * D2R
lat2(3) = -5.0 * D2R
lon2(4) = 1.0 * D2R
lat2(4) = -6.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 10 ! Test point should be outside polygon.

! Test to trip the sixth 'if' gross check. Is point outside the
! neighborhood in the minus 'z' direction?

print*, "Test point 6"

lon1 = 0.0 * D2R ! Test point.
lat1 = 0.0 * D2R

lon2(1) = 359.0 * D2R ! Polygon.
lat2(1) = 5.0 * D2R
lon2(2) = 359.0 * D2R
lat2(2) = 6.0 * D2R
lon2(3) = 1.0 * D2R
lat2(3) = 6.0 * D2R
lon2(4) = 1.0 * D2R
lat2(4) = 5.0 * D2R

inside=inside_a_polygon(lon1, lat1, npts, lon2, lat2)

if (inside) stop 12 ! Test point should be outside polygon.

print*,"OK"
print*,"SUCCSSS"
Expand Down

0 comments on commit 35c06bd

Please sign in to comment.