format
This commit is contained in:
parent
fe96abca59
commit
8a37182dd5
6 changed files with 39 additions and 35 deletions
|
|
@ -469,8 +469,7 @@ defmodule Aprs.Is do
|
|||
converted_map =
|
||||
struct
|
||||
|> Map.from_struct()
|
||||
|> Enum.map(fn {k, v} -> {k, struct_to_map(v)} end)
|
||||
|> Enum.into(%{})
|
||||
|> Map.new(fn {k, v} -> {k, struct_to_map(v)} end)
|
||||
|
||||
# Add type information to help with later processing
|
||||
Map.put(converted_map, :__original_struct__, struct_type)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ defmodule Aprs.Packet do
|
|||
import Ecto.Changeset
|
||||
|
||||
alias Aprs.DataExtended
|
||||
alias Parser.Types.MicE
|
||||
|
||||
schema "packets" do
|
||||
field(:base_callsign, :string)
|
||||
|
|
@ -158,13 +159,13 @@ defmodule Aprs.Packet do
|
|||
# Extract data based on the type of data_extended
|
||||
additional_data =
|
||||
case data_extended do
|
||||
%{__original_struct__: Parser.Types.MicE} = mic_e_map ->
|
||||
%{__original_struct__: MicE} = mic_e_map ->
|
||||
extract_from_mic_e_map(mic_e_map)
|
||||
|
||||
%{} when is_map(data_extended) ->
|
||||
extract_from_map(data_extended)
|
||||
|
||||
%Parser.Types.MicE{} = mic_e ->
|
||||
%MicE{} = mic_e ->
|
||||
extract_from_mic_e(mic_e)
|
||||
|
||||
_ ->
|
||||
|
|
@ -210,8 +211,10 @@ defmodule Aprs.Packet do
|
|||
|> maybe_put(:equipment_type, mic_e.equipment_type)
|
||||
|> maybe_put(:course, mic_e.course)
|
||||
|> maybe_put(:speed, mic_e.speed)
|
||||
|> maybe_put(:symbol_code, ">") # Default car symbol for MicE
|
||||
|> maybe_put(:symbol_table_id, "/") # Primary table
|
||||
# Default car symbol for MicE
|
||||
|> maybe_put(:symbol_code, ">")
|
||||
# Primary table
|
||||
|> maybe_put(:symbol_table_id, "/")
|
||||
end
|
||||
|
||||
# Extract data from converted MicE map (from struct_to_map conversion)
|
||||
|
|
@ -222,8 +225,10 @@ defmodule Aprs.Packet do
|
|||
|> maybe_put(:equipment_type, mic_e_map[:equipment_type])
|
||||
|> maybe_put(:course, mic_e_map[:heading])
|
||||
|> maybe_put(:speed, mic_e_map[:speed])
|
||||
|> maybe_put(:symbol_code, ">") # Default car symbol for MicE
|
||||
|> maybe_put(:symbol_table_id, "/") # Primary table
|
||||
# Default car symbol for MicE
|
||||
|> maybe_put(:symbol_code, ">")
|
||||
# Primary table
|
||||
|> maybe_put(:symbol_table_id, "/")
|
||||
end
|
||||
|
||||
# Extract weather data from various formats
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
<h1 class="text-xl font-bold text-gray-800 mb-2">Legacy APRS Map</h1>
|
||||
<p class="text-sm text-gray-600 mb-4">
|
||||
This is the legacy JavaScript-based map.
|
||||
<a href="/" class="text-blue-600 hover:text-blue-800 underline">Try the new LiveView-based map</a> or
|
||||
<a href="/enhanced" class="text-blue-600 hover:text-blue-800 underline">enhanced version</a>.
|
||||
<a href="/" class="text-blue-600 hover:text-blue-800 underline">
|
||||
Try the new LiveView-based map
|
||||
</a>
|
||||
or <a href="/enhanced" class="text-blue-600 hover:text-blue-800 underline">enhanced version</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ defmodule AprsWeb.Helpers.AprsSymbols do
|
|||
case symbol_table_id do
|
||||
"/" -> "aprs-symbols-24-0.png"
|
||||
"\\" -> "aprs-symbols-24-1.png"
|
||||
_ -> "aprs-symbols-24-0.png" # Default to primary table
|
||||
# Default to primary table
|
||||
_ -> "aprs-symbols-24-0.png"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -96,9 +97,9 @@ defmodule AprsWeb.Helpers.AprsSymbols do
|
|||
{x, y} = get_symbol_position(symbol_code)
|
||||
|
||||
"background-image: url('/aprs-symbols/#{sprite_file}'); " <>
|
||||
"background-position: #{x}px #{y}px; " <>
|
||||
"width: 24px; height: 24px; " <>
|
||||
"background-repeat: no-repeat;"
|
||||
"background-position: #{x}px #{y}px; " <>
|
||||
"width: 24px; height: 24px; " <>
|
||||
"background-repeat: no-repeat;"
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
@ -109,7 +110,7 @@ defmodule AprsWeb.Helpers.AprsSymbols do
|
|||
extra_style = Keyword.get(opts, :style, "")
|
||||
|
||||
base_style = symbol_css_style(symbol_table_id, symbol_code)
|
||||
full_style = if extra_style != "", do: base_style <> " " <> extra_style, else: base_style
|
||||
full_style = if extra_style == "", do: base_style, else: base_style <> " " <> extra_style
|
||||
|
||||
Phoenix.HTML.raw(~s(<div class="#{css_class}" style="#{full_style}"></div>))
|
||||
end
|
||||
|
|
@ -137,7 +138,8 @@ defmodule AprsWeb.Helpers.AprsSymbols do
|
|||
Get the default symbol for unknown or invalid symbols.
|
||||
"""
|
||||
def default_symbol do
|
||||
{"/", ">"} # Car icon as default
|
||||
# Car icon as default
|
||||
{"/", ">"}
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
@ -148,6 +150,7 @@ defmodule AprsWeb.Helpers.AprsSymbols do
|
|||
{table, code} when table in ["/", "\\"] and is_binary(code) and byte_size(code) > 0 ->
|
||||
char_code = code |> String.first() |> String.to_charlist() |> List.first()
|
||||
char_code >= 32 and char_code <= 127
|
||||
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -262,12 +262,8 @@ defmodule AprsWeb.MapLive.Enhanced do
|
|||
.historical-marker {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<!-- Map Container -->
|
||||
<div
|
||||
id="aprs-map"
|
||||
|
|
|
|||
|
|
@ -462,8 +462,6 @@ defmodule AprsWeb.MapLive.Index do
|
|||
z-index: 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.locate-button {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
|
|
@ -549,8 +547,6 @@ defmodule AprsWeb.MapLive.Index do
|
|||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
id="aprs-map"
|
||||
phx-hook="APRSMap"
|
||||
|
|
@ -749,10 +745,13 @@ defmodule AprsWeb.MapLive.Index do
|
|||
# Only include packets with valid position data
|
||||
if lat && lng do
|
||||
# Get symbol information from data_extended
|
||||
symbol_table_id = get_in(data_extended, ["symbol_table_id"]) ||
|
||||
packet.symbol_table_id || "/"
|
||||
symbol_code = get_in(data_extended, ["symbol_code"]) ||
|
||||
packet.symbol_code || ">"
|
||||
symbol_table_id =
|
||||
get_in(data_extended, ["symbol_table_id"]) ||
|
||||
packet.symbol_table_id || "/"
|
||||
|
||||
symbol_code =
|
||||
get_in(data_extended, ["symbol_code"]) ||
|
||||
packet.symbol_code || ">"
|
||||
|
||||
# Validate symbol
|
||||
{final_table_id, final_symbol_code} =
|
||||
|
|
@ -763,11 +762,12 @@ defmodule AprsWeb.MapLive.Index do
|
|||
end
|
||||
|
||||
# Generate callsign for display
|
||||
callsign = if packet.ssid && packet.ssid != "" do
|
||||
"#{packet.base_callsign}-#{packet.ssid}"
|
||||
else
|
||||
packet.base_callsign || ""
|
||||
end
|
||||
callsign =
|
||||
if packet.ssid && packet.ssid != "" do
|
||||
"#{packet.base_callsign}-#{packet.ssid}"
|
||||
else
|
||||
packet.base_callsign || ""
|
||||
end
|
||||
|
||||
%{
|
||||
"id" => callsign,
|
||||
|
|
@ -784,9 +784,8 @@ defmodule AprsWeb.MapLive.Index do
|
|||
"comment" => get_in(data_extended, ["comment"]) || "",
|
||||
"data_extended" => data_extended || %{}
|
||||
}
|
||||
else
|
||||
|
||||
# Return nil for packets without position data
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue