2026-04-13-4
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
# overture_ingest.sh - Data pipeline for Overture Maps
|
||||
# سكريبت سحب وحقن بيانات المباني والشوارع
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
DB_HOST="localhost"
|
||||
DB_PORT="5432"
|
||||
DB_USER="mapuser"
|
||||
DB_NAME="mapdb"
|
||||
DB_PASS="mappass"
|
||||
|
||||
# Jordan North BBOX (Amman, Irbid, Zarqa)
|
||||
BBOX_JORDAN_NORTH="35.5,31.7,39.3,33.4"
|
||||
# Jordan South BBOX (Aqaba, Karak, Ma'an)
|
||||
BBOX_JORDAN_SOUTH="34.9,29.1,38.0,31.7"
|
||||
# Syria BBOX (Full Country)
|
||||
BBOX_SYRIA="35.7,32.3,42.4,37.3"
|
||||
|
||||
echo "🚀 Starting Overture Data Pipeline (Jordan & Syria)..."
|
||||
|
||||
# 1. Setup Python Environment
|
||||
# ... (rest of setup)
|
||||
if [ ! -d "venv_overture" ]; then
|
||||
echo "📦 Creating virtual environment..."
|
||||
python3 -m venv venv_overture
|
||||
fi
|
||||
source venv_overture/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install overturemaps
|
||||
|
||||
# 2. Function to download and ingest
|
||||
process_city() {
|
||||
local city=$1
|
||||
local bbox=$2
|
||||
local theme=$3 # building, segment, or division_area
|
||||
|
||||
echo "🌍 Processing $city - Theme: $theme..."
|
||||
output_file="overture_${city}_${theme}.geojson"
|
||||
|
||||
# Download
|
||||
overturemaps download --bbox="$bbox" -f geojson --type="$theme" -o "$output_file"
|
||||
|
||||
# If division_area, we use our NestJS API to import for better control
|
||||
if [ "$theme" == "division_area" ]; then
|
||||
echo "📍 Administrative data downloaded: $output_file"
|
||||
echo "💡 Use the NestJS /geocoding/import-boundaries endpoint to ingest this file."
|
||||
return
|
||||
fi
|
||||
|
||||
# Ingest into PostGIS for buildings and segments
|
||||
echo "🔌 Injecting into PostGIS (Table: overture_${theme})..."
|
||||
export PGPASSWORD=$DB_PASS
|
||||
ogr2ogr -f "PostgreSQL" \
|
||||
PG:"host=$DB_HOST port=$DB_PORT user=$DB_USER dbname=$DB_NAME password=$DB_PASS" \
|
||||
"$output_file" \
|
||||
-nln "overture_${theme}" \
|
||||
-update -append \
|
||||
-nlt PROMOTE_TO_MULTI \
|
||||
-lco GEOMETRY_NAME=location
|
||||
|
||||
echo "✅ Finished $city $theme"
|
||||
rm "$output_file"
|
||||
}
|
||||
|
||||
# 3. Execution (Jordan & Syria)
|
||||
# Jordan
|
||||
process_city "jordan_north" "$BBOX_JORDAN_NORTH" "division_area"
|
||||
process_city "jordan_south" "$BBOX_JORDAN_SOUTH" "division_area"
|
||||
|
||||
# Syria
|
||||
process_city "syria" "$BBOX_SYRIA" "division_area"
|
||||
|
||||
echo "🎉 Administrative boundary GeoJSONs ready for import!"
|
||||
Reference in New Issue
Block a user