44 lines
1.4 KiB
Bash
Executable file
44 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# scripts/06_build_offline_packages.sh
|
|
# Register a region in the offline_regions table.
|
|
# Actual tile/routing/POI files are served directly from their data directories;
|
|
# this script just records metadata so the API can list available regions.
|
|
|
|
set -euo pipefail
|
|
|
|
PG_CONN="${PG_CONN:-postgres://maps:maps@postgres:5432/maps}"
|
|
REGION_ID="${REGION_ID:-amsterdam}"
|
|
REGION_NAME="${REGION_NAME:-Amsterdam}"
|
|
BBOX="${BBOX:-4.7288,52.2783,5.0796,52.4311}" # minLon,minLat,maxLon,maxLat
|
|
|
|
IFS=',' read -r MIN_LON MIN_LAT MAX_LON MAX_LAT <<< "$BBOX"
|
|
|
|
echo "=== Registering offline region: $REGION_NAME ($REGION_ID) ==="
|
|
|
|
psql "$PG_CONN" <<SQL
|
|
CREATE TABLE IF NOT EXISTS offline_regions (
|
|
id TEXT PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
description TEXT,
|
|
bbox GEOMETRY(Polygon, 4326),
|
|
tiles_size_bytes BIGINT NOT NULL DEFAULT 0,
|
|
routing_size_bytes BIGINT NOT NULL DEFAULT 0,
|
|
pois_size_bytes BIGINT NOT NULL DEFAULT 0,
|
|
last_updated TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
INSERT INTO offline_regions (id, name, bbox, tiles_size_bytes, routing_size_bytes, pois_size_bytes, last_updated)
|
|
VALUES (
|
|
'${REGION_ID}',
|
|
'${REGION_NAME}',
|
|
ST_MakeEnvelope(${MIN_LON}, ${MIN_LAT}, ${MAX_LON}, ${MAX_LAT}, 4326),
|
|
0,
|
|
0,
|
|
0,
|
|
NOW()
|
|
)
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
last_updated = NOW();
|
|
SQL
|
|
|
|
echo "Region $REGION_ID registered."
|