Fix object/item packets showing sender callsign instead of object name

Objects and items now display with their own names on the map instead of
the originating station's callsign. This prevents confusion where stations
creating objects (like repeaters) appear at multiple locations.

For example, CALGRY creates repeater objects (147.06-WC, 146.85-NH) which
were appearing on the map labeled as "CALGRY" at the repeater locations
instead of showing the actual object names.

Changes:
- Updated map_label() to return object_name for object packets
- Updated map_label() to return item_name for item packets
- Position packets continue to show the sender callsign
- Updated tests to expect object/item names instead of sender

This matches APRS.fi behavior where objects are displayed separately
from their originating station.
This commit is contained in:
Graham McIntire 2026-03-22 13:02:09 -05:00
parent 4e85ccda05
commit 544d8648a0
No known key found for this signature in database
2 changed files with 37 additions and 27 deletions

View file

@ -235,18 +235,28 @@ defmodule AprsmeWeb.Live.Shared.PacketUtils do
@doc """ @doc """
Get the map label for a packet. Get the map label for a packet.
For map display, always show the sender callsign regardless of whether For objects and items, show the object/item name to distinguish them from
it's an object or item packet. This avoids confusion where the map label the station that created them. For example, a repeater object should show
shows something different from what the user expects (like a balloon ID the repeater name, not the station that's reporting it.
instead of the station callsign).
If the packet is an object or item, you can append the object/item name For position packets, show the sender callsign.
in the popup or detail view.
""" """
@spec map_label(map()) :: String.t() @spec map_label(map()) :: String.t()
def map_label(packet) do def map_label(packet) do
# Always return the sender for map labels data_type = get_packet_field(packet, :data_type, "")
get_packet_field(packet, :sender, "")
cond do
data_type == "object" ->
object_name = get_packet_field(packet, :object_name, "")
if object_name == "", do: get_packet_field(packet, :sender, ""), else: object_name
data_type == "item" ->
item_name = get_packet_field(packet, :item_name, "")
if item_name == "", do: get_packet_field(packet, :sender, ""), else: item_name
true ->
get_packet_field(packet, :sender, "")
end
end end
defp non_empty_string?(value) when is_binary(value), do: String.trim(value) != "" defp non_empty_string?(value) when is_binary(value), do: String.trim(value) != ""

View file

@ -27,9 +27,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_packet_data(packet, true) result = DataBuilder.build_packet_data(packet, true)
assert result assert result
# Map label shows sender for clarity # Map label shows object name for objects
assert result["callsign"] == "DB0SDA" assert result["callsign"] == "P-K5SGD"
# But grouping uses object name # Grouping also uses object name
assert result["callsign_group"] == "P-K5SGD" assert result["callsign_group"] == "P-K5SGD"
end end
@ -56,9 +56,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_packet_data(packet, true) result = DataBuilder.build_packet_data(packet, true)
assert result assert result
# Map label shows sender for clarity # Map label shows item name for items
assert result["callsign"] == "N0CALL" assert result["callsign"] == "REPEATER1"
# But grouping uses item name # Grouping also uses item name
assert result["callsign_group"] == "REPEATER1" assert result["callsign_group"] == "REPEATER1"
end end
@ -111,9 +111,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_packet_data(packet, true) result = DataBuilder.build_packet_data(packet, true)
# Popup now shows sender for consistency with map label # Popup now shows object name for objects
assert result["popup"] =~ "DB0SDA" assert result["popup"] =~ "P-K5SGD"
refute result["popup"] =~ "P-K5SGD" refute result["popup"] =~ "DB0SDA"
end end
test "build_minimal_packet_data uses sender for map label but object_name for grouping" do test "build_minimal_packet_data uses sender for map label but object_name for grouping" do
@ -139,13 +139,13 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_minimal_packet_data(packet, true, false) result = DataBuilder.build_minimal_packet_data(packet, true, false)
assert result assert result
# Map label shows sender for clarity # Map label shows object name for objects
assert result["callsign"] == "DB0SDA" assert result["callsign"] == "P-K5SGD"
# But grouping uses object name # Grouping also uses object name
assert result["callsign_group"] == "P-K5SGD" assert result["callsign_group"] == "P-K5SGD"
# Symbol HTML should show sender, not object name # Symbol HTML should show object name
assert result["symbol_html"] =~ "DB0SDA" assert result["symbol_html"] =~ "P-K5SGD"
refute result["symbol_html"] =~ "P-K5SGD" refute result["symbol_html"] =~ "DB0SDA"
end end
test "build_minimal_packet_data uses red dot HTML for historical (non-most-recent) packets" do test "build_minimal_packet_data uses red dot HTML for historical (non-most-recent) packets" do
@ -338,9 +338,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
results = DataBuilder.build_packet_data_list([object_packet_1, object_packet_2]) results = DataBuilder.build_packet_data_list([object_packet_1, object_packet_2])
# Map labels should show sender # Map labels should show object name
callsigns = Enum.map(results, & &1["callsign"]) callsigns = Enum.map(results, & &1["callsign"])
assert Enum.all?(callsigns, &(&1 == "DB0SDA")) assert Enum.all?(callsigns, &(&1 == "P-K5SGD"))
# But grouping should be by object name # But grouping should be by object name
groups = Enum.map(results, & &1["callsign_group"]) groups = Enum.map(results, & &1["callsign_group"])
@ -369,8 +369,8 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
popup = DataBuilder.build_simple_popup(packet, false) popup = DataBuilder.build_simple_popup(packet, false)
assert popup =~ "WA0YMH-2" assert popup =~ "X3234025"
refute popup =~ "X3234025" refute popup =~ "WA0YMH-2"
end end
end end
end end