Files
maps-saas/packages/tactical_app/lib/controllers/hlz_controller.dart
T

74 lines
2.9 KiB
Dart

import 'package:get/get.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import '../models/military_operations_models.dart';
import '../services/hlz_assessment_engine.dart';
/// ============================================================================
/// [HlzController] - وحدة التحكم بتقييم مهابط الطيران العامودي
/// ============================================================================
/// English:
/// GetX Controller managing Helicopter Landing Zone (HLZ) parameters, terrain
/// slope gradient calculations, approach corridor clearances, and suitability scoring.
///
/// العربية:
/// متحكم GetX لإدارة تقييم مهابط المروحيات العسكرية، فحص نسبة انحدار الأرض،
/// سلامة ممرات الاقتراب والإقلاع، وتحديد درجة صلاحية المهبط تكتيكياً.
/// ============================================================================
class HlzController extends GetxController {
// ── Observables / الحالات التفاعلية ──────────────────────────────────────
final Rx<LatLng?> selectedPosition = Rx<LatLng?>(null);
final Rx<HelicopterType> helicopterType =
Rx<HelicopterType>(HelicopterType.mediumLift);
final RxDouble approachAzimuthDeg = 0.0.obs;
final RxBool isLoading = false.obs;
final Rx<HlzAssessmentResult?> assessmentResult =
Rx<HlzAssessmentResult?>(null);
/// Set Landing Pad Center Location / تعيين موقع مركز المهبط المقترح
void setPosition(LatLng pos) {
selectedPosition.value = pos;
assessLandingZone();
}
/// Select Helicopter Airframe Type / تحديد فئة الطوافة (خفيفة / متوسطة / ثقيلة)
void setHelicopterType(HelicopterType type) {
helicopterType.value = type;
assessLandingZone();
}
/// Set Approach Corridor Azimuth / تحديد سمت ممر الاقتراب
void setApproachAzimuth(double azimuthDeg) {
approachAzimuthDeg.value = azimuthDeg;
assessLandingZone();
}
/// Run Full HLZ Assessment / تنفيذ التقييم الميداني الشامل للمهبط
Future<void> assessLandingZone() async {
if (selectedPosition.value == null) {
assessmentResult.value = null;
return;
}
try {
isLoading.value = true;
final res = await HlzAssessmentEngine.assessLandingZone(
center: selectedPosition.value!,
helicopterType: helicopterType.value,
approachAzimuthDeg: approachAzimuthDeg.value,
);
assessmentResult.value = res;
} catch (e) {
assessmentResult.value = null;
} finally {
isLoading.value = false;
}
}
/// Reset HLZ state / إعادة ضبط المهبط
void reset() {
selectedPosition.value = null;
assessmentResult.value = null;
approachAzimuthDeg.value = 0.0;
}
}