auto-sync: 2026-05-13 10:10:01

This commit is contained in:
Stream
2026-05-13 10:10:08 +03:00
parent 46bd700a7c
commit 9136f34204

View File

@@ -0,0 +1,90 @@
#!/bin/bash
set -e
echo '=== FULL HYPSO GENERATION ==='
echo "Start: $(date)"
SRTM_DIR='/home/slin/enduro-trails/data/srtm'
TERRAIN_DIR='/home/slin/enduro-trails/data/terrain'
HYPSO_DIR="${TERRAIN_DIR}/hypso"
TMP='/tmp/hypso_full_gen'
rm -rf $TMP
mkdir -p $TMP
echo ''
echo '=== Step 1: Remove old empty hypso tiles ==='
rm -rf ${HYPSO_DIR}
mkdir -p ${HYPSO_DIR}
echo 'Old tiles removed'
echo ''
echo '=== Step 2: Build VRT from all HGT files ==='
find $SRTM_DIR -name '*.hgt' > $TMP/file_list.txt
gdalbuildvrt -vrtnodata -32768 -overwrite -input_file_list $TMP/file_list.txt $TMP/srtm_all.vrt 2>&1
echo 'VRT built'
gdalinfo -stats $TMP/srtm_all.vrt 2>&1 | grep STATISTICS
echo "HGT files: $(wc -l < $TMP/file_list.txt)"
echo ''
echo '=== Step 3: Generate color-relief GeoTIFF ==='
cat > $TMP/color_ramp.txt << 'EOF'
nv 0 0 0 0
-100 0 0 0 0
0 0 0 0 0
1 57 151 105 255
50 80 165 110 255
100 120 180 100 255
150 160 190 95 255
200 139 176 96 255
300 170 185 105 255
500 189 188 115 255
700 210 200 130 255
1000 220 206 148 255
1500 235 220 175 255
2000 210 185 140 255
2500 185 152 110 255
3000 160 120 80 255
4000 120 80 40 255
5000 200 200 200 255
EOF
gdaldem color-relief \
$TMP/srtm_all.vrt \
$TMP/color_ramp.txt \
$TMP/hypso_full.tif \
-alpha \
-of GTiff \
-co COMPRESS=LZW \
-co BIGTIFF=YES 2>&1
echo 'Hypso GeoTIFF done:'
gdalinfo -stats $TMP/hypso_full.tif 2>&1 | grep STATISTICS_MAX
du -sh $TMP/hypso_full.tif
echo ''
echo '=== Step 4: Generate tiles (zoom 5-12, 4 processes) ==='
gdal2tiles.py \
--zoom=5-12 \
--processes=4 \
--tilesize=256 \
--webviewer=none \
$TMP/hypso_full.tif \
${HYPSO_DIR}/ 2>&1
echo ''
echo '=== Step 5: Stats ==='
for z in 5 6 7 8 9 10 11 12; do
total=$(find ${HYPSO_DIR}/$z/ -name '*.png' 2>/dev/null | wc -l)
nonempty=$(find ${HYPSO_DIR}/$z/ -name '*.png' -size +400c 2>/dev/null | wc -l)
echo " zoom $z: $total total, $nonempty non-empty"
done
echo ''
echo 'Total tiles:'
find ${HYPSO_DIR} -name '*.png' | wc -l
du -sh ${HYPSO_DIR}
echo ''
echo '=== DONE ==='
echo "End: $(date)"