diff --git a/wrolpi/scripts/initialize_map_tiles.sh b/wrolpi/scripts/initialize_map_tiles.sh index 8c7213ff..f21f94f3 100644 --- a/wrolpi/scripts/initialize_map_tiles.sh +++ b/wrolpi/scripts/initialize_map_tiles.sh @@ -49,14 +49,37 @@ done # If we've made it through all attempts, curl never succeeded if [[ $i -eq $ATTEMPTS ]]; then echo "Failed to fetch the image after $ATTEMPTS attempts." + echo " You can try resetting your map using /opt/wrolpi/scripts/reset_map.sh then importing a map again." exit 1 fi echo "Fetching first map tile succeeded." -curl -ks \ - "${HOST}/hot/3/{0..7}/{0..7}.png" \ - "${HOST}/hot/4/{0..15}/{0..15}.png" \ - "${HOST}/hot/5/{0..31}/{0..31}.png" \ - "${HOST}/hot/6/{0..41}/{0..41}.png" >/dev/null 2>&1 -echo "Fetching many map tiles completed." + +# Function to fetch and count downloads +fetch_and_count() { + local level=$1 + local max_x=$2 + local max_y=$3 + + local success_count=0 + local failure_count=0 + + for x in $(seq 0 $max_x); do + for y in $(seq 0 $max_y); do + if wget -q --spider --no-check-certificate "${HOST}/hot/${level}/${x}/${y}.png"; then + ((success_count++)) + else + ((failure_count++)) + fi + done + done + + echo "Level $level - Successful downloads: $success_count" +} + +# Fetch all tiles from each level so the map is ready to use. +fetch_and_count 3 7 7 +fetch_and_count 4 15 15 +fetch_and_count 5 31 31 +fetch_and_count 6 41 41 \ No newline at end of file