Tile-Server: Vektor-Basemap in PWA integrieren (protomaps-leaflet, Feature-Flag)

- ui.js Map.create: Basemap-Swap OSM-Raster→PMTiles-Vektorlayer hinter Flag
  'by_vector_map' (?vectormap=1/0). Leaflet+markercluster+Marker unverändert,
  sauberer Raster-Fallback bei Fehler. Attribution Pflicht eingeblendet.
- map-vector.js: protomaps-leaflet paintRules/labelRules für OpenMapTiles-Schema
  (Light+Dark), Labels per Canvas-Text → keine Glyphs nötig. Quelle /tiles/dach.pmtiles.
- protomaps-leaflet 4.0.1 vendored.
- Makefile: 'make tiles' (download→merge -H+time-filter dedup→planetiler) + 'make tiles-deploy'
  (atomarer Swap, ENV=prod für Produktion).
This commit is contained in:
rene 2026-06-04 21:53:07 +02:00
parent a561759034
commit 2b5afcf0ae
4 changed files with 205 additions and 6 deletions

View file

@ -28,7 +28,7 @@ TAR_EXCLUDE := --exclude='.git' \
--exclude='./.DS_Store'
.PHONY: help deploy deploy-clean staging release sync push restart build stop status \
logs logs-f shell db dev clean-cache check-ssh reports bump test
logs logs-f shell db dev clean-cache check-ssh reports bump test tiles tiles-deploy
# ----------------------------------------------------------
# SSH-Prüfung — Abhängigkeit aller DS-Befehle
@ -140,6 +140,48 @@ staging-db: check-ssh
sudo chmod 666 $(DS_PATH_STAGING)/data/banyaro.db && \
echo '✓ DB kopiert'"
# ----------------------------------------------------------
# TILES — DACH-Vektortiles (planetiler → PMTiles), lokal bauen + ausliefern
# Voraussetzung: Docker Desktop läuft, osmium installiert (brew install osmium-tool).
# make tiles DACH neu generieren (download → merge → planetiler)
# make tiles-deploy dach.pmtiles auf Staging ausliefern (atomar)
# make tiles-deploy ENV=prod dach.pmtiles auf Produktion ausliefern (atomar)
# Monatlich neu generieren hält die Karte aktuell. Datei liegt im data-Volume,
# NICHT im Image — wird per Range-Route (/tiles) ausgeliefert.
# ----------------------------------------------------------
TILES_DIR := tiles/build
TILES_REGIONS := germany austria switzerland
PLANETILER_IMAGE := ghcr.io/onthegomap/planetiler:latest
TILES_TARGET := $(if $(filter prod,$(ENV)),$(DS_PATH),$(DS_PATH_STAGING))
tiles:
@mkdir -p $(TILES_DIR)
@echo "→ Geofabrik-Extrakte laden ($(TILES_REGIONS))..."
@for r in $(TILES_REGIONS); do \
echo " $$r"; \
curl -fsSL -o $(TILES_DIR)/$$r.osm.pbf https://download.geofabrik.de/europe/$$r-latest.osm.pbf; done
@echo "→ merge (History) + time-filter dedup → dach.osm.pbf..."
@# Geofabrik-Extrakte können versetzte Stände haben (z.B. germany älter als at/ch)
@# Grenz-Nodes mit abweichender Version. Als History mergen + auf 'jetzt' snapshotten
@# liefert genau eine Version pro ID (planetiler braucht eindeutige, sortierte IDs).
@osmium merge -H $(foreach r,$(TILES_REGIONS),$(TILES_DIR)/$(r).osm.pbf) -o $(TILES_DIR)/dach-hist.osm.pbf --overwrite
@osmium time-filter $(TILES_DIR)/dach-hist.osm.pbf -o $(TILES_DIR)/dach.osm.pbf --overwrite
@rm -f $(TILES_DIR)/dach-hist.osm.pbf
@echo "→ planetiler → dach.pmtiles (disk-backed mmap)..."
@docker run --rm -v "$(CURDIR)/$(TILES_DIR):/data" $(PLANETILER_IMAGE) \
--osm-path=/data/dach.osm.pbf --download --output=/data/dach.pmtiles --force \
--storage=mmap --nodemap-storage=mmap
@echo ""
@echo " ✓ Tiles gebaut:"; ls -lh $(TILES_DIR)/dach.pmtiles
tiles-deploy: check-ssh
@if [ ! -f $(TILES_DIR)/dach.pmtiles ]; then echo "$(TILES_DIR)/dach.pmtiles fehlt — erst 'make tiles'"; exit 1; fi
@echo "→ Ausliefern nach $(TILES_TARGET)/data/tiles/ (atomarer Swap)..."
@ssh $(DS_HOST) "mkdir -p $(TILES_TARGET)/data/tiles"
@scp -O $(TILES_DIR)/dach.pmtiles $(DS_HOST):$(TILES_TARGET)/data/tiles/dach.pmtiles.tmp
@ssh $(DS_HOST) "mv -f $(TILES_TARGET)/data/tiles/dach.pmtiles.tmp $(TILES_TARGET)/data/tiles/dach.pmtiles"
@echo " ✓ dach.pmtiles ausgeliefert ($(if $(filter prod,$(ENV)),PRODUKTION,Staging))"
# ----------------------------------------------------------
# RELEASE — develop → main → Production (VERSION= pflichtangabe)
# Beispiel: make release VERSION=1.1.0