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 """
Get the map label for a packet.
For map display, always show the sender callsign regardless of whether
it's an object or item packet. This avoids confusion where the map label
shows something different from what the user expects (like a balloon ID
instead of the station callsign).
For objects and items, show the object/item name to distinguish them from
the station that created them. For example, a repeater object should show
the repeater name, not the station that's reporting it.
If the packet is an object or item, you can append the object/item name
in the popup or detail view.
For position packets, show the sender callsign.
"""
@spec map_label(map()) :: String.t()
def map_label(packet) do
# Always return the sender for map labels
get_packet_field(packet, :sender, "")
data_type = get_packet_field(packet, :data_type, "")
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
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)
assert result
# Map label shows sender for clarity
assert result["callsign"] == "DB0SDA"
# But grouping uses object name
# Map label shows object name for objects
assert result["callsign"] == "P-K5SGD"
# Grouping also uses object name
assert result["callsign_group"] == "P-K5SGD"
end
@ -56,9 +56,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_packet_data(packet, true)
assert result
# Map label shows sender for clarity
assert result["callsign"] == "N0CALL"
# But grouping uses item name
# Map label shows item name for items
assert result["callsign"] == "REPEATER1"
# Grouping also uses item name
assert result["callsign_group"] == "REPEATER1"
end
@ -111,9 +111,9 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
result = DataBuilder.build_packet_data(packet, true)
# Popup now shows sender for consistency with map label
assert result["popup"] =~ "DB0SDA"
refute result["popup"] =~ "P-K5SGD"
# Popup now shows object name for objects
assert result["popup"] =~ "P-K5SGD"
refute result["popup"] =~ "DB0SDA"
end
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)
assert result
# Map label shows sender for clarity
assert result["callsign"] == "DB0SDA"
# But grouping uses object name
# Map label shows object name for objects
assert result["callsign"] == "P-K5SGD"
# Grouping also uses object name
assert result["callsign_group"] == "P-K5SGD"
# Symbol HTML should show sender, not object name
assert result["symbol_html"] =~ "DB0SDA"
refute result["symbol_html"] =~ "P-K5SGD"
# Symbol HTML should show object name
assert result["symbol_html"] =~ "P-K5SGD"
refute result["symbol_html"] =~ "DB0SDA"
end
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])
# Map labels should show sender
# Map labels should show object name
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
groups = Enum.map(results, & &1["callsign_group"])
@ -369,8 +369,8 @@ defmodule AprsmeWeb.MapLive.DataBuilderTest do
popup = DataBuilder.build_simple_popup(packet, false)
assert popup =~ "WA0YMH-2"
refute popup =~ "X3234025"
assert popup =~ "X3234025"
refute popup =~ "WA0YMH-2"
end
end
end