fix(routing): allow bidirectional travel on two-way corridors
- u_turn_costs: 60 (was infinite -> U-turns forbidden -> huge detours) - distance_influence 70 -> 20, de-prioritise service/living_street/track - restore safe ignored_highways (was "" -> footways imported, bad snapping) - profiles_ch -> profiles_lm (edge-based CH too heavy with turn_costs) - server port 8989 -> 8080 to match compose mapping, healthcheck and API - add normalize-oneway + check-bidirectional tooling
This commit is contained in:
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
# --------------------------------------------------------------------------
|
||||
# normalize-oneway.sh — تشغيل تصحيح الاتجاهات وإعادة بناء رسم GraphHopper
|
||||
#
|
||||
# الاستخدام:
|
||||
# 1) تقرير فقط (لا يعدّل شيئاً):
|
||||
# bash infrastructure/scripts/normalize-oneway.sh audit
|
||||
# → infrastructure/osm-data/oneway-audit.csv
|
||||
#
|
||||
# 2) تعديل طرق محددة بالاسم (الأكثر أماناً):
|
||||
# bash infrastructure/scripts/normalize-oneway.sh apply --names "طريق السخنة"
|
||||
#
|
||||
# 3) تعديل قائمة way_ids معتمدة بعد مراجعة التقرير:
|
||||
# bash infrastructure/scripts/normalize-oneway.sh apply \
|
||||
# --allowlist infrastructure/osm-data/oneway-allowlist.txt
|
||||
#
|
||||
# 4) تعديل شامل لأصناف كاملة (خطر — يكسر الطرق المزدوجة الصحيحة):
|
||||
# bash infrastructure/scripts/normalize-oneway.sh apply --force
|
||||
#
|
||||
# بعد apply يعيد السكربت بناء الرسم: يحذف graph-cache ويقلع map-routing.
|
||||
# النسخة الأصلية من الـ PBF تبقى كما هي (master_map.osm.pbf.orig).
|
||||
# --------------------------------------------------------------------------
|
||||
set -euo pipefail
|
||||
|
||||
DATA_DIR="./infrastructure/osm-data"
|
||||
PBF="$DATA_DIR/master_map.osm.pbf"
|
||||
VENV="./.venv-osm"
|
||||
PY="$VENV/bin/python"
|
||||
SCRIPT="./infrastructure/scripts/normalize_oneway.py"
|
||||
|
||||
MODE="${1:-audit}"
|
||||
shift || true
|
||||
|
||||
[ -f "$PBF" ] || { echo "❌ الملف غير موجود: $PBF"; exit 1; }
|
||||
|
||||
# ── بيئة pyosmium ────────────────────────────────────────────────────────
|
||||
if [ ! -x "$PY" ]; then
|
||||
echo "📦 تهيئة بيئة pyosmium..."
|
||||
python3 -m venv "$VENV"
|
||||
"$VENV/bin/pip" install --quiet --upgrade pip
|
||||
"$VENV/bin/pip" install --quiet osmium
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "audit" ]; then
|
||||
"$PY" "$SCRIPT" audit --input "$PBF" --report "$DATA_DIR/oneway-audit.csv" "$@"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" != "apply" ]; then
|
||||
echo "❌ الوضع غير معروف: $MODE (المتاح: audit | apply)"; exit 1
|
||||
fi
|
||||
|
||||
# ── تعديل البيانات ───────────────────────────────────────────────────────
|
||||
TMP="$DATA_DIR/master_map.normalized.osm.pbf"
|
||||
rm -f "$TMP"
|
||||
"$PY" "$SCRIPT" apply --input "$PBF" --output "$TMP" "$@"
|
||||
|
||||
if [ ! -f "$PBF.orig" ]; then
|
||||
echo "💾 حفظ نسخة أصلية: $PBF.orig"
|
||||
cp "$PBF" "$PBF.orig"
|
||||
fi
|
||||
mv "$TMP" "$PBF"
|
||||
|
||||
# ── إعادة بناء الرسم ─────────────────────────────────────────────────────
|
||||
# GraphHopper لا يعيد قراءة الـ PBF إن كان graph-cache موجوداً.
|
||||
echo "🧹 حذف graph-cache وإعادة بناء الرسم..."
|
||||
docker compose stop routing || true
|
||||
rm -rf "$DATA_DIR/graph-cache"
|
||||
docker compose up -d routing
|
||||
|
||||
echo "⏳ انتظار جهوزية المحرك (قد يستغرق البناء عدة دقائق)..."
|
||||
for i in $(seq 1 120); do
|
||||
if curl -fsS http://localhost:8989/health >/dev/null 2>&1; then
|
||||
echo "✅ map-routing جاهز."
|
||||
exit 0
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
echo "⚠️ لم يستجب المحرك بعد 20 دقيقة — راجع: docker compose logs -f routing"
|
||||
exit 1
|
||||
Reference in New Issue
Block a user