62 lines
2.4 KiB
Dart
62 lines
2.4 KiB
Dart
import 'package:get/get.dart';
|
|
import 'package:intaleq_maps/intaleq_maps.dart';
|
|
import '../services/tactical_isochrone_engine.dart';
|
|
|
|
/// ============================================================================
|
|
/// [IsochroneController] - وحدة التحكم بنطاق التدخل السريع وزمن الاستجابة
|
|
/// ============================================================================
|
|
/// English:
|
|
/// GetX Controller managing Quick Reaction Force (QRF) and emergency reachability
|
|
/// isochrone polygons with terrain slope resistance factors.
|
|
///
|
|
/// العربية:
|
|
/// متحكم GetX لإدارة مضلعات زمن الاستجابة لقوات التدخل السريع (QRF) والإسعاف،
|
|
/// مع احتساب تأثير انحدار التضاريس ومقاومة حركة الآليات.
|
|
/// ============================================================================
|
|
class IsochroneController extends GetxController {
|
|
// ── Observables / الحالات التفاعلية ──────────────────────────────────────
|
|
final Rx<LatLng?> center = Rx<LatLng?>(null);
|
|
final RxDouble speedKmh = 60.0.obs;
|
|
final RxBool isLoading = false.obs;
|
|
final RxList<IsochroneRing> isochroneRings = <IsochroneRing>[].obs;
|
|
|
|
/// Set QRF Base Location / تعيين مركز انطلاق قوة التدخل السريع
|
|
void setCenter(LatLng pos) {
|
|
center.value = pos;
|
|
calculateIsochrones();
|
|
}
|
|
|
|
/// Set Average Movement Speed / ضبط متوسط سرعة الآليات (كم/ساعة)
|
|
void setSpeed(double speed) {
|
|
speedKmh.value = speed;
|
|
calculateIsochrones();
|
|
}
|
|
|
|
/// Compute Multi-tier Reachability Rings / احتساب مضلعات الوصول (5، 10، 15 دقيقة)
|
|
Future<void> calculateIsochrones() async {
|
|
if (center.value == null) {
|
|
isochroneRings.clear();
|
|
return;
|
|
}
|
|
|
|
try {
|
|
isLoading.value = true;
|
|
final rings = await TacticalIsochroneEngine.calculateIsochrones(
|
|
center: center.value!,
|
|
baseSpeedKmh: speedKmh.value,
|
|
);
|
|
isochroneRings.assignAll(rings);
|
|
} catch (e) {
|
|
isochroneRings.clear();
|
|
} finally {
|
|
isLoading.value = false;
|
|
}
|
|
}
|
|
|
|
/// Reset isochrone state / إعادة ضبط نطاق الوصول
|
|
void reset() {
|
|
center.value = null;
|
|
isochroneRings.clear();
|
|
}
|
|
}
|