refactor(tactical-app): modernize state management with GetX controllers, bindings, and clean MVP architecture
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart';
|
||||
import '../services/viewshed_360_engine.dart';
|
||||
|
||||
/// ============================================================================
|
||||
/// [ViewshedController] - وحدة التحكم برادار الرصد الدائري 360°
|
||||
/// ============================================================================
|
||||
/// English:
|
||||
/// GetX Controller managing 360° radial viewshed calculations, observer radar
|
||||
/// radius, visible coverage polygons, and dead ground area metrics.
|
||||
///
|
||||
/// العربية:
|
||||
/// متحكم GetX لإدارة رادار الرصد الدائري 360 درجة، وحساب مضلع التغطية البصرية
|
||||
/// الفعلي ومساحة الرصد بالكيلومتر المربع مع تضاريس الأردن الحقيقية.
|
||||
/// ============================================================================
|
||||
class ViewshedController extends GetxController {
|
||||
// ── Observables / الحالات التفاعلية ──────────────────────────────────────
|
||||
final Rx<LatLng?> observerPosition = Rx<LatLng?>(null);
|
||||
final RxDouble radiusKm = 5.0.obs;
|
||||
final RxDouble observerHeightM = 2.0.obs;
|
||||
final RxBool isCalculating = false.obs;
|
||||
final Rx<Viewshed360Report?> viewshedReport = Rx<Viewshed360Report?>(null);
|
||||
|
||||
/// Set Viewshed Radar Center / تعيين مركز الرادار والرصد
|
||||
void setObserver(LatLng pos) {
|
||||
observerPosition.value = pos;
|
||||
computeViewshed();
|
||||
}
|
||||
|
||||
/// Set Radar Range Radius in KM / ضبط نصف قطر دائرة الرصد بالكيلومتر
|
||||
void setRadius(double km) {
|
||||
radiusKm.value = km;
|
||||
computeViewshed();
|
||||
}
|
||||
|
||||
/// Set Observer Antenna/Tower Height / ضبط ارتفاع سارية الرصد بالمتر
|
||||
void setHeight(double heightM) {
|
||||
observerHeightM.value = heightM;
|
||||
computeViewshed();
|
||||
}
|
||||
|
||||
/// Compute 360 Viewshed / تنفيذ الحساب التفاعلي لحقل الرؤية الدائري
|
||||
Future<void> computeViewshed() async {
|
||||
if (observerPosition.value == null) {
|
||||
viewshedReport.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isCalculating.value = true;
|
||||
final rep = await Viewshed360Engine.calculateAsync(
|
||||
observer: observerPosition.value!,
|
||||
radiusMeters: radiusKm.value * 1000.0,
|
||||
observerHeightM: observerHeightM.value,
|
||||
rayCount: 360,
|
||||
);
|
||||
viewshedReport.value = rep;
|
||||
} catch (e) {
|
||||
viewshedReport.value = null;
|
||||
} finally {
|
||||
isCalculating.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset viewshed state / إعادة ضبط الرادار الدائري
|
||||
void reset() {
|
||||
observerPosition.value = null;
|
||||
viewshedReport.value = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user