23 lines
767 B
Elixir
23 lines
767 B
Elixir
defmodule Microwaveprop.Rover.Elevation do
|
|
@moduledoc """
|
|
Bulk SRTM elevation lookup for a list of `{lat, lon}` points.
|
|
|
|
Wraps `Microwaveprop.Terrain.Srtm.lookup/3`, which already opens and
|
|
reads each tile per call. Cells whose tile is missing or whose value
|
|
is the SRTM void sentinel are mapped to `nil`.
|
|
"""
|
|
|
|
alias Microwaveprop.Terrain.Srtm
|
|
|
|
@spec lookup_many([{float(), float()}]) :: %{{float(), float()} => integer() | nil}
|
|
def lookup_many(points) when is_list(points) do
|
|
tiles_dir = Application.get_env(:microwaveprop, :srtm_tiles_dir, "/data/srtm")
|
|
|
|
Map.new(points, fn {lat, lon} = key ->
|
|
case Srtm.lookup(lat, lon, tiles_dir) do
|
|
{:ok, elev} -> {key, elev}
|
|
{:error, _} -> {key, nil}
|
|
end
|
|
end)
|
|
end
|
|
end
|