diff --git a/lib/aprsme_web/live/map_live/data_builder.ex b/lib/aprsme_web/live/map_live/data_builder.ex index c48dc45..2ed2d1c 100644 --- a/lib/aprsme_web/live/map_live/data_builder.ex +++ b/lib/aprsme_web/live/map_live/data_builder.ex @@ -64,7 +64,7 @@ defmodule AprsmeWeb.MapLive.DataBuilder do callsign = generate_callsign(packet) # Validate coordinates and callsign before building packet data - if valid_coordinates?(lat, lon) && callsign != "" && callsign != nil do + if valid_coordinates?(lat, lon) && callsign != "" do packet_data = build_packet_map(packet, to_float(lat), to_float(lon), data_extended, locale) Map.put(packet_data, "is_most_recent_for_callsign", is_most_recent_for_callsign) else @@ -161,15 +161,12 @@ defmodule AprsmeWeb.MapLive.DataBuilder do # Validate coordinates are numeric and within valid ranges @spec valid_coordinates?(any(), any()) :: boolean() defp valid_coordinates?(lat, lon) when is_number(lat) and is_number(lon) do - lat >= -90 and lat <= 90 and lon >= -180 and lon <= 180 and - is_finite(lat) and is_finite(lon) + # Range checks ensure finite values; infinity would be outside these ranges + lat >= -90 and lat <= 90 and lon >= -180 and lon <= 180 end defp valid_coordinates?(_, _), do: false - defp is_finite(n) when is_float(n), do: n != :infinity and n != :neg_infinity - defp is_finite(n) when is_integer(n), do: true - @doc """ Build packet data list for historical display. Moved from historical_loader.ex. @@ -525,8 +522,6 @@ defmodule AprsmeWeb.MapLive.DataBuilder do _ -> false end - defp has_weather_packets?(_), do: false - @spec convert_tuples_to_strings(any()) :: any() defp convert_tuples_to_strings(map) when is_map(map) do # Avoid processing structs entirely diff --git a/lib/aprsme_web/live/map_live/historical_loader.ex b/lib/aprsme_web/live/map_live/historical_loader.ex index a603d09..c445251 100644 --- a/lib/aprsme_web/live/map_live/historical_loader.ex +++ b/lib/aprsme_web/live/map_live/historical_loader.ex @@ -445,14 +445,11 @@ defmodule AprsmeWeb.MapLive.HistoricalLoader do socket end - defp is_finite(n) when is_float(n), do: n != :infinity and n != :neg_infinity - defp is_finite(n) when is_integer(n), do: true - defp packet_has_valid_coordinates?(packet) do {lat, lon, _} = CoordinateUtils.get_coordinates(packet) + # Range checks ensure finite values; infinity would be outside these ranges is_number(lat) and is_number(lon) and - lat >= -90 and lat <= 90 and lon >= -180 and lon <= 180 and - is_finite(lat) and is_finite(lon) + lat >= -90 and lat <= 90 and lon >= -180 and lon <= 180 end end