#!/usr/bin/env bash set -e CYAN='\033[0;36m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' MAPS_DIR=/opt/hub/maps/www mkdir -p "$MAPS_DIR" if ! command -v pmtiles >/dev/null 2>&1; then echo -e "${CYAN}==> Installing pmtiles CLI...${NC}" cd /tmp PM_VER=1.30.3 wget -q "https://github.com/protomaps/go-pmtiles/releases/download/v${PM_VER}/go-pmtiles_${PM_VER}_Linux_x86_64.tar.gz" tar -xzf "go-pmtiles_${PM_VER}_Linux_x86_64.tar.gz" mv pmtiles /usr/local/bin/ rm -f "go-pmtiles_${PM_VER}_Linux_x86_64.tar.gz" README.txt LICENSE 2>/dev/null || true cd - >/dev/null fi echo -e "${CYAN}==> Finding latest Protomaps build...${NC}" LATEST_BUILD=$(curl -s https://maps.protomaps.com/builds/ | grep -oE '20[0-9]{6}\.pmtiles' | sort -u | tail -1) if [ -z "$LATEST_BUILD" ]; then echo -e "${YELLOW}Could not auto-detect latest build. Edit fetch-maps.sh and set BUILD manually.${NC}" exit 1 fi echo "Using $LATEST_BUILD" echo -e "${CYAN}==> Downloading North America basemap (~4 GB at zoom 12, this can take 10-30 min)...${NC}" pmtiles extract "https://build.protomaps.com/${LATEST_BUILD}" \ "$MAPS_DIR/base.pmtiles" \ --bbox=-168.0,14.5,-52.0,72.0 \ --maxzoom=12 echo -e "${GREEN}==> Basemap done. Size:${NC} $(du -h "$MAPS_DIR/base.pmtiles" | cut -f1)" echo read -p "Also download topographic terrain tiles? (~20 GB, 1-3 hr) [y/N]: " yn yn=${yn:-N} if [[ "$yn" =~ ^[Yy]$ ]]; then echo -e "${CYAN}==> Downloading Mapterhorn terrain (this is slow)...${NC}" pmtiles extract https://download.mapterhorn.com/planet.pmtiles \ "$MAPS_DIR/terrain.pmtiles" \ --bbox=-168.0,14.5,-52.0,72.0 \ --maxzoom=12 echo -e "${GREEN}==> Terrain done. Size:${NC} $(du -h "$MAPS_DIR/terrain.pmtiles" | cut -f1)" fi echo echo -e "${GREEN}Map download complete.${NC}"