Jármű navigáció @3h
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
/// Periodikus járműpozíció-minta — a navigációs oldal a beállított
|
||||
/// időközönként ide ment egy sort, amíg a rögzítés fut. Ebből (és a
|
||||
/// SourcePoint terv-pozíciókból) számítható utólag, mely forráspontok
|
||||
/// mellett járt ténylegesen a jármű.
|
||||
class VehiclePositionLog {
|
||||
final int? id;
|
||||
final String uuid;
|
||||
final int projectId;
|
||||
|
||||
final String vehicleId; // pl. "V1" / "V2" / "V3"
|
||||
|
||||
final double eovY;
|
||||
final double eovX;
|
||||
final double lat;
|
||||
final double lon;
|
||||
final double? altitude;
|
||||
final double? speedKmh;
|
||||
final double? heading;
|
||||
final int? fixQuality;
|
||||
final double? accuracy;
|
||||
|
||||
final DateTime timestamp;
|
||||
final String? deviceId;
|
||||
final String? appInstanceId;
|
||||
|
||||
VehiclePositionLog({
|
||||
this.id,
|
||||
String? uuid,
|
||||
required this.projectId,
|
||||
required this.vehicleId,
|
||||
required this.eovY,
|
||||
required this.eovX,
|
||||
required this.lat,
|
||||
required this.lon,
|
||||
this.altitude,
|
||||
this.speedKmh,
|
||||
this.heading,
|
||||
this.fixQuality,
|
||||
this.accuracy,
|
||||
DateTime? timestamp,
|
||||
this.deviceId,
|
||||
this.appInstanceId,
|
||||
}) : uuid = uuid ?? const Uuid().v4(),
|
||||
timestamp = timestamp ?? DateTime.now();
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
if (id != null) 'id': id,
|
||||
'uuid': uuid,
|
||||
'project_id': projectId,
|
||||
'vehicle_id': vehicleId,
|
||||
'eov_y': eovY,
|
||||
'eov_x': eovX,
|
||||
'lat': lat,
|
||||
'lon': lon,
|
||||
'altitude': altitude,
|
||||
'speed_kmh': speedKmh,
|
||||
'heading': heading,
|
||||
'fix_quality': fixQuality,
|
||||
'accuracy': accuracy,
|
||||
'timestamp': timestamp.toIso8601String(),
|
||||
'device_id': deviceId,
|
||||
'app_instance_id': appInstanceId,
|
||||
};
|
||||
|
||||
factory VehiclePositionLog.fromMap(Map<String, dynamic> m) =>
|
||||
VehiclePositionLog(
|
||||
id: m['id'] as int?,
|
||||
uuid: m['uuid'] as String,
|
||||
projectId: m['project_id'] as int,
|
||||
vehicleId: (m['vehicle_id'] as String?) ?? '',
|
||||
eovY: (m['eov_y'] as num).toDouble(),
|
||||
eovX: (m['eov_x'] as num).toDouble(),
|
||||
lat: (m['lat'] as num).toDouble(),
|
||||
lon: (m['lon'] as num).toDouble(),
|
||||
altitude: (m['altitude'] as num?)?.toDouble(),
|
||||
speedKmh: (m['speed_kmh'] as num?)?.toDouble(),
|
||||
heading: (m['heading'] as num?)?.toDouble(),
|
||||
fixQuality: m['fix_quality'] as int?,
|
||||
accuracy: (m['accuracy'] as num?)?.toDouble(),
|
||||
timestamp: DateTime.tryParse((m['timestamp'] as String?) ?? '') ??
|
||||
DateTime.now(),
|
||||
deviceId: m['device_id'] as String?,
|
||||
appInstanceId: m['app_instance_id'] as String?,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user