prop/test/microwaveprop/buildings/ms_footprints_test.exs
Graham McIntire 5a97776fd5
feat(buildings): MS Global ML Building Footprints quadkey + tile fetcher
Phase 1 of building-blockage support: implements quadkey math (Bing/MS
tile encoding), looks up the MS dataset-links index for UnitedStates,
and downloads csv.gz quadkey tiles to /data/buildings (overridable via
:buildings_cache_dir). Index is cached 24h; tiles are written once and
reused. No path-analysis wiring yet — that's the next slice.
2026-04-26 10:33:25 -05:00

35 lines
1.3 KiB
Elixir

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