Move setup/download helpers into scripts/ and update paths

This commit is contained in:
2025-12-15 21:51:39 +01:00
parent 928647d4b6
commit 96734b3c02
6 changed files with 64 additions and 10 deletions

3
.gitignore vendored
View File

@@ -43,13 +43,10 @@ export_unity/buildings_obj/
raw/**
!raw/dop20/
raw/dop20/**
!raw/dop20/dlscript.sh
!raw/dop20/filelist.txt
raw/dop20/jp2/**
!raw/dop/
raw/dop/**
!raw/dop/dlscript.sh
!raw/dop/filelist.txt
raw/dop/jp2/**
archives/

View File

@@ -9,9 +9,9 @@
## Build, Test, and Development Commands
- Create a venv: `uv venv && source .venv/bin/activate`. Install deps: `uv sync` (generates `uv.lock`).
- If wheels fail, install system GDAL first (e.g., `brew install gdal` or `apt-get install gdal-bin libgdal-dev`), then rerun `uv sync`.
- Prepare the directory tree (raw/archives/work/exports): `bash setup_dirs.sh`.
- Prepare the directory tree (raw/archives/work/exports): `bash scripts/setup_dirs.sh`.
- Heightmap export (rebuilds VRT if absent): `uv run python export_heightmaps.py`.
- Orthophoto export: `uv run python export_ortho_tiles.py` (requires JP2s under `raw/dop20/jp2/`; alt `raw/dop/jp2/` and legacy `raw_dop/jp2/` still work).
- Orthophoto export: `uv run python export_ortho_tiles.py` (requires JP2s under `raw/dop20/jp2/`; alt `raw/dop/jp2/` and legacy `raw_dop/jp2/` still work). Use `bash scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML listed in `raw/dop20/filelist.txt`.
- Refresh VRT manually if needed: `gdalbuildvrt work/dgm.vrt raw/dgm1/*.tif` (legacy: `raw_dgm1/*.tif`).
- Inspect a result: `gdalinfo export_unity/height_png16/<tile>.png | head` to sanity-check bounds and scaling.
- Expected warning: `Computed -srcwin ... falls partially outside source raster extent` means the DOP coverage is slightly smaller than the tile footprint; edge pixels will be filled with NoData/zeros. Add adjacent JP2s or shrink the requested window if you need to silence it.

View File

@@ -12,7 +12,7 @@ This repository converts DGM1 elevation tiles into Unity-ready 16-bit PNG height
- Create a project venv: `uv venv && source .venv/bin/activate`.
- Install dependencies from `pyproject.toml`: `uv sync` (generates `uv.lock`; warning-free with dependency-groups).
- If wheels fail to resolve, ensure system GDAL is present (e.g., `brew install gdal` or `apt-get install gdal-bin libgdal-dev`), then rerun `uv sync`.
- Create the default directory tree (inputs/archives/outputs): `bash setup_dirs.sh`.
- Create the default directory tree (inputs/archives/outputs): `bash scripts/setup_dirs.sh`.
### Repository Layout
- `raw/` — preferred working inputs (not versioned): `raw/dgm1/`, `raw/dop20/jp2/` (or `raw/dop/jp2/`), `raw/citygml/lod1/`, `raw/citygml/lod2/`. Legacy directories (`raw_dgm1/`, `raw_dop/`, `raw_3dgeb_lod1/`, `raw_3dgeb_lod2/`) are still honored by the scripts.
@@ -27,11 +27,12 @@ This repository converts DGM1 elevation tiles into Unity-ready 16-bit PNG height
### Quick Start
1. Activate the uv venv (`source .venv/bin/activate`) or prefix commands with `uv run`.
2. Export Unity heightmaps and manifest (builds `work/dgm.vrt` automatically if missing):
2. Ensure directory tree exists: `bash scripts/setup_dirs.sh`.
3. Export Unity heightmaps and manifest (builds `work/dgm.vrt` automatically if missing):
```bash
uv run python export_heightmaps.py
```
3. Import the PNGs into Unity Terrains using `tile_index.csv` for placement and consistent height scaling (065535).
4. Import the PNGs into Unity Terrains using `tile_index.csv` for placement and consistent height scaling (065535).
### Key Commands
- Refresh VRT: `gdalbuildvrt work/dgm.vrt raw/dgm1/*.tif` (legacy: `raw_dgm1/*.tif`)
@@ -48,7 +49,7 @@ This repository converts DGM1 elevation tiles into Unity-ready 16-bit PNG height
- Handoff to Unity: copy/sync `export_unity/height_png16/` and `export_unity/tile_index.csv` into `DTrierFlood/Assets/GeoData/` before running the Unity-side importer. Keep `OUT_RES` aligned with the importers expected resolution (currently 1025).
### Orthophotos (textures)
1. Ensure DOP JP2s are present in `raw/dop20/jp2/` (alt: `raw/dop/jp2/`, legacy: `raw_dop/jp2/`); use `raw/dop20/dlscript.sh` to fetch JP2/J2W/XML entries listed in `filelist.txt` (one URL per line).
1. Ensure DOP JP2s are present in `raw/dop20/jp2/` (alt: `raw/dop/jp2/`, legacy: `raw_dop/jp2/`); use `scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML entries listed in `raw/dop20/filelist.txt` (one URL per line).
2. From `GeoData/`, run:
```bash
uv run python export_ortho_tiles.py

View File

@@ -53,7 +53,7 @@ def export_orthos(args: argparse.Namespace) -> int:
jp2_paths = sorted(glob.glob(os.path.join(raw_ortho_dir, "*.jp2")))
if not jp2_paths:
raise SystemExit(
f"No JP2 files found in {raw_ortho_dir}. Run raw/dop20/dlscript.sh (or raw/dop/dlscript.sh, legacy raw_dop/dlscript.sh) first."
f"No JP2 files found in {raw_ortho_dir}. Run scripts/dlscript_dop20.sh (or use the fallback layouts) first."
)
build_vrt(args.vrt_path, jp2_paths)

29
scripts/dlscript_dop20.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Download DOP20 assets (JP2/J2W/XML) listed line-by-line in raw/dop20/filelist.txt.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
DOP_ROOT="$ROOT/raw/dop20"
LIST="${LIST:-$DOP_ROOT/filelist.txt}"
OUT="$DOP_ROOT/jp2"
if [[ ! -f "$LIST" ]]; then
echo "Missing filelist: $LIST" >&2
exit 1
fi
mkdir -p "$OUT"
while IFS= read -r url; do
[[ -z "$url" || "$url" =~ ^# ]] && continue
fname="${url##*/}"
dest="$OUT/$fname"
if [[ -f "$dest" ]]; then
echo "Exists: $fname"
continue
fi
echo "Downloading $fname"
curl -fL "$url" -o "$dest"
done < "$LIST"
echo "Done. Files in $OUT"

27
scripts/setup_dirs.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
# Create the default directory layout for GeoData inputs/outputs.
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
DIRS=(
"$ROOT/raw/dgm1"
"$ROOT/raw/dop20/jp2"
"$ROOT/raw/dop/jp2"
"$ROOT/raw/citygml/lod1"
"$ROOT/raw/citygml/lod2"
"$ROOT/archives/dgm1"
"$ROOT/archives/dop20"
"$ROOT/archives/citygml/lod1"
"$ROOT/archives/citygml/lod2"
"$ROOT/work"
"$ROOT/export_unity/height_png16"
"$ROOT/export_unity/ortho_jpg"
)
for dir in "${DIRS[@]}"; do
mkdir -p "$dir"
done
echo "Created default directories:"
printf ' - %s\n' "${DIRS[@]}"