Files
PilotVault/Fly App/lib/flight_model.dart
T
tajniak81andClaude Opus 4.8 94f6876024 Add location-aware automatic default bounding box
The OpenSky "Default bounding box" now follows where flying happens.
A new "Automatic" picker mode (the default) resolves the live-map area
from a location cascade — drone telemetry → phone GPS → browser
geolocation → the user's Region country → Europe — instead of a fixed
box. Manual presets and Custom coordinates still work.

- Web App: new shared countries.js dataset (all countries + bbox,
  offline point→country); the bbox picker gains all European countries
  and an Automatic option (client pref prefs.autoBbox); the Region
  setting expands from 6 locale entries to all countries; the live map
  resolves the cascade each poll and sends it as ?bbox=.
- API Server: the states endpoint accepts and validates a ?bbox=
  override (validBBox); the Web App BFF forwards the query; the hub
  relays new phoneLatitude/phoneLongitude telemetry to the Web App.
- Fly App: reports the phone's own GPS (geolocator) alongside
  telemetry, used as the "your location" fallback.
- API panel: the OpenSky bbox picker lists all European countries.

Builds verified across web, panel, both Go modules and the Fly App
APK. Region list, Automatic default and the cascade ?bbox= override
verified in the browser.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-14 00:07:12 +02:00

37 lines
1.1 KiB
Dart

import 'package:flutter/foundation.dart';
import 'uploader.dart';
enum RegistrationState { idle, registering, success, failed }
/// Live aircraft/session state, shared by the Go Fly launch screen and the
/// Flight Control overlay. [_HomePageState] owns the DJI/uploader plumbing and
/// pushes updates here; the screens observe it via [AnimatedBuilder].
class FlightModel extends ChangeNotifier {
String sdkVersion = '…';
RegistrationState registration = RegistrationState.idle;
String? registrationError;
bool connected = false;
String? model;
int? satellites;
bool? isFlying;
String? flightMode;
double? altitude;
double? latitude;
double? longitude;
// Phone's own GPS (independent of the drone's fix above); streamed to the
// server as a location fallback for the Web App's automatic bounding box.
double? phoneLatitude;
double? phoneLongitude;
int? batteryPercent;
UploadStatus upload = UploadStatus.disabled;
bool get registered => registration == RegistrationState.success;
/// Notify observers after a batch of field writes.
void bump() => notifyListeners();
}