From 2c5260fb33a60dd885d51f4e98224fc104b2853b Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Mon, 15 Dec 2025 23:00:28 +0100 Subject: [PATCH] Make setup non-exporting and rename archive flag --- AGENTS.md | 4 ++-- README.md | 6 +++--- geodata_to_unity.py | 23 ++++++++++++++--------- scripts/dlscript_dop20.sh | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 27fdca3..14f3ae4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,10 +12,10 @@ - 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 and config: `uv run python geodata_to_unity.py --setup` (or `bash scripts/setup_dirs.sh` for directories only). - Heightmap export: `uv run python geodata_to_unity.py --export heightmap`. -- Orthophoto export: `uv run python geodata_to_unity.py --export textures` (requires JP2s under `raw/dop20/jp2/`; use `bash scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML listed in `raw/dop20/filelist.txt`). +- Orthophoto export: `uv run python geodata_to_unity.py --export textures` (requires JP2s under `raw/dop20/jp2/`; use `bash scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML listed in `archive/dop20/filelist.txt`). - Refresh VRT manually if needed: `gdalbuildvrt work/dgm.vrt raw/dgm1/*.tif`. - Inspect a result: `gdalinfo export_unity/height_png16/.png | head` to sanity-check bounds and scaling. -- Populate raw data from archives: `uv run python geodata_to_unity.py --use-archive --export all` (unzips `archive/*` and copies dop20 filelist). +- Populate raw data from archives: `uv run python geodata_to_unity.py --build-from-archive --export all` (unzips `archive/*`; dop20 filelist stays in archive for the downloader). - Rebuild VRTs after moving data: add `--force-vrt`. - 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. - Scripts accept CLI overrides (e.g., `--config`, `--raw-dgm1-path`, `--raw-dop20-path`, `--export`); run `uv run python geodata_to_unity.py -h` to see options. diff --git a/README.md b/README.md index bcdf5c0..72a173e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ This repository converts DGM1 elevation tiles into Unity-ready 16-bit PNG height - Run export pipeline: `uv run python geodata_to_unity.py --export all` - Inspect an output tile: `gdalinfo export_unity/height_png16/.png | head` - Override config paths: use `--config `, `--raw-dgm1-path `, `--raw-dop20-path `. -- Use archives to populate raws: `uv run python geodata_to_unity.py --use-archive --export all` (unzips `archive/*` and copies dop20 filelist). +- Build raws from archives: `uv run python geodata_to_unity.py --build-from-archive --export all` (unzips `archive/*`; dop20 filelist stays in `archive/dop20/` for the downloader). - Rebuild VRTs after moving data: add `--force-vrt`. ### Workflow Notes @@ -50,11 +50,11 @@ This repository converts DGM1 elevation tiles into Unity-ready 16-bit PNG height - `_tmp.tif` files in `work/` are transient; you can delete `work/` to force a clean rebuild. - Keep file names stable to avoid churn in Unity scenes; re-exports overwrite in place. - Large raw datasets are intentionally excluded from version control—document download sources or scripts instead of committing data. -- Additional inputs: download helper lives in `scripts/dlscript_dop20.sh` and pulls JP2/J2W/XML orthophotos listed in `raw/dop20/filelist.txt` (one URL per line); `archive/` can hold zipped 3D building tiles for future use. +- Additional inputs: download helper lives in `scripts/dlscript_dop20.sh` and pulls JP2/J2W/XML orthophotos listed in `archive/dop20/filelist.txt` (one URL per line); `archive/` can hold zipped 3D building tiles for future use. - 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 `heightmap.out_res` aligned with the importer’s expected resolution (currently 1025). ### Orthophotos (textures) -1. Ensure DOP JP2s are present in `raw/dop20/jp2/`; use `scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML entries listed in `raw/dop20/filelist.txt` (one URL per line). +1. Ensure DOP assets are present in `raw/dop20/jp2/`, `raw/dop20/j2w/`, and `raw/dop20/meta/`; use `scripts/dlscript_dop20.sh` to fetch JP2/J2W/XML entries listed in `archive/dop20/filelist.txt` (one URL per line). 2. From `GeoData/`, run: ```bash uv run python geodata_to_unity.py --export textures diff --git a/geodata_to_unity.py b/geodata_to_unity.py index 4fa4082..a928601 100644 --- a/geodata_to_unity.py +++ b/geodata_to_unity.py @@ -29,14 +29,14 @@ def parse_args(argv: Iterable[str] | None = None) -> argparse.Namespace: parser.add_argument("--raw-dgm1-path", dest="raw_dgm1_path", help="Override raw DGM1 directory.") parser.add_argument("--raw-dop20-path", dest="raw_dop20_path", help="Override raw DOP20 JP2 directory.") parser.add_argument( - "--use-archive", + "--build-from-archive", action="store_true", - help="Populate raw inputs from archives (unzips zips, copies dop20 filelist).", + help="Populate raw inputs from archives (unzips zips, leaves dop20 filelist in archive).", ) parser.add_argument( "--setup", action="store_true", - help="Create default directory structure and config if missing; still runs export unless --export is omitted.", + help="Create default directory structure and config if missing; does not export.", ) parser.add_argument( "--force-vrt", @@ -52,12 +52,15 @@ def parse_args(argv: Iterable[str] | None = None) -> argparse.Namespace: def load_config(args: argparse.Namespace) -> Config: - if args.setup and not os.path.exists(args.config): - cfg = ensure_default_config(args.config) + if args.setup: + cfg = Config.default() + cfg.save(args.config) + return cfg.with_overrides(raw_dgm1_path=args.raw_dgm1_path, raw_dop20_path=args.raw_dop20_path) + if os.path.exists(args.config): + cfg = Config.load(args.config) else: - cfg = ensure_default_config(args.config) if os.path.exists(args.config) else Config.default() - if not os.path.exists(args.config): - cfg.save(args.config) + cfg = Config.default() + cfg.save(args.config) return cfg.with_overrides(raw_dgm1_path=args.raw_dgm1_path, raw_dop20_path=args.raw_dop20_path) @@ -68,8 +71,10 @@ def main(argv: Iterable[str] | None = None) -> int: if args.setup: ensure_directories(cfg) print(f"Directories ensured. Config at {args.config}.") + if args.no_export or args.export is None: + return 0 - if args.use_archive: + if args.build_from_archive: materialize_archives(cfg) if args.no_export: diff --git a/scripts/dlscript_dop20.sh b/scripts/dlscript_dop20.sh index 9f05173..d357c50 100644 --- a/scripts/dlscript_dop20.sh +++ b/scripts/dlscript_dop20.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Download DOP20 assets (JP2/J2W/XML) listed line-by-line in raw/dop20/filelist.txt. +# Download DOP20 assets (JP2/J2W/XML) listed line-by-line in archive/dop20/filelist.txt. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"