Terrain_MBtiles/merge_tiles.sh
Fabio Micheluz acf5948fdb first commit
2026-02-08 15:56:14 +01:00

35 lines
898 B
Bash
Executable file

#!/bin/zsh
SRC_ROOT="tiles_italy_new"
DST_ROOT="merged_tiles"
mkdir -p "$DST_ROOT"
echo "[INFO] Merge tiles da $SRC_ROOT$DST_ROOT"
# Scorri tutte le tile z/x/y.png in tutte le sottocartelle
find "$SRC_ROOT" -type f -name '*.png' | while read -r TILE; do
# TILE = tiles_italy_new/<DEM>/<z>/<x>/<y>.png
REL="${TILE#$SRC_ROOT/}" # <DEM>/<z>/<x>/<y>.png
DEM="${REL%%/*}" # <DEM>
REST="${REL#*/}" # <z>/<x>/<y>.png
Z="$(echo "$REST" | cut -d'/' -f1)"
X="$(echo "$REST" | cut -d'/' -f2)"
Y_FILE="$(echo "$REST" | cut -d'/' -f3)"
OUT_DIR="$DST_ROOT/$Z/$X"
OUT_PATH="$OUT_DIR/$Y_FILE"
mkdir -p "$OUT_DIR"
if [ -f "$OUT_PATH" ]; then
echo "[WARN] Tile già esistente, lascio la prima:
$OUT_PATH"
continue
fi
cp "$TILE" "$OUT_PATH"
done
echo "[INFO] Merge completato in $DST_ROOT"