LOGICAL FUNCTION IsPointInsideInteger &
!
(point, grid, checkCRS) &
!
RESULT (inside)
IMPLICIT NONE
!Arguments with intent in:
TYPE (grid_integer), INTENT(IN) :: grid
TYPE (Coordinate), INTENT(IN) :: point
LOGICAL, INTENT(IN) :: checkCRS
!local declarations:
TYPE (Coordinate) :: point2
INTEGER (KIND = float) :: r, c
LOGICAL :: checkIn
!----------------------end of declarations-------------------------------------
inside = .FALSE.
IF ( checkCRS ) THEN !check CRS of point is the same of grid
IF ( point % system == grid % grid_mapping ) THEN
!coordinate reference system is the same
CALL GetIJ ( point % easting, point % northing, grid, &
r, c, checkIn)
IF ( .NOT. checkIn) THEN !point is outside grid boundary
RETURN
END IF
IF ( grid % mat (r,c) /= grid % nodata ) THEN
inside = .TRUE.
RETURN
END IF
ELSE
!convert CRS
point2 % system = grid % grid_mapping
CALL Convert (point, point2)
CALL GetIJ ( point2 % easting, point2 % northing, grid, &
r, c, checkIn)
IF ( .NOT. checkIn) THEN !point is outside grid boundary
RETURN
END IF
IF ( grid % mat (r,c) /= grid % nodata ) THEN
inside = .TRUE.
RETURN
END IF
END IF
ELSE
CALL GetIJ ( point % easting, point % northing, grid, &
r, c, checkIn)
IF ( .NOT. checkIn) THEN !point is outside grid boundary
RETURN
END IF
IF ( grid % mat (r,c) /= grid % nodata ) THEN
inside = .TRUE.
RETURN
END IF
END IF
RETURN
END FUNCTION IsPointInsideInteger