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