feat(geoportal): PMTiles for terenuri/cladiri overview + cache warming + cleanup

- Extend PMTiles to include simplified terenuri (5m tolerance) and cladiri (3m)
- map-viewer: terenuri z13 from PMTiles, z14+ from Martin (live detail)
- map-viewer: cladiri z14 from PMTiles, z15+ from Martin
- Martin sources start at higher minzoom when PMTiles active (less DB load)
- Add warm-tile-cache.sh: pre-populate nginx cache for major cities
- Rebuild script now includes cache warming step after PMTiles upload
- Remove deprecated docker-compose version: "3.8"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-27 21:46:47 +02:00
parent 236635fbf4
commit 0d5fcf909c
4 changed files with 151 additions and 17 deletions
+47 -4
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# rebuild-overview-tiles.sh — Export UAT overview layers from PostGIS, generate PMTiles, upload to MinIO
# rebuild-overview-tiles.sh — Export all overview layers from PostGIS, generate PMTiles, upload to MinIO
# Includes: UAT boundaries, administrativ, simplified terenuri (z10-z14), simplified cladiri (z12-z14)
# Usage: ./scripts/rebuild-overview-tiles.sh
# Dependencies: ogr2ogr (GDAL), tippecanoe, mc (MinIO client)
# Run from project root or as a Docker one-shot container.
set -euo pipefail
@@ -33,6 +33,7 @@ cd "$TMPDIR"
# ── Step 1: Export views from PostGIS (parallel) ──
echo "[$(date -Iseconds)] Exporting PostGIS views to FlatGeobuf..."
# UAT boundaries (4 zoom levels)
ogr2ogr -f FlatGeobuf -s_srs EPSG:3844 -t_srs EPSG:4326 \
uats_z0.fgb "$PG_CONN" \
-sql "SELECT name, siruta, geom FROM gis_uats_z0 WHERE geom IS NOT NULL" &
@@ -49,10 +50,26 @@ ogr2ogr -f FlatGeobuf -s_srs EPSG:3844 -t_srs EPSG:4326 \
uats_z12.fgb "$PG_CONN" \
-sql "SELECT name, siruta, county, geom FROM gis_uats_z12 WHERE geom IS NOT NULL" &
# Administrativ (intravilan, arii speciale)
ogr2ogr -f FlatGeobuf -s_srs EPSG:3844 -t_srs EPSG:4326 \
administrativ.fgb "$PG_CONN" \
-sql "SELECT object_id, siruta, layer_id, cadastral_ref, geom FROM gis_administrativ WHERE geom IS NOT NULL" &
# Terenuri simplified for overview (ST_SimplifyPreserveTopology 5m tolerance — good for z10-z14)
# Only essential properties for overview display
ogr2ogr -f FlatGeobuf -s_srs EPSG:3844 -t_srs EPSG:4326 \
terenuri_overview.fgb "$PG_CONN" \
-sql "SELECT object_id, siruta, cadastral_ref, area_value, layer_id,
ST_SimplifyPreserveTopology(geom, 5) AS geom
FROM gis_terenuri WHERE geom IS NOT NULL" &
# Cladiri simplified for overview (3m tolerance — buildings are smaller)
ogr2ogr -f FlatGeobuf -s_srs EPSG:3844 -t_srs EPSG:4326 \
cladiri_overview.fgb "$PG_CONN" \
-sql "SELECT object_id, siruta, cadastral_ref, area_value, layer_id,
ST_SimplifyPreserveTopology(geom, 3) AS geom
FROM gis_cladiri WHERE geom IS NOT NULL" &
wait
echo "[$(date -Iseconds)] Export complete."
@@ -66,6 +83,8 @@ tippecanoe \
--named-layer=gis_uats_z8:uats_z8.fgb \
--named-layer=gis_uats_z12:uats_z12.fgb \
--named-layer=gis_administrativ:administrativ.fgb \
--named-layer=gis_terenuri:terenuri_overview.fgb \
--named-layer=gis_cladiri:cladiri_overview.fgb \
--minimum-zoom=0 \
--maximum-zoom=14 \
--base-zoom=14 \
@@ -93,6 +112,30 @@ mc mv "${MINIO_ALIAS}/${MINIO_BUCKET}/overview_new.pmtiles" "${MINIO_ALIAS}/${MI
echo "[$(date -Iseconds)] Upload complete."
# ── Step 4: Cleanup ──
rm -f uats_z0.fgb uats_z5.fgb uats_z8.fgb uats_z12.fgb administrativ.fgb "$OUTPUT_FILE"
# ── Step 4: Warm nginx tile cache (detail layers only — overview served from PMTiles) ──
TILE_CACHE="${TILE_CACHE_URL:-http://10.10.10.166:3010}"
echo "[$(date -Iseconds)] Warming tile cache for detail layers..."
# Warm popular z14-z16 tiles for Bucharest + Cluj (Martin-served detail layers)
for z in 14 15; do
for source in gis_terenuri gis_cladiri; do
# Bucharest
for x in $(seq 9200 9220); do
for y in $(seq 5960 5975); do
echo "${TILE_CACHE}/${source}/${z}/${x}/${y}"
done
done
# Cluj
for x in $(seq 9058 9068); do
for y in $(seq 5842 5852); do
echo "${TILE_CACHE}/${source}/${z}/${x}/${y}"
done
done
done
done | xargs -P 8 -I {} curl -sf -o /dev/null {} 2>/dev/null || true
echo "[$(date -Iseconds)] Cache warming complete."
# ── Step 5: Cleanup ──
rm -f uats_z0.fgb uats_z5.fgb uats_z8.fgb uats_z12.fgb administrativ.fgb \
terenuri_overview.fgb cladiri_overview.fgb "$OUTPUT_FILE"
echo "[$(date -Iseconds)] Rebuild finished successfully."