Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 4m38s
- F-level (228): replace length/1 with Enum.count_until/2 or pattern matching; convert Enum.flat_map+if to Enum.filter+Enum.map; fix identity case in narr_client - W-level (46): normalize dual atom/string key access in weather_layers, beacon_measurements, surface, skewt_live, contact_live/show; add :data_provider and weather-map assigns to ignored_assigns in credo config (consumed by child components credo can't trace); remove weak is_list assertion; remove explicit assert_receive timeout - R-level (6): replace 'This module provides...' moduledocs with meaningful descriptions - Also fix 4 compile-connected xref issues by deferring BandConfig.band_options() from module attribute to runtime Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
2.1 KiB
Elixir
64 lines
2.1 KiB
Elixir
defmodule Microwaveprop.Buildings.IndexTest do
|
|
use ExUnit.Case, async: false
|
|
|
|
alias Microwaveprop.Buildings.Index
|
|
|
|
setup do
|
|
Index.clear()
|
|
:ok
|
|
end
|
|
|
|
test "max_height_near/3 returns 0 when no buildings have been indexed" do
|
|
assert Index.max_height_near(32.8, -97.0, 100) == 0.0
|
|
end
|
|
|
|
test "insert_records/1 then max_height_near/3 returns the tallest nearby height" do
|
|
Index.insert_records([
|
|
%{centroid_lat: 32.8000, centroid_lon: -97.0000, max_radius_m: 10.0, height_m: 8.0},
|
|
%{centroid_lat: 32.8001, centroid_lon: -97.0001, max_radius_m: 10.0, height_m: 25.0},
|
|
# Far away — should not be considered.
|
|
%{centroid_lat: 33.0, centroid_lon: -97.5, max_radius_m: 10.0, height_m: 100.0}
|
|
])
|
|
|
|
assert Index.max_height_near(32.8000, -97.0000, 50) == 25.0
|
|
end
|
|
|
|
test "max_height_near/3 returns 0 when buildings are outside the radius" do
|
|
Index.insert_records([
|
|
%{centroid_lat: 32.8500, centroid_lon: -97.0500, max_radius_m: 10.0, height_m: 50.0}
|
|
])
|
|
|
|
assert Index.max_height_near(32.8000, -97.0000, 100) == 0.0
|
|
end
|
|
|
|
test "records_near/3 returns matching records" do
|
|
Index.insert_records([
|
|
%{centroid_lat: 32.8000, centroid_lon: -97.0000, max_radius_m: 10.0, height_m: 8.0},
|
|
%{centroid_lat: 32.8001, centroid_lon: -97.0001, max_radius_m: 10.0, height_m: 25.0}
|
|
])
|
|
|
|
records = Index.records_near(32.8000, -97.0000, 50)
|
|
assert Enum.count_until(records, 3) == 2
|
|
heights = records |> Enum.map(& &1.height_m) |> Enum.sort()
|
|
assert heights == [8.0, 25.0]
|
|
end
|
|
|
|
test "records_near/3 returns empty list outside radius" do
|
|
Index.insert_records([
|
|
%{centroid_lat: 33.0, centroid_lon: -97.5, max_radius_m: 10.0, height_m: 50.0}
|
|
])
|
|
|
|
assert Index.records_near(32.8, -97.0, 100) == []
|
|
end
|
|
|
|
test "mark_loaded/1 and loaded?/1 track loaded quadkeys" do
|
|
refute Index.loaded?("023112330")
|
|
Index.mark_loaded("023112330")
|
|
assert Index.loaded?("023112330")
|
|
end
|
|
|
|
test "insert_records/1 handles empty list" do
|
|
Index.insert_records([])
|
|
assert Index.max_height_near(32.8, -97.0, 100) == 0.0
|
|
end
|
|
end
|