From 1bc458fc2a476fb103525d6b3c78fc20f3f0849e Mon Sep 17 00:00:00 2001 From: Stream Date: Wed, 13 May 2026 12:20:17 +0300 Subject: [PATCH] auto-sync: 2026-05-13 12:20:01 --- tasks/enduro-trails/scripts/download_gap.sh | 38 +++++++++ .../enduro-trails/scripts/download_gap_v2.sh | 81 +++++++++++++++++++ .../scripts/download_missing_srtm.sh | 69 ++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 tasks/enduro-trails/scripts/download_gap.sh create mode 100644 tasks/enduro-trails/scripts/download_gap_v2.sh create mode 100644 tasks/enduro-trails/scripts/download_missing_srtm.sh diff --git a/tasks/enduro-trails/scripts/download_gap.sh b/tasks/enduro-trails/scripts/download_gap.sh new file mode 100644 index 0000000..d8a4a7e --- /dev/null +++ b/tasks/enduro-trails/scripts/download_gap.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +cd /home/slin/enduro-trails/data/srtm + +echo 'Missing files to download:' +for lat in 54 55 56; do + for lon in 041 042 043 044 045 046; do + f="N${lat}E${lon}.hgt" + if [ ! -f "$f" ]; then + echo " $f" + fi + done +done + +echo '' +echo 'Downloading missing...' +for lat in 54 55 56; do + for lon in 041 042 043 044 045 046; do + f="N${lat}E${lon}" + if [ ! -f "${f}.hgt" ]; then + wget -q "https://firmware.ardupilot.org/SRTM/ap_srtm3/${f}.hgt.zip" -O "/tmp/${f}.hgt.zip" 2>/dev/null + if [ -s "/tmp/${f}.hgt.zip" ]; then + unzip -o -q "/tmp/${f}.hgt.zip" -d . 2>/dev/null && echo " OK: ${f}" || echo " UNZIP FAIL: ${f}" + rm -f "/tmp/${f}.hgt.zip" + else + echo " NOT FOUND on ardupilot: ${f}" + rm -f "/tmp/${f}.hgt.zip" + fi + else + echo " EXISTS: ${f}" + fi + done +done + +echo '' +echo 'Total HGT files now:' +ls *.hgt | wc -l diff --git a/tasks/enduro-trails/scripts/download_gap_v2.sh b/tasks/enduro-trails/scripts/download_gap_v2.sh new file mode 100644 index 0000000..2ffaee3 --- /dev/null +++ b/tasks/enduro-trails/scripts/download_gap_v2.sh @@ -0,0 +1,81 @@ +#!/bin/bash +set -e + +cd /home/slin/enduro-trails/data/srtm + +echo 'Downloading missing SRTM tiles from multiple mirrors...' + +download_tile() { + local tile=$1 + local f="${tile}.hgt" + + if [ -f "$f" ]; then + echo " EXISTS: $f" + return 0 + fi + + # Mirror 1: USGS via e4ftl01 (SRTMGL3 - 3 arc-second, no auth for v003) + # Mirror 2: OpenData AWS terrain tiles + # Mirror 3: viewfinderpanoramas.org + + local lat_num=${tile:1:2} + local lon_num=${tile:4:3} + + # Try viewfinderpanoramas (grouped by lat band in zip) + # Individual files available at: http://viewfinderpanoramas.org/dem3/N55/N55E041.hgt.zip + local vfp_url="http://viewfinderpanoramas.org/dem3/${tile:0:3}/${tile}.hgt.zip" + wget -q --timeout=30 "$vfp_url" -O "/tmp/${tile}.zip" 2>/dev/null + if [ -s "/tmp/${tile}.zip" ]; then + unzip -o -q "/tmp/${tile}.zip" -d . 2>/dev/null + if [ -f "$f" ]; then + echo " OK (viewfinder): $f ($(du -h $f | cut -f1))" + rm -f "/tmp/${tile}.zip" + return 0 + fi + fi + rm -f "/tmp/${tile}.zip" + + # Try CGIAR SRTM v4 (5x5 degree tiles, different naming) + # Try direct NASA mirror + local nasa_url="https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL3.003/2000.02.11/${tile}.SRTMGL3.hgt.zip" + wget -q --timeout=30 "$nasa_url" -O "/tmp/${tile}.zip" 2>/dev/null + if [ -s "/tmp/${tile}.zip" ]; then + unzip -o -q "/tmp/${tile}.zip" -d . 2>/dev/null + if [ -f "$f" ]; then + echo " OK (nasa): $f ($(du -h $f | cut -f1))" + rm -f "/tmp/${tile}.zip" + return 0 + fi + fi + rm -f "/tmp/${tile}.zip" + + # Try sonny's mirror (reliable for SRTM3) + local sonny_url="https://srtm.kurviger.de/SRTM3/Eurasia/${tile}.hgt.zip" + wget -q --timeout=30 "$sonny_url" -O "/tmp/${tile}.zip" 2>/dev/null + if [ -s "/tmp/${tile}.zip" ]; then + unzip -o -q "/tmp/${tile}.zip" -d . 2>/dev/null + if [ -f "$f" ]; then + echo " OK (kurviger): $f ($(du -h $f | cut -f1))" + rm -f "/tmp/${tile}.zip" + return 0 + fi + fi + rm -f "/tmp/${tile}.zip" + + echo " FAIL: $tile (all mirrors failed)" + return 1 +} + +# Clean up stale downloads +rm -f /tmp/N*.hgt.zip + +for lat in 54 55 56; do + for lon in 041 042 043 044 045 046; do + download_tile "N${lat}E${lon}" + done +done + +echo '' +echo "Total HGT files: $(ls *.hgt | wc -l)" +echo "E041-E046 coverage:" +ls *E04[1-6]* 2>/dev/null | grep -E "N5[456]" | sort diff --git a/tasks/enduro-trails/scripts/download_missing_srtm.sh b/tasks/enduro-trails/scripts/download_missing_srtm.sh new file mode 100644 index 0000000..82215c4 --- /dev/null +++ b/tasks/enduro-trails/scripts/download_missing_srtm.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -e + +echo '=== DOWNLOAD MISSING SRTM FILES (E041-E046, N54-N56) ===' +echo "Start: $(date)" + +SRTM_DIR='/home/slin/enduro-trails/data/srtm' +cd $SRTM_DIR + +# Missing tiles for the gap between Vladimir (E040) and Cheboksary (E047) +# Latitudes N54-N56 (main coverage area) +TILES="N54E041 N54E046 N55E041 N55E042 N55E043 N55E044 N55E045 N55E046 N56E041 N56E042 N56E043 N56E044 N56E045 N56E046" + +# Also fill N53 gap +TILES="$TILES N53E046 N53E047" + +# SRTM v4.1 from CGIAR (free, no auth needed) +# URL pattern: https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/ +# Alternative: NASA EarthData (needs auth) or viewfinderpanoramas.org + +# Use viewfinderpanoramas.org - direct HGT downloads +BASE_URL="https://viewfinderpanoramas.org/dem3" + +count=0 +for tile in $TILES; do + if [ -f "${tile}.hgt" ]; then + echo "SKIP: ${tile}.hgt already exists" + continue + fi + + # Extract lat letter (N/S) and first 2 digits for directory + lat_letter=${tile:0:1} + lat_num=${tile:1:2} + + # viewfinderpanoramas uses zip files grouped by latitude band + # Try direct NASA SRTM mirror instead + # https://e4ftl01.cr.usgs.gov/MEASURES/SRTMGL1.003/2000.02.11/ + # Needs .SRTMGL1.hgt.zip format - requires auth + + # Use OpenTopography or direct SRTM mirror + # Simplest: use elevation-tiles from AWS (no auth) + echo "Downloading ${tile}..." + + # Try USGS SRTM mirror (no auth for SRTM3/1-arc-second) + wget -q "https://firmware.ardupilot.org/SRTM/ap_srtm3/${tile}.hgt.zip" -O "/tmp/${tile}.hgt.zip" 2>/dev/null + if [ $? -eq 0 ] && [ -s "/tmp/${tile}.hgt.zip" ]; then + unzip -o -q "/tmp/${tile}.hgt.zip" -d $SRTM_DIR/ + rm -f "/tmp/${tile}.hgt.zip" + echo " OK: ${tile}.hgt ($(du -h ${tile}.hgt | cut -f1))" + count=$((count + 1)) + else + echo " FAIL: ${tile} not available from ardupilot mirror" + # Try alternative + wget -q "http://viewfinderpanoramas.org/dem3/${lat_letter}${lat_num}/${tile}.hgt.zip" -O "/tmp/${tile}.hgt.zip" 2>/dev/null + if [ $? -eq 0 ] && [ -s "/tmp/${tile}.hgt.zip" ]; then + unzip -o -q "/tmp/${tile}.hgt.zip" -d $SRTM_DIR/ + rm -f "/tmp/${tile}.hgt.zip" + echo " OK (viewfinder): ${tile}.hgt" + count=$((count + 1)) + else + echo " FAIL: ${tile} not found" + fi + fi +done + +echo "" +echo "Downloaded: $count new files" +echo "Total HGT files: $(ls $SRTM_DIR/*.hgt | wc -l)" +echo "End: $(date)"