towerops/test/support/lidar_fake_parser.ex
Graham McIntire 158ee9d323 feat: add Texas LIDAR DEM catalog with on-demand elevation reads
Catalog-only system for LIDAR-derived 1m DEMs covering Texas. We do not
mirror raster data — the DB stores tile metadata (URL + footprint
geometry) and elevation values are streamed on-demand from public USGS
3DEP / TNRIS Cloud-Optimized GeoTIFFs via GDAL /vsicurl/ HTTP byte-range
reads. Used for future tower coverage line-of-sight calculations.

- Enable PostGIS extension; tile footprints indexed via GiST
- Catalog sync from USGS 3DEP (primary) and TNRIS (fallback for gaps)
- Tile dedup by ST_Contains so TNRIS doesn't duplicate 3DEP coverage
- Single-point reads via gdallocationinfo with tile fallthrough on nodata
- Grid retrieval via gdal_translate AAIGrid with multi-tile mosaicing
- Monthly Oban cron worker keeps catalog fresh
- gdal-bin added to runtime image; geo_postgis dep added
2026-05-04 13:03:28 -05:00

39 lines
975 B
Elixir

defmodule Towerops.Lidar.Test.FakeParser do
@moduledoc """
Test-only stand-in for `Towerops.Lidar.Sources.ThreeDep.GdalParser`.
Tests configure canned tile responses per project name via `put_state/1`,
which are stored in an ETS table so the parser process can be the test
process or any Oban-spawned worker.
"""
@table :lidar_catalog_fake_parser
def put_state(map) do
ensure_table()
:ets.insert(@table, {:state, map})
end
def enumerate(project_name, _opts) do
ensure_table()
case :ets.lookup(@table, :state) do
[{:state, map}] ->
case Map.fetch(map, project_name) do
{:ok, {:error, _} = err} -> err
{:ok, tiles} -> {:ok, tiles}
:error -> {:error, :unknown_project}
end
_ ->
{:error, :no_state}
end
end
defp ensure_table do
case :ets.info(@table) do
:undefined -> :ets.new(@table, [:named_table, :public, :set])
_ -> @table
end
end
end