fix: Restore all files lost during destructive rebase

A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.

This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).

Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-02-09 09:51:32 +01:00
parent f7487ee240
commit bfdaf63ba9
2009 changed files with 749983 additions and 1731 deletions

View File

@@ -0,0 +1,198 @@
#!/bin/bash
# ============================================
# Copernicus DEM Download Script for GeoEdu Service
# ============================================
#
# WICHTIG: Dieses Script startet einen Download von ca. 20-40 GB!
# Nur nach expliziter Freigabe ausfuehren!
#
# Quelle: Copernicus Data Space Ecosystem
# Daten: GLO-30 DEM (30m Aufloesung)
# Lizenz: Copernicus Data (frei, Attribution erforderlich)
# Attribution: © Copernicus Service Information
#
# Voraussetzungen:
# - Copernicus Data Space Account (kostenlos)
# - Credentials in ~/.netrc oder als Umgebungsvariablen
#
# Nutzung:
# ./download_dem.sh [--dry-run] [--bbox west,south,east,north]
#
# Beispiel (nur Bayern):
# ./download_dem.sh --bbox 8.97,47.27,13.84,50.56
#
# ============================================
set -e
# Configuration
DATA_DIR="${DEM_DATA_DIR:-/app/data/dem}"
COPERNICUS_URL="https://dataspace.copernicus.eu"
# Germany bounding box (default)
BBOX_WEST="${BBOX_WEST:-5.87}"
BBOX_SOUTH="${BBOX_SOUTH:-47.27}"
BBOX_EAST="${BBOX_EAST:-15.04}"
BBOX_NORTH="${BBOX_NORTH:-55.06}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}============================================${NC}"
echo -e "${YELLOW}GeoEdu Service - Copernicus DEM Download${NC}"
echo -e "${YELLOW}============================================${NC}"
echo ""
echo -e "Quelle: ${GREEN}Copernicus Data Space${NC}"
echo -e "Daten: ${GREEN}GLO-30 DEM (30m Aufloesung)${NC}"
echo -e "Groesse: ${YELLOW}~20-40 GB (Deutschland komplett)${NC}"
echo -e "Lizenz: ${GREEN}Copernicus Data (frei)${NC}"
echo -e "Attribution: ${GREEN}© Copernicus Service Information${NC}"
echo ""
# Parse arguments
DRY_RUN=false
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
DRY_RUN=true
shift
;;
--bbox)
IFS=',' read -r BBOX_WEST BBOX_SOUTH BBOX_EAST BBOX_NORTH <<< "$2"
shift 2
;;
*)
echo "Unbekannte Option: $1"
exit 1
;;
esac
done
echo "Bounding Box:"
echo " West: $BBOX_WEST"
echo " Sued: $BBOX_SOUTH"
echo " Ost: $BBOX_EAST"
echo " Nord: $BBOX_NORTH"
echo ""
# Calculate required tiles
# Copernicus DEM tiles are 1°x1° cells
calc_tiles() {
local west=$(echo "$BBOX_WEST" | cut -d. -f1)
local south=$(echo "$BBOX_SOUTH" | cut -d. -f1)
local east=$(echo "$BBOX_EAST" | cut -d. -f1)
local north=$(echo "$BBOX_NORTH" | cut -d. -f1)
# Adjust for negative values
west=$((west < 0 ? west : west))
local count=0
for lat in $(seq $south $north); do
for lon in $(seq $west $east); do
count=$((count + 1))
done
done
echo $count
}
TILE_COUNT=$(calc_tiles)
ESTIMATED_SIZE=$((TILE_COUNT * 50)) # ~50 MB per tile
echo "Benoetigte Tiles: $TILE_COUNT"
echo "Geschaetzte Groesse: ~${ESTIMATED_SIZE} MB"
echo ""
if [ "$DRY_RUN" = true ]; then
echo -e "${YELLOW}[DRY-RUN] Kein Download wird durchgefuehrt.${NC}"
echo ""
echo "Wuerde folgende Tiles herunterladen:"
echo ""
for lat in $(seq $(echo "$BBOX_SOUTH" | cut -d. -f1) $(echo "$BBOX_NORTH" | cut -d. -f1)); do
for lon in $(seq $(echo "$BBOX_WEST" | cut -d. -f1) $(echo "$BBOX_EAST" | cut -d. -f1)); do
lat_prefix=$([ $lat -ge 0 ] && echo "N" || echo "S")
lon_prefix=$([ $lon -ge 0 ] && echo "E" || echo "W")
printf " %s%02d%s%03d.tif\n" "$lat_prefix" "${lat#-}" "$lon_prefix" "${lon#-}"
done
done
echo ""
exit 0
fi
# Confirm download
echo -e "${RED}ACHTUNG: Download startet ~${ESTIMATED_SIZE} MB Daten!${NC}"
echo ""
read -p "Download starten? (j/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[JjYy]$ ]]; then
echo "Download abgebrochen."
exit 1
fi
# Create data directory
mkdir -p "$DATA_DIR"
cd "$DATA_DIR"
# Check for AWS CLI (preferred method for Copernicus)
if ! command -v aws &> /dev/null; then
echo -e "${YELLOW}HINWEIS: AWS CLI nicht installiert.${NC}"
echo "Installiere mit: pip install awscli"
echo ""
echo "Alternative: Manueller Download von:"
echo " https://dataspace.copernicus.eu/explore-data/data-collections/copernicus-contributing-missions/collections-description/COP-DEM"
exit 1
fi
# Download tiles
echo ""
echo -e "${GREEN}Starte Download...${NC}"
DOWNLOADED=0
FAILED=0
for lat in $(seq $(echo "$BBOX_SOUTH" | cut -d. -f1) $(echo "$BBOX_NORTH" | cut -d. -f1)); do
for lon in $(seq $(echo "$BBOX_WEST" | cut -d. -f1) $(echo "$BBOX_EAST" | cut -d. -f1)); do
lat_prefix=$([ $lat -ge 0 ] && echo "N" || echo "S")
lon_prefix=$([ $lon -ge 0 ] && echo "E" || echo "W")
lat_abs=${lat#-}
lon_abs=${lon#-}
filename=$(printf "%s%02d%s%03d.tif" "$lat_prefix" "$lat_abs" "$lon_prefix" "$lon_abs")
if [ -f "$filename" ]; then
echo "$filename (bereits vorhanden)"
DOWNLOADED=$((DOWNLOADED + 1))
continue
fi
echo "$filename"
# Copernicus DEM S3 bucket path
# Format: s3://copernicus-dem-30m/Copernicus_DSM_COG_10_N47_00_E008_00_DEM/
s3_path="s3://copernicus-dem-30m/Copernicus_DSM_COG_10_${lat_prefix}${lat_abs}_00_${lon_prefix}${lon_abs}_00_DEM/"
if aws s3 cp "${s3_path}Copernicus_DSM_COG_10_${lat_prefix}${lat_abs}_00_${lon_prefix}${lon_abs}_00_DEM.tif" "$filename" --no-sign-request 2>/dev/null; then
DOWNLOADED=$((DOWNLOADED + 1))
else
echo -e " ${YELLOW}(nicht verfuegbar)${NC}"
FAILED=$((FAILED + 1))
fi
done
done
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN}Download abgeschlossen${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo "Heruntergeladen: $DOWNLOADED Tiles"
echo "Nicht verfuegbar: $FAILED Tiles"
echo "Speicherort: $DATA_DIR"
echo ""
echo -e "${YELLOW}Naechster Schritt:${NC}"
echo " Die Tiles werden automatisch vom geo-service geladen."

View File

@@ -0,0 +1,113 @@
#!/bin/bash
# ============================================
# OSM Data Download Script for GeoEdu Service
# ============================================
#
# WICHTIG: Dieses Script startet einen Download von ca. 4.4 GB!
# Nur nach expliziter Freigabe ausfuehren!
#
# Quelle: Geofabrik (offizieller OSM-Mirror)
# Lizenz: ODbL (Open Database License)
# Attribution: © OpenStreetMap contributors
#
# Nutzung:
# ./download_osm.sh [--dry-run]
#
# ============================================
set -e
# Configuration
DATA_DIR="${OSM_DATA_DIR:-/app/data/osm}"
GEOFABRIK_URL="https://download.geofabrik.de/europe/germany-latest.osm.pbf"
GEOFABRIK_MD5_URL="https://download.geofabrik.de/europe/germany-latest.osm.pbf.md5"
OUTPUT_FILE="germany-latest.osm.pbf"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}============================================${NC}"
echo -e "${YELLOW}GeoEdu Service - OSM Data Download${NC}"
echo -e "${YELLOW}============================================${NC}"
echo ""
echo -e "Quelle: ${GREEN}Geofabrik${NC}"
echo -e "Datei: ${GREEN}Germany PBF${NC}"
echo -e "Groesse: ${YELLOW}~4.4 GB${NC}"
echo -e "Lizenz: ${GREEN}ODbL (Open Database License)${NC}"
echo -e "Attribution: ${GREEN}© OpenStreetMap contributors${NC}"
echo ""
# Check for dry-run mode
if [[ "$1" == "--dry-run" ]]; then
echo -e "${YELLOW}[DRY-RUN] Kein Download wird durchgefuehrt.${NC}"
echo ""
echo "Wuerde herunterladen von:"
echo " $GEOFABRIK_URL"
echo ""
echo "Nach:"
echo " $DATA_DIR/$OUTPUT_FILE"
echo ""
exit 0
fi
# Confirm download
echo -e "${RED}ACHTUNG: Download startet ~4.4 GB Daten!${NC}"
echo ""
read -p "Download starten? (j/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[JjYy]$ ]]; then
echo "Download abgebrochen."
exit 1
fi
# Create data directory
mkdir -p "$DATA_DIR"
cd "$DATA_DIR"
# Download MD5 checksum first
echo ""
echo -e "${GREEN}[1/3] Lade MD5-Pruefsumme herunter...${NC}"
curl -L -o "${OUTPUT_FILE}.md5" "$GEOFABRIK_MD5_URL"
# Download OSM data
echo ""
echo -e "${GREEN}[2/3] Lade OSM-Daten herunter (~4.4 GB)...${NC}"
echo " Dies kann je nach Internetverbindung 5-60 Minuten dauern."
echo ""
# Use wget with resume support
if command -v wget &> /dev/null; then
wget -c -O "$OUTPUT_FILE" "$GEOFABRIK_URL"
else
curl -L -C - -o "$OUTPUT_FILE" "$GEOFABRIK_URL"
fi
# Verify checksum
echo ""
echo -e "${GREEN}[3/3] Verifiziere MD5-Pruefsumme...${NC}"
if md5sum -c "${OUTPUT_FILE}.md5"; then
echo ""
echo -e "${GREEN}✓ Download erfolgreich!${NC}"
echo ""
echo "Datei: $DATA_DIR/$OUTPUT_FILE"
echo "Groesse: $(du -h "$OUTPUT_FILE" | cut -f1)"
echo ""
echo -e "${YELLOW}Naechster Schritt:${NC}"
echo " ./import_osm.sh # OSM in PostGIS importieren"
echo " ./generate_tiles.sh # PMTiles generieren"
else
echo ""
echo -e "${RED}✗ MD5-Pruefsumme stimmt nicht ueberein!${NC}"
echo "Bitte Download erneut starten."
exit 1
fi
echo ""
echo -e "${YELLOW}============================================${NC}"
echo -e "${YELLOW}Download abgeschlossen${NC}"
echo -e "${YELLOW}============================================${NC}"

View File

@@ -0,0 +1,184 @@
#!/bin/bash
# ============================================
# PMTiles Generation Script for GeoEdu Service
# ============================================
#
# Generiert PMTiles Vector Tiles aus PostGIS OSM Daten
# Verwendet tippecanoe fuer die Tile-Generierung
#
# Voraussetzungen:
# - OSM Daten in PostGIS importiert
# - tippecanoe installiert
# - ogr2ogr (GDAL) installiert
#
# Nutzung:
# ./generate_tiles.sh [--min-zoom 0] [--max-zoom 14]
#
# ============================================
set -e
# Configuration
DATA_DIR="${OSM_DATA_DIR:-/app/data/osm}"
OUTPUT_FILE="${DATA_DIR}/germany.pmtiles"
DATABASE_URL="${DATABASE_URL:-postgresql://breakpilot:breakpilot123@postgres:5432/breakpilot_db}"
MIN_ZOOM="${MIN_ZOOM:-0}"
MAX_ZOOM="${MAX_ZOOM:-14}"
# Parse DATABASE_URL
DB_USER=$(echo $DATABASE_URL | sed -n 's|.*://\([^:]*\):.*|\1|p')
DB_PASS=$(echo $DATABASE_URL | sed -n 's|.*://[^:]*:\([^@]*\)@.*|\1|p')
DB_HOST=$(echo $DATABASE_URL | sed -n 's|.*@\([^:]*\):.*|\1|p')
DB_PORT=$(echo $DATABASE_URL | sed -n 's|.*:\([0-9]*\)/.*|\1|p')
DB_NAME=$(echo $DATABASE_URL | sed -n 's|.*/\([^?]*\).*|\1|p')
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}============================================${NC}"
echo -e "${YELLOW}GeoEdu Service - PMTiles Generation${NC}"
echo -e "${YELLOW}============================================${NC}"
echo ""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--min-zoom)
MIN_ZOOM="$2"
shift 2
;;
--max-zoom)
MAX_ZOOM="$2"
shift 2
;;
*)
echo "Unbekannte Option: $1"
exit 1
;;
esac
done
echo "Zoom Level: $MIN_ZOOM - $MAX_ZOOM"
echo "Output: $OUTPUT_FILE"
echo ""
# Estimate output size
if [ "$MAX_ZOOM" -le 14 ]; then
ESTIMATED_SIZE="200-500 GB"
elif [ "$MAX_ZOOM" -le 16 ]; then
ESTIMATED_SIZE="500-800 GB"
else
ESTIMATED_SIZE="2-4 TB"
fi
echo -e "${YELLOW}Geschaetzte Groesse: $ESTIMATED_SIZE${NC}"
echo -e "${YELLOW}Geschaetzte Dauer: 12-24 Stunden (Zoom 0-14)${NC}"
echo ""
# Check for required tools
for tool in tippecanoe ogr2ogr; do
if ! command -v $tool &> /dev/null; then
echo -e "${RED}Fehler: $tool nicht installiert!${NC}"
echo ""
if [ "$tool" == "tippecanoe" ]; then
echo "Installation:"
echo " git clone https://github.com/felt/tippecanoe.git"
echo " cd tippecanoe && make -j && sudo make install"
else
echo "Installation:"
echo " apt-get install gdal-bin # Debian/Ubuntu"
echo " brew install gdal # macOS"
fi
exit 1
fi
done
echo "tippecanoe: $(tippecanoe --version 2>&1 | head -1)"
echo "ogr2ogr: $(ogr2ogr --version | head -1)"
echo ""
read -p "Tile-Generierung starten? (j/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[JjYy]$ ]]; then
echo "Abgebrochen."
exit 1
fi
# Create temporary directory for GeoJSON
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
echo ""
echo -e "${GREEN}[1/5] Exportiere Landuse/Landcover...${NC}"
PGPASSWORD="$DB_PASS" ogr2ogr -f GeoJSONSeq \
"$TEMP_DIR/landuse.geojsonseq" \
"PG:host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
-sql "SELECT way AS geometry, landuse, natural, name FROM planet_osm_polygon WHERE landuse IS NOT NULL OR natural IS NOT NULL"
echo -e "${GREEN}[2/5] Exportiere Gebaude...${NC}"
PGPASSWORD="$DB_PASS" ogr2ogr -f GeoJSONSeq \
"$TEMP_DIR/building.geojsonseq" \
"PG:host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
-sql "SELECT way AS geometry, building, name, addr_housenumber FROM planet_osm_polygon WHERE building IS NOT NULL"
echo -e "${GREEN}[3/5] Exportiere Strassen...${NC}"
PGPASSWORD="$DB_PASS" ogr2ogr -f GeoJSONSeq \
"$TEMP_DIR/transportation.geojsonseq" \
"PG:host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
-sql "SELECT way AS geometry, highway, railway, name, ref FROM planet_osm_line WHERE highway IS NOT NULL OR railway IS NOT NULL"
echo -e "${GREEN}[4/5] Exportiere Gewaesser...${NC}"
PGPASSWORD="$DB_PASS" ogr2ogr -f GeoJSONSeq \
"$TEMP_DIR/water.geojsonseq" \
"PG:host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
-sql "SELECT way AS geometry, waterway, water, name FROM planet_osm_polygon WHERE water IS NOT NULL OR waterway IS NOT NULL
UNION ALL
SELECT way AS geometry, waterway, NULL as water, name FROM planet_osm_line WHERE waterway IS NOT NULL"
echo -e "${GREEN}[5/5] Exportiere Orte (POIs)...${NC}"
PGPASSWORD="$DB_PASS" ogr2ogr -f GeoJSONSeq \
"$TEMP_DIR/place.geojsonseq" \
"PG:host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
-sql "SELECT way AS geometry, place, name, population FROM planet_osm_point WHERE place IS NOT NULL"
echo ""
echo -e "${GREEN}Generiere PMTiles...${NC}"
echo "Dies kann mehrere Stunden dauern!"
echo ""
# Run tippecanoe
tippecanoe \
--output="$OUTPUT_FILE" \
--force \
--name="GeoEdu Germany" \
--description="Self-hosted OSM tiles for DSGVO-compliant education" \
--attribution="© OpenStreetMap contributors" \
--minimum-zoom="$MIN_ZOOM" \
--maximum-zoom="$MAX_ZOOM" \
--drop-densest-as-needed \
--extend-zooms-if-still-dropping \
--layer=landuse:"$TEMP_DIR/landuse.geojsonseq" \
--layer=building:"$TEMP_DIR/building.geojsonseq" \
--layer=transportation:"$TEMP_DIR/transportation.geojsonseq" \
--layer=water:"$TEMP_DIR/water.geojsonseq" \
--layer=place:"$TEMP_DIR/place.geojsonseq"
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN}PMTiles Generierung abgeschlossen!${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo "Ausgabe: $OUTPUT_FILE"
echo "Groesse: $(du -h "$OUTPUT_FILE" | cut -f1)"
echo ""
echo "Die Tiles sind jetzt bereit fuer den geo-service."

236
geo-service/scripts/import_osm.sh Executable file
View File

@@ -0,0 +1,236 @@
#!/bin/bash
# ============================================
# OSM PostGIS Import Script for GeoEdu Service
# ============================================
#
# Importiert OSM PBF-Daten in PostgreSQL/PostGIS
# Verwendet osm2pgsql fuer den Import
#
# Voraussetzungen:
# - PostgreSQL mit PostGIS Extension
# - osm2pgsql installiert
# - OSM PBF Datei heruntergeladen
#
# Nutzung:
# ./import_osm.sh [--slim] [--drop]
#
# ============================================
set -e
# Configuration
DATA_DIR="${OSM_DATA_DIR:-/app/data/osm}"
PBF_FILE="${DATA_DIR}/germany-latest.osm.pbf"
DATABASE_URL="${DATABASE_URL:-postgresql://breakpilot:breakpilot123@postgres:5432/breakpilot_db}"
# Parse DATABASE_URL
DB_USER=$(echo $DATABASE_URL | sed -n 's|.*://\([^:]*\):.*|\1|p')
DB_PASS=$(echo $DATABASE_URL | sed -n 's|.*://[^:]*:\([^@]*\)@.*|\1|p')
DB_HOST=$(echo $DATABASE_URL | sed -n 's|.*@\([^:]*\):.*|\1|p')
DB_PORT=$(echo $DATABASE_URL | sed -n 's|.*:\([0-9]*\)/.*|\1|p')
DB_NAME=$(echo $DATABASE_URL | sed -n 's|.*/\([^?]*\).*|\1|p')
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}============================================${NC}"
echo -e "${YELLOW}GeoEdu Service - OSM PostGIS Import${NC}"
echo -e "${YELLOW}============================================${NC}"
echo ""
# Check if PBF file exists
if [ ! -f "$PBF_FILE" ]; then
echo -e "${RED}Fehler: OSM PBF Datei nicht gefunden!${NC}"
echo "Erwartet: $PBF_FILE"
echo ""
echo "Bitte zuerst download_osm.sh ausfuehren."
exit 1
fi
echo "PBF Datei: $PBF_FILE"
echo "Groesse: $(du -h "$PBF_FILE" | cut -f1)"
echo ""
echo "Datenbank: $DB_NAME @ $DB_HOST:$DB_PORT"
echo ""
# Check for osm2pgsql
if ! command -v osm2pgsql &> /dev/null; then
echo -e "${RED}Fehler: osm2pgsql nicht installiert!${NC}"
echo ""
echo "Installation:"
echo " apt-get install osm2pgsql # Debian/Ubuntu"
echo " brew install osm2pgsql # macOS"
exit 1
fi
OSM2PGSQL_VERSION=$(osm2pgsql --version 2>&1 | head -1)
echo "osm2pgsql Version: $OSM2PGSQL_VERSION"
echo ""
# Parse arguments
SLIM_MODE=""
DROP_MODE=""
while [[ $# -gt 0 ]]; do
case $1 in
--slim)
SLIM_MODE="--slim"
echo "Modus: Slim (fuer Updates)"
shift
;;
--drop)
DROP_MODE="--drop"
echo "Modus: Drop (bestehende Tabellen loeschen)"
shift
;;
*)
echo "Unbekannte Option: $1"
exit 1
;;
esac
done
# Estimate time
PBF_SIZE=$(stat -f%z "$PBF_FILE" 2>/dev/null || stat -c%s "$PBF_FILE")
ESTIMATED_HOURS=$((PBF_SIZE / 1000000000 / 2)) # Rough estimate: ~2GB per hour
echo ""
echo -e "${YELLOW}ACHTUNG: Import kann 2-4 Stunden dauern!${NC}"
echo "Geschaetzte Dauer: ~${ESTIMATED_HOURS}-$((ESTIMATED_HOURS * 2)) Stunden"
echo ""
read -p "Import starten? (j/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[JjYy]$ ]]; then
echo "Import abgebrochen."
exit 1
fi
# Create style file
STYLE_FILE="${DATA_DIR}/osm2pgsql.style"
cat > "$STYLE_FILE" << 'EOF'
# osm2pgsql style file for GeoEdu Service
# Optimized for educational geography content
# Common tags
node,way access text linear
node,way addr:housename text linear
node,way addr:housenumber text linear
node,way addr:interpolation text linear
node,way admin_level text linear
node,way aerialway text linear
node,way amenity text polygon
node,way area text linear
node,way barrier text linear
node,way bicycle text linear
node,way boundary text linear
node,way bridge text linear
node,way building text polygon
node,way construction text linear
node,way covered text linear
node,way foot text linear
node,way highway text linear
node,way historic text polygon
node,way junction text linear
node,way landuse text polygon
node,way layer text linear
node,way leisure text polygon
node,way man_made text polygon
node,way military text polygon
node,way name text linear
node,way natural text polygon
node,way oneway text linear
node,way place text polygon
node,way power text polygon
node,way railway text linear
node,way ref text linear
node,way religion text linear
node,way route text linear
node,way service text linear
node,way shop text polygon
node,way sport text polygon
node,way surface text linear
node,way tourism text polygon
node,way tracktype text linear
node,way tunnel text linear
node,way water text polygon
node,way waterway text linear
node,way wetland text polygon
node,way wood text polygon
node,way z_order int4 linear
# Elevation data from OSM
node,way ele text linear
# Name translations
node,way name:de text linear
node,way name:en text linear
# Population for place rendering
node,way population text linear
# Way area for polygon ordering
way way_area real linear
EOF
echo ""
echo -e "${GREEN}[1/3] PostGIS Extension aktivieren...${NC}"
PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS postgis;"
PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS hstore;"
echo ""
echo -e "${GREEN}[2/3] OSM Daten importieren...${NC}"
echo " Dies dauert mehrere Stunden!"
echo ""
# Run osm2pgsql
PGPASSWORD="$DB_PASS" osm2pgsql \
-H "$DB_HOST" \
-P "$DB_PORT" \
-U "$DB_USER" \
-d "$DB_NAME" \
-S "$STYLE_FILE" \
--cache 4000 \
--number-processes 4 \
$SLIM_MODE \
$DROP_MODE \
"$PBF_FILE"
echo ""
echo -e "${GREEN}[3/3] Indizes erstellen...${NC}"
PGPASSWORD="$DB_PASS" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" << 'EOSQL'
-- Spatial indexes (if not created by osm2pgsql)
CREATE INDEX IF NOT EXISTS planet_osm_point_way_idx ON planet_osm_point USING GIST (way);
CREATE INDEX IF NOT EXISTS planet_osm_line_way_idx ON planet_osm_line USING GIST (way);
CREATE INDEX IF NOT EXISTS planet_osm_polygon_way_idx ON planet_osm_polygon USING GIST (way);
CREATE INDEX IF NOT EXISTS planet_osm_roads_way_idx ON planet_osm_roads USING GIST (way);
-- Name indexes for search
CREATE INDEX IF NOT EXISTS planet_osm_point_name_idx ON planet_osm_point (name);
CREATE INDEX IF NOT EXISTS planet_osm_polygon_name_idx ON planet_osm_polygon (name);
-- Vacuum analyze for query optimization
VACUUM ANALYZE planet_osm_point;
VACUUM ANALYZE planet_osm_line;
VACUUM ANALYZE planet_osm_polygon;
VACUUM ANALYZE planet_osm_roads;
EOSQL
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN}Import abgeschlossen!${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo "Tabellen erstellt:"
echo " - planet_osm_point"
echo " - planet_osm_line"
echo " - planet_osm_polygon"
echo " - planet_osm_roads"
echo ""
echo -e "${YELLOW}Naechster Schritt:${NC}"
echo " ./generate_tiles.sh # PMTiles generieren"