Skip to content

Commit

Permalink
Finish unit test for inside_a_polygon.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGayno-NOAA committed Dec 2, 2024
1 parent cfe59e1 commit e8637db
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions tests/orog/ftst_inside_polygon.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
program inside_polygon

! Unit test for function inside_a_polygon, which determines
! whether a test point is located within an area specified
! by a polygon.
!
! Author George Gayno NCEP/EMC

use orog_utils, only : inside_a_polygon

implicit none
Expand All @@ -13,13 +19,15 @@ program inside_polygon
real :: lon1, lat1
real :: lon2(npts), lat2(npts)

! The first part of the function checks if the test point is outside
print*,"Starting test of inside_a_polygon."

! The first part of the function checks if the test point is well 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
! Test to trip the first 'if' gross check. Is point well outside the
! neighborhood in the plus 'x' direction?

print*, "Test point 1"
Expand All @@ -40,7 +48,7 @@ program inside_polygon

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

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

print*, "Test point 2"
Expand All @@ -61,7 +69,7 @@ program inside_polygon

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

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

print*, "Test point 3"
Expand All @@ -82,7 +90,7 @@ program inside_polygon

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

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

print*, "Test point 4"
Expand All @@ -103,7 +111,7 @@ program inside_polygon

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

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

print*, "Test point 5"
Expand All @@ -124,7 +132,7 @@ program inside_polygon

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

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

print*, "Test point 6"
Expand Down Expand Up @@ -189,6 +197,26 @@ program inside_polygon

if (.not.inside) stop 16 ! Test point should be inside polygon.

! Test the case when the test point just outside the polygon.

print*, "Test point 9"

lon1 = 89.5 * D2R ! Test point.
lat1 = 0.5 * D2R

lon2(1) = 90.0 * D2R ! Polygon.
lat2(1) = 0.0 * D2R
lon2(2) = 90.0 * D2R
lat2(2) = 1.0 * D2R
lon2(3) = 91.0 * D2R
lat2(3) = 1.0 * D2R
lon2(4) = 91.0 * D2R
lat2(4) = 0.0 * D2R

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

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

print*,"OK"
print*,"SUCCSSS"

Expand Down

0 comments on commit e8637db

Please sign in to comment.