Phase 2/3/5 of the building-blockage support: * Parser streams csv.gz tiles into compact records (centroid, radius, height) — keeps RAM ~32 B per polygon, drops -1.0-height entries. * Index buckets records into 0.01° (~1 km) grid cells in a public ETS table for concurrent reads; max_height_near/3 and records_near/3 scan only the 9 nearest buckets. * Loader lazily parses any cached quadkey before a Calculate so the scorer is terrain-only when tiles aren't on disk yet. * Rover.PathTerrain now treats each path-sample obstacle as terrain_elev + max_local_building_height, so blocked LOS through recent construction actually reduces clearance. * Selecting a candidate pushes a candidate_buildings event with the buildings near each rover→station path; the hook renders them as height-coloured circles (yellow <10 m, orange 10-30 m, red >=30 m) with a tooltip showing height in meters.
33 lines
1.1 KiB
Elixir
33 lines
1.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
|
|
end
|