<%= if @weather_packet do %>

Weather Station

{@callsign} <% {symbol_table_id, symbol_code} = AprsmeWeb.MapLive.PacketUtils.get_symbol_info(@weather_packet) %> <% symbol_table = if symbol_table_id in ["/", "\\", "]"], do: symbol_table_id, else: "/" %> <% symbol_code = symbol_code || ">" %> <% table_id = if symbol_table == "/", do: "0", else: if(symbol_table == "]", do: "2", else: "1") %> <% symbol_code_ord = symbol_code |> String.to_charlist() |> List.first() |> (fn c -> if is_integer(c), do: c, else: 63 end).() %> <% index = symbol_code_ord - 33 %> <% safe_index = max(0, min(index, 93)) %> <% column = rem(safe_index, 16) %> <% row = div(safe_index, 16) %> <% x = -column * 128 %> <% y = -row * 128 %> <% symbol_img = "/aprs-symbols/aprs-symbols-128-#{table_id}@2x.png" %>
<.link navigate={~p"/info/#{@callsign}"} class="btn btn-outline btn-sm"> View info <.link navigate={~p"/packets/#{@callsign}"} class="btn btn-outline btn-sm"> View packets <.link navigate={~p"/#{@callsign}"} class="btn btn-primary btn-sm"> View on map
<% dt = AprsmeWeb.TimeHelpers.to_datetime( Map.get(@weather_packet, :inserted_at) || Map.get(@weather_packet, "inserted_at") ) %>

Weather Details

Last WX report
<%= if dt do %> {Calendar.strftime(dt, "%Y-%m-%d %H:%M:%S UTC")} ({AprsmeWeb.TimeHelpers.time_ago_in_words( dt )})
<%!-- {Calendar.strftime(dt, "%Y-%m-%d %H:%M:%S %Z")} local time at {Map.get(@weather_packet, :region) || Map.get(@weather_packet, "region") || "Unknown location"} [?] --%> <% else %> Unknown <% end %>
Temperature
{PacketUtils.get_weather_field(@weather_packet, :temperature)}°F
Humidity
{PacketUtils.get_weather_field(@weather_packet, :humidity)}%
Wind
{PacketUtils.get_weather_field(@weather_packet, :wind_direction)}° @ {PacketUtils.get_weather_field( @weather_packet, :wind_speed )} mph
Gusts
{PacketUtils.get_weather_field(@weather_packet, :wind_gust)} mph
Pressure
{PacketUtils.get_weather_field(@weather_packet, :pressure)} hPa
Rain (1h)
{get_weather_field_zero(@weather_packet, :rain_1h)} in
Rain (24h)
{get_weather_field_zero(@weather_packet, :rain_24h)} in
Rain (since midnight)
{get_weather_field_zero(@weather_packet, :rain_since_midnight)} in
Raw Packet
<%= if is_binary(@weather_packet.raw_packet) do %> {Aprsme.EncodingUtils.sanitize_string(@weather_packet.raw_packet)} <% else %> {@weather_packet.raw_packet || ""} <% end %>
Raw comment: {@weather_packet.comment || @weather_packet["comment"]}

Weather History Graphs

<%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :temperature, nil)))) do %>
<% end %> <%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :humidity, nil)))) do %>
<% end %> <%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :pressure, nil)))) do %>
<% end %> <%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :wind_speed, nil)))) do %>
<% end %> <%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :rain_1h, nil)))) or Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :rain_24h, nil)))) or Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :rain_since_midnight, nil)))) do %>
<% end %> <%= if Enum.any?(@weather_history, &(not is_nil(Map.get(&1, :luminosity, nil)))) do %>
<% end %>
<% else %>

Weather for {@callsign}

No recent weather data available for this callsign.
<% end %>