defmodule Microwaveprop.Buildings.MsFootprintsTest do use ExUnit.Case, async: true alias Microwaveprop.Buildings.MsFootprints describe "quadkey/3" do test "encodes a known DFW point at zoom 9" do # (32.8, -97.0) — urban DFW — lies inside MS quadkey 023112330 at # zoom 9, cross-checked against the published dataset index where # 023112330 is the 109 MB tile covering the metro core. assert MsFootprints.quadkey(32.8, -97.0, 9) == "023112330" # A polygon sampled directly from the 023112322 csv.gz file # (lat 32.221708, lon -97.736116) confirms that tile's footprint. assert MsFootprints.quadkey(32.221708, -97.736116, 9) == "023112322" end test "Greenwich at zoom 1 hits root quadrants" do assert MsFootprints.quadkey(0.5, 0.5, 1) == "1" assert MsFootprints.quadkey(-0.5, -0.5, 1) == "2" end end describe "quadkeys_for_bbox/2" do test "returns the cell containing a point and immediate neighbors at zoom 9" do # Bbox covering ~80 km around DFW should span 4-9 zoom-9 quadkeys. bbox = %{"south" => 32.0, "north" => 33.5, "west" => -97.8, "east" => -96.4} keys = MsFootprints.quadkeys_for_bbox(bbox, 9) assert is_list(keys) assert length(keys) > 1 assert "023112330" in keys end end end