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
46 lines
1.5 KiB
Elixir
46 lines
1.5 KiB
Elixir
defmodule Towerops.Repo.Migrations.CreateLidarTiles do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:lidar_tiles, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
add :source, :string, null: false
|
|
add :project_name, :string, null: false
|
|
add :tile_name, :string, null: false
|
|
add :year, :integer
|
|
add :resolution_m, :decimal, precision: 6, scale: 3
|
|
add :url, :text, null: false
|
|
add :crs, :string
|
|
add :file_size_bytes, :bigint
|
|
add :metadata, :map, default: %{}
|
|
add :last_verified_at, :utc_datetime
|
|
add :availability, :string, null: false, default: "available"
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
# PostGIS geometry column. AddGeometryColumn registers the column in
|
|
# geometry_columns metadata and applies SRID/type constraints.
|
|
execute(
|
|
"""
|
|
SELECT AddGeometryColumn('lidar_tiles', 'footprint', 4326, 'POLYGON', 2)
|
|
""",
|
|
"SELECT DropGeometryColumn('lidar_tiles', 'footprint')"
|
|
)
|
|
|
|
execute(
|
|
"ALTER TABLE lidar_tiles ALTER COLUMN footprint SET NOT NULL",
|
|
"ALTER TABLE lidar_tiles ALTER COLUMN footprint DROP NOT NULL"
|
|
)
|
|
|
|
create unique_index(:lidar_tiles, [:source, :project_name, :tile_name])
|
|
create index(:lidar_tiles, [:year])
|
|
create index(:lidar_tiles, [:availability])
|
|
|
|
# GiST index on footprint for fast spatial intersection queries.
|
|
execute(
|
|
"CREATE INDEX lidar_tiles_footprint_gist ON lidar_tiles USING gist (footprint)",
|
|
"DROP INDEX lidar_tiles_footprint_gist"
|
|
)
|
|
end
|
|
end
|