<%= if @weather_packet do %>

{gettext("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"> {gettext("View info")} <.link navigate={~p"/packets/#{@callsign}"} class="btn btn-outline btn-sm"> {gettext("View packets")} <.link navigate={~p"/#{@callsign}"} class="btn btn-primary btn-sm"> {gettext("View on map")}
<% dt = AprsmeWeb.TimeHelpers.to_datetime( Map.get(@weather_packet, :inserted_at) || Map.get(@weather_packet, "inserted_at") ) %>

{gettext("Weather Details")}

{gettext("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 %> {gettext("Unknown")} <% end %>
{gettext("Temperature")}
{format_weather_value(@weather_packet, :temperature, @locale)}
{gettext("Humidity")}
{PacketUtils.get_weather_field(@weather_packet, :humidity)}%
{gettext("Wind")}
{PacketUtils.get_weather_field(@weather_packet, :wind_direction)}° @ {format_weather_value( @weather_packet, :wind_speed, @locale )}
{gettext("Gusts")}
{format_weather_value(@weather_packet, :wind_gust, @locale)}
{gettext("Pressure")}
{PacketUtils.get_weather_field(@weather_packet, :pressure)} hPa
{gettext("Rain (1h)")}
{format_weather_value(@weather_packet, :rain_1h, @locale)}
{gettext("Rain (24h)")}
{format_weather_value(@weather_packet, :rain_24h, @locale)}
{gettext("Rain (since midnight)")}
{format_weather_value(@weather_packet, :rain_since_midnight, @locale)}
{gettext("Raw Packet")}
<%= if is_binary(@weather_packet.raw_packet) do %> {Aprsme.EncodingUtils.sanitize_string(@weather_packet.raw_packet)} <% else %> {@weather_packet.raw_packet || ""} <% end %>
{gettext("Raw comment")}: {@weather_packet.comment || @weather_packet["comment"]}

{gettext("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 %>