MobilApp/lib/services/location_source.dart

62 lines
1.5 KiB
Dart
Raw Normal View History

2026-05-10 02:31:27 +02:00
import 'dart:async';
/// Egyetlen mért pozíció egységes reprezentációja.
/// Mindkét forrás (telefon GPS, BLE GNSS) ezt adja vissza.
class SourcePosition {
final double latitude;
final double longitude;
/// Ellipszoidi magasság [m] — telefonnál a platform adja,
/// BLE GNSS-nél a NMEA h = H + N értéke.
final double? altitude;
/// Vízszintes pontossági becslés [m] (1σ).
final double? accuracy;
/// Vertikális pontossági becslés [m].
final double? verticalAccuracy;
/// Pillanatnyi sebesség [m/s].
final double? speed;
/// Irányszög [fok, 0360, É=0].
final double? heading;
final DateTime timestamp;
/// Forrás azonosítója a naplókhoz.
final String source;
const SourcePosition({
required this.latitude,
required this.longitude,
this.altitude,
this.accuracy,
this.verticalAccuracy,
this.speed,
this.heading,
required this.timestamp,
required this.source,
});
@override
String toString() =>
'SourcePosition($source @ $latitude, $longitude, alt=${altitude?.toStringAsFixed(1)}m)';
}
/// Absztrakt helymeghatározási forrás.
/// Implementációk: [PhoneGpsSource], [BleGnssSource].
abstract class LocationSource {
/// Emberbarát név (pl. "Telefon GPS", "TiGNSS Rover").
String get displayName;
/// Elindítja a pozíció-streamet.
Stream<SourcePosition> get positionStream;
/// Igaz, ha a forrás jelenleg aktív / kapcsolódott.
bool get isAvailable;
/// Leállítja és felszabadítja az erőforrásokat.
Future<void> dispose();
}