rd13_tile_server/scripts/download-data.sh
Conrad Schulz bfd8dfdf96 feat: initial tile server setup
- TileServer-GL + nginx reverse proxy (docker-compose)
- CORS-Konfiguration für MediaWiki, Nextcloud & weitere Dienste
- Rate-Limiting & Tile-Caching-Header via nginx
- config/config.json: OSM + Satellitenkacheln
- scripts/download-data.sh: Planetiler (OSM), Sentinel-2 Hinweise
- docs: API-Endpoints, MediaWiki Kartographer, Nextcloud Maps
- .gitignore: MBTiles/PMTiles und .env ausgeschlossen
2026-05-30 15:57:07 +00:00

150 lines
4.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# =============================================================================
# download-data.sh Kartendaten für den rd13 Tile Server herunterladen
#
# Verwendung:
# ./scripts/download-data.sh [region]
#
# Regionen:
# europe-dach Deutschland, Österreich, Schweiz (Standard)
# germany nur Deutschland
# planet gesamter Planet (groß!)
# satellite Sentinel-2 cloudless Satellitenkacheln (niedrig/mittel Zoom)
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DATA_DIR="$SCRIPT_DIR/../data"
mkdir -p "$DATA_DIR"
REGION="${1:-europe-dach}"
# ---- OSM-Vektorkacheln via Planetiler ------------------------------------
download_osm() {
local region="$1"
local jar="$DATA_DIR/planetiler.jar"
# Planetiler herunterladen falls nicht vorhanden
if [[ ! -f "$jar" ]]; then
echo "[OSM] Lade Planetiler herunter..."
curl -L -o "$jar" \
"https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar"
fi
case "$region" in
germany)
AREA="germany"
DOWNLOAD="https://download.geofabrik.de/europe/germany-latest.osm.pbf"
;;
europe-dach)
# DACH als Extrakt
AREA="dach"
DOWNLOAD="https://download.geofabrik.de/europe/dach-latest.osm.pbf"
;;
planet)
AREA="planet"
DOWNLOAD="" # Planetiler lädt selbst herunter
;;
*)
echo "Unbekannte Region: $region"; exit 1 ;;
esac
echo "[OSM] Erzeuge osm.mbtiles für Region: $region"
if [[ "$region" == "planet" ]]; then
java -Xmx8g -jar "$jar" \
--download \
--output="$DATA_DIR/osm.mbtiles"
else
# OSM-PBF herunterladen
local pbf="$DATA_DIR/${AREA}.osm.pbf"
if [[ ! -f "$pbf" ]]; then
echo "[OSM] Lade PBF-Datei: $DOWNLOAD"
curl -L -o "$pbf" "$DOWNLOAD"
fi
java -Xmx4g -jar "$jar" \
--area="$AREA" \
--osm-path="$pbf" \
--output="$DATA_DIR/osm.mbtiles"
fi
echo "[OSM] Fertig: $DATA_DIR/osm.mbtiles"
}
# ---- Satellit: Sentinel-2 cloudless (OpenMapTiles / maptiler) ------------
download_satellite() {
echo ""
echo "[Satellit] Hinweis:"
echo " Kostenlose Satelliten-MBTiles sind nur für niedrige Zoomstufen (0-10)"
echo " verfügbar. Für höhere Auflösung gibt es zwei Optionen:"
echo ""
echo " 1) NASA GIBS (kostenlos, TMS/WMTS, kein Download nötig):"
echo " https://gibs.earthdata.nasa.gov/wmts/"
echo " → Einfach in config.json als 'tilejson'-Source eintragen."
echo ""
echo " 2) Sentinel-2 cloudless (maptiler.com, kostenloser Account für self-hosted):"
echo " https://www.maptiler.com/data/satellite-mediumres/"
echo " → MBTiles manuell herunterladen und als data/satellite.mbtiles ablegen."
echo ""
echo " 3) Eigene GeoTIFFs → MBTiles mit gdal2tiles:"
echo " gdal2tiles.py --zoom=0-14 input.tif data/satellite/"
echo " mb-util data/satellite/ data/satellite.mbtiles"
echo ""
}
# ---- Fonts & Sprites für OSM Bright Style --------------------------------
download_assets() {
local fonts_dir="$DATA_DIR/fonts"
local sprites_dir="$DATA_DIR/sprites"
local styles_dir="$DATA_DIR/styles"
mkdir -p "$fonts_dir" "$sprites_dir" "$styles_dir"
if [[ ! -d "$fonts_dir/Open Sans Regular" ]]; then
echo "[Assets] Lade OpenMapTiles Fonts herunter..."
TMP=$(mktemp -d)
curl -L -o "$TMP/fonts.zip" \
"https://github.com/openmaptiles/fonts/releases/latest/download/v3.0.zip" \
|| { echo "[Assets] Font-Download fehlgeschlagen bitte manuell von"; \
echo " https://github.com/openmaptiles/fonts/releases herunterladen"; \
rm -rf "$TMP"; }
if [[ -f "$TMP/fonts.zip" ]]; then
unzip -q "$TMP/fonts.zip" -d "$fonts_dir"
rm -rf "$TMP"
echo "[Assets] Fonts installiert."
fi
else
echo "[Assets] Fonts bereits vorhanden."
fi
if [[ ! -d "$styles_dir/osm-bright" ]]; then
echo "[Assets] Lade OSM Bright GL Style herunter..."
TMP=$(mktemp -d)
curl -L -o "$TMP/style.zip" \
"https://github.com/openmaptiles/osm-bright-gl-style/releases/latest/download/v1.9.zip" \
|| { echo "[Assets] Style-Download fehlgeschlagen."; rm -rf "$TMP"; }
if [[ -f "$TMP/style.zip" ]]; then
unzip -q "$TMP/style.zip" -d "$TMP/extracted"
mv "$TMP/extracted/"*/ "$styles_dir/osm-bright"
rm -rf "$TMP"
echo "[Assets] OSM Bright Style installiert."
fi
else
echo "[Assets] OSM Bright Style bereits vorhanden."
fi
}
# ---- Hauptlogik ----------------------------------------------------------
echo "=== rd13 Tile Server Daten-Download ==="
echo "Region: $REGION"
echo ""
if [[ "$REGION" == "satellite" ]]; then
download_satellite
else
download_osm "$REGION"
download_assets
download_satellite
fi
echo ""
echo "=== Abgeschlossen ==="
echo "Starte den Server mit: docker compose up -d"