diff --git a/.dialyzer_ignore.exs b/.dialyzer_ignore.exs index d86b1ed..fe51488 100644 --- a/.dialyzer_ignore.exs +++ b/.dialyzer_ignore.exs @@ -1,6 +1 @@ -[ - {{"lib/parser.ex", 1}, :pattern_match, "The pattern can never match the type."}, - {{"lib/parser.ex", 893}, :pattern_match, "The pattern can never match the type."}, - {{"lib/parser.ex", 324}, :pattern_match_cov, - "The pattern :variable_ can never match, because previous clauses completely cover the type {:error, <<_::224>>}."} -] +[] diff --git a/lib/aprs_web/live/map_live/index.ex b/lib/aprs_web/live/map_live/index.ex index c2f9389..9f8237f 100644 --- a/lib/aprs_web/live/map_live/index.ex +++ b/lib/aprs_web/live/map_live/index.ex @@ -1154,7 +1154,7 @@ defmodule AprsWeb.MapLive.Index do {lat1, lng1, _} = MapHelpers.get_coordinates(packet1) {lat2, lng2, _} = MapHelpers.get_coordinates(packet2) - abs(lat1 - lat2) > 0.00001 || abs(lng1 - lng2) > 0.00001 + abs(lat1 - lat2) > 0.0001 || abs(lng1 - lng2) > 0.0001 end # Fetch historical packets from the database diff --git a/lib/aprs_web/live/packets_live/index.html.heex b/lib/aprs_web/live/packets_live/index.html.heex index 8dc8b8f..222d95c 100644 --- a/lib/aprs_web/live/packets_live/index.html.heex +++ b/lib/aprs_web/live/packets_live/index.html.heex @@ -59,7 +59,7 @@ %{} = data_ext -> Map.get(data_ext, :latitude) || Map.get(data_ext, "latitude") _ -> nil end %> - {if lat, + {if not is_nil(lat), do: (is_float(lat) and :io_lib.format("~.6f", [lat]) |> List.to_string()) or (is_binary(lat) and Regex.replace(~r/(\d+\.\d{1,6})\d*/, lat, "\\1")) or lat, @@ -80,7 +80,7 @@ %{} = data_ext -> Map.get(data_ext, :longitude) || Map.get(data_ext, "longitude") _ -> nil end %> - {if lon, + {if not is_nil(lon), do: (is_float(lon) and :io_lib.format("~.6f", [lon]) |> List.to_string()) or (is_binary(lon) and Regex.replace(~r/(\d+\.\d{1,6})\d*/, lon, "\\1")) or lon, diff --git a/lib/parser.ex b/lib/parser.ex index a3b832f..4c121b1 100644 --- a/lib/parser.ex +++ b/lib/parser.ex @@ -58,6 +58,7 @@ defmodule Parser do def parse(_), do: {:error, :invalid_packet} + @spec do_parse(String.t()) :: parse_result() defp do_parse(message) do with {:ok, [sender, path, data]} <- split_packet(message), {:ok, callsign_parts} <- parse_callsign(sender), @@ -101,12 +102,6 @@ defmodule Parser do data_extended: data_extended, received_at: DateTime.truncate(DateTime.utc_now(), :microsecond) }} - else - {:error, reason} when is_binary(reason) -> - case reason do - "Invalid packet format" -> {:error, "Invalid packet format"} - _ -> {:error, reason} - end end rescue _ -> @@ -288,7 +283,7 @@ defmodule Parser do def parse_data(:raw_gps_ultimeter, _destination, data) do case Parser.Helpers.parse_nmea_sentence(data) do - {:error, error} when is_binary(error) -> + {:error, error} -> %{ data_type: :raw_gps_ultimeter, error: error, @@ -297,16 +292,6 @@ defmodule Parser do latitude: nil, longitude: nil } - - _ -> - %{ - data_type: :raw_gps_ultimeter, - error: "Invalid NMEA sentence", - nmea_type: nil, - raw_data: data, - latitude: nil, - longitude: nil - } end end diff --git a/test/parser/ax25_test.exs b/test/parser/ax25_test.exs index 46024b0..3d865db 100644 --- a/test/parser/ax25_test.exs +++ b/test/parser/ax25_test.exs @@ -9,6 +9,10 @@ defmodule Parser.AX25Test do assert {:ok, {"CALL", "1"}} = AX25.parse_callsign("CALL-1") end + test "parses callsign with multiple dashes" do + assert {:ok, {"CALL-1-EXTRA", "0"}} = AX25.parse_callsign("CALL-1-EXTRA") + end + test "parses callsign without dash" do assert {:ok, {"CALL", "0"}} = AX25.parse_callsign("CALL") end