elevation Function

private function elevation(self, lat, lon, found) result(h)

The height of the terrain (scene units, above the body's sphere or ellipsoid) at latitude and longitude lat, lon (degrees), from the last elevation layer added that is a file (LAYER_GDAL), read directly (also before the body is shown); found is false (and the height 0) without such a layer or data there, or without Rocky.

Type Bound

TerrainBody

Arguments

Type IntentOptional Attributes Name
class(TerrainBody), intent(in) :: self
real(kind=wp), intent(in) :: lat

latitude and longitude (degrees)

real(kind=wp), intent(in) :: lon

latitude and longitude (degrees)

logical, intent(out), optional :: found

false if there is no height there

Return Value real(kind=wp)


Calls

proc~~elevation~~CallsGraph proc~elevation TerrainBody%elevation interface~vkf_rocky_elevation vkf_rocky_elevation proc~elevation->interface~vkf_rocky_elevation proc~find_data_file find_data_file proc~elevation->proc~find_data_file proc~rocky_available rocky_available proc~elevation->proc~rocky_available proc~find_in_dirs find_in_dirs proc~find_data_file->proc~find_in_dirs interface~vkf_rocky_available vkf_rocky_available proc~rocky_available->interface~vkf_rocky_available

Source Code

    function elevation(self, lat, lon, found) result(h)
        class(TerrainBody), intent(in) :: self
        real(wp), intent(in) :: lat, lon                !! latitude and longitude (degrees)
        logical, intent(out), optional :: found         !! false if there is no height there
        real(wp) :: h
        character(len=:), allocatable :: file
        integer(c_int) :: ok
        integer :: k
        h = 0.0_wp
        if (present(found)) found = .false.
        if (.not. rocky_available()) return
        do k = self%n_layers, 1, -1
            if (.not. (self%layers(k)%elevation .and. self%layers(k)%source == LAYER_GDAL)) cycle
            file = self%layers(k)%uri
            if (index(file, '://') == 0) file = find_data_file(file)
            if (len(file) == 0) return
            h = vkf_rocky_elevation(file, len(file, kind=c_int), self%profile_, len(self%profile_, kind=c_int), &
                                    real(lat, c_double), real(lon, c_double), ok) * self%units_per_meter_
            if (present(found)) found = ok /= 0
            return
        end do
    end function elevation