maps/backend/scripts/03_import_pois.sh
2026-03-30 11:01:20 +02:00

43 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# scripts/03_import_pois.sh
# Create the pois table and import POI data using osm2pgsql flex output.
set -euo pipefail
PBF_FILE="${PBF_FILE:-/data/osm/region.osm.pbf}"
PG_CONN="${PG_CONN:-postgres://maps:maps@postgres:5432/maps}"
echo "=== Creating pois table ==="
psql "$PG_CONN" <<'SQL'
CREATE TABLE IF NOT EXISTS pois (
osm_id BIGINT NOT NULL,
osm_type CHAR(1) NOT NULL,
name TEXT,
category TEXT,
geometry GEOMETRY(Point, 4326) NOT NULL,
address JSONB,
tags JSONB,
opening_hours TEXT,
phone TEXT,
website TEXT,
wheelchair TEXT,
PRIMARY KEY (osm_type, osm_id)
);
CREATE INDEX IF NOT EXISTS pois_geometry_idx ON pois USING GIST (geometry);
CREATE INDEX IF NOT EXISTS pois_category_idx ON pois (category);
SQL
echo "=== Importing POIs from $PBF_FILE ==="
osm2pgsql \
--create \
--output=flex \
--style /app/scripts/pois.lua \
--database "$PG_CONN" \
--cache 512 \
--number-processes 2 \
"$PBF_FILE"
echo "POI import complete."