From e3248e335ba102adf7273c31afe0fe395e8eb5ea Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 18 Apr 2026 13:50:53 -0500 Subject: [PATCH] revert(map): remove antenna-height control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The antenna-height input only scaled the displayed range labels and the viewshed max-range — it never fed into the propagation score itself. Showing the control implied the colored overlay responded to it, which was misleading. Viewshed now uses a fixed 10 m baseline, matching the previous 33 ft default. --- lib/microwaveprop_web/live/map_live.ex | 102 +++--------------- test/microwaveprop_web/live/map_live_test.exs | 30 ------ 2 files changed, 17 insertions(+), 115 deletions(-) diff --git a/lib/microwaveprop_web/live/map_live.ex b/lib/microwaveprop_web/live/map_live.ex index 54467ada..b770b8cb 100644 --- a/lib/microwaveprop_web/live/map_live.ex +++ b/lib/microwaveprop_web/live/map_live.ex @@ -87,7 +87,6 @@ defmodule MicrowavepropWeb.MapLive do outside_conus: outside_conus?(visitor), grid_visible: false, radar_visible: false, - antenna_height_ft: 33, deploy_iso: Calendar.strftime(build_ts, "%Y-%m-%d %H:%M UTC"), deploy_ago: format_deploy_ago(build_ts) )} @@ -159,9 +158,7 @@ defmodule MicrowavepropWeb.MapLive do |> assign(selected_band: band, valid_times: valid_times, selected_time: selected_time) |> LiveStash.stash_assigns([:selected_band, :selected_time]) |> push_event("update_scores", %{scores: scores}) - |> push_event("update_band_info", %{ - band_info: band_info(band, socket.assigns.antenna_height_ft) - }) + |> push_event("update_band_info", %{band_info: band_info(band)}) |> push_timeline() {:noreply, socket} @@ -194,23 +191,6 @@ defmodule MicrowavepropWeb.MapLive do end end - def handle_event("set_antenna_height", %{"height_ft" => value}, socket) do - height = - case Integer.parse(value) do - {h, _} when h >= 0 and h <= 200 -> h - _ -> 8 - end - - socket = - socket - |> assign(:antenna_height_ft, height) - |> push_event("update_band_info", %{ - band_info: band_info(socket.assigns.selected_band, height) - }) - - {:noreply, socket} - end - def handle_event("toggle_grid", _params, socket) do visible = !socket.assigns.grid_visible @@ -275,7 +255,6 @@ defmodule MicrowavepropWeb.MapLive do band_mhz = socket.assigns.selected_band band_config = BandConfig.get(band_mhz) freq_ghz = band_mhz / 1_000 - ant_height_m = socket.assigns.antenna_height_ft * 0.3048 score = case Propagation.point_detail(band_mhz, lat, lon) do @@ -283,13 +262,13 @@ defmodule MicrowavepropWeb.MapLive do _ -> 50 end - max_range_km = score_range_km(score, band_config, socket.assigns.antenna_height_ft) + max_range_km = score_range_km(score, band_config) socket = start_async(socket, :viewshed, fn -> Viewshed.compute(lat, lon, freq_ghz: freq_ghz, - ant_height_m: ant_height_m, + ant_height_m: 10.0, max_range_km: max_range_km, score: score ) @@ -442,47 +421,29 @@ defmodule MicrowavepropWeb.MapLive do Enum.min_by(times, fn t -> abs(DateTime.diff(t, now)) end) end - defp score_range_km(score, config, ant_height_ft) do - factor = height_factor(ant_height_ft) - - base = - cond do - score >= 80 -> config.exceptional_range_km - score >= 65 -> config.extended_range_km - score >= 50 -> config.typical_range_km - score >= 33 -> round(config.typical_range_km * 0.6) - true -> round(config.typical_range_km * 0.3) - end - - round(base * factor) + defp score_range_km(score, config) do + cond do + score >= 80 -> config.exceptional_range_km + score >= 65 -> config.extended_range_km + score >= 50 -> config.typical_range_km + score >= 33 -> round(config.typical_range_km * 0.6) + true -> round(config.typical_range_km * 0.3) + end end - defp band_info(band_mhz, ant_height_ft) do + defp band_info(band_mhz) do config = BandConfig.get(band_mhz) - factor = height_factor(ant_height_ft) %{ band_label: config.label, - typical_range_km: round(config.typical_range_km * factor), - extended_range_km: round(config.extended_range_km * factor), - exceptional_range_km: round(config.exceptional_range_km * factor), + typical_range_km: config.typical_range_km, + extended_range_km: config.extended_range_km, + exceptional_range_km: config.exceptional_range_km, humidity_effect: to_string(config.humidity_effect), - freq_mhz: config.freq_mhz, - antenna_height_ft: ant_height_ft + freq_mhz: config.freq_mhz } end - # Scales effective range with antenna height. Baseline 33 ft (~10 m) = 1.0; - # scales as sqrt(h_m / 10) because radio horizon scales as sqrt(height). - # Clamped to [0.6, 2.0] to avoid silly extremes at 0 ft and very tall towers. - defp height_factor(ant_height_ft) when is_number(ant_height_ft) do - h_m = max(ant_height_ft, 3) * 0.3048 - factor = :math.sqrt(h_m / 10.0) - factor |> max(0.6) |> min(2.0) - end - - defp height_factor(_), do: 1.0 - defp selected_label(bands, selected_band) do case Enum.find(bands, &(&1.freq_mhz == selected_band)) do nil -> "Select Band" @@ -582,7 +543,7 @@ defmodule MicrowavepropWeb.MapLive do phx-hook="PropagationMap" phx-update="ignore" data-scores={@initial_scores_json} - data-band-info={Jason.encode!(band_info(@selected_band, @antenna_height_ft))} + data-band-info={Jason.encode!(band_info(@selected_band))} data-valid-times={ Jason.encode!( Enum.map(@valid_times, fn t -> @@ -689,20 +650,6 @@ defmodule MicrowavepropWeb.MapLive do Weather radar -
- - - ft -
-
<.link navigate="/path" class="btn btn-xs btn-ghost justify-start"> Path Calculator @@ -844,21 +791,6 @@ defmodule MicrowavepropWeb.MapLive do Weather radar - <%!-- Antenna height --%> -
- - - ft -
- <%!-- Navigation --%>