Files
MobilApp/lib/models/source_point.dart
T
2026-07-13 07:58:51 +02:00

75 lines
2.2 KiB
Dart

import 'package:uuid/uuid.dart';
/// Forráspont (vibrátor-állomás) — az SPS S-fájlból importált TERV-pozíció.
///
/// Tisztán referencia-réteg: nincs "kijelölve/meglőve" mutálható állapota
/// (a döntés szerint a tényleges ellenőrzés a periodikus pozíciónapló és
/// a terv UTÓLAGOS összevetéséből adódik — lásd VibratorNavController).
class SourcePoint {
final int? id;
final String uuid;
final int projectId;
final String lineId;
final int station; // VP (vibration point) szám
final double planEovY;
final double planEovX;
final double planLat;
final double planLon;
final String source; // 'sps'
final String? importBatch;
final DateTime createdAt;
SourcePoint({
this.id,
String? uuid,
required this.projectId,
required this.lineId,
required this.station,
required this.planEovY,
required this.planEovX,
required this.planLat,
required this.planLon,
this.source = 'sps',
this.importBatch,
DateTime? createdAt,
}) : uuid = uuid ?? const Uuid().v4(),
createdAt = createdAt ?? DateTime.now();
String get displayId => '$lineId · $station';
Map<String, dynamic> toMap() => {
if (id != null) 'id': id,
'uuid': uuid,
'project_id': projectId,
'line_id': lineId,
'station': station,
'plan_eov_y': planEovY,
'plan_eov_x': planEovX,
'plan_lat': planLat,
'plan_lon': planLon,
'source': source,
'import_batch': importBatch,
'created_at': createdAt.toIso8601String(),
};
factory SourcePoint.fromMap(Map<String, dynamic> m) => SourcePoint(
id: m['id'] as int?,
uuid: m['uuid'] as String,
projectId: m['project_id'] as int,
lineId: (m['line_id'] as String?) ?? '',
station: m['station'] as int,
planEovY: (m['plan_eov_y'] as num).toDouble(),
planEovX: (m['plan_eov_x'] as num).toDouble(),
planLat: (m['plan_lat'] as num).toDouble(),
planLon: (m['plan_lon'] as num).toDouble(),
source: (m['source'] as String?) ?? 'sps',
importBatch: m['import_batch'] as String?,
createdAt: DateTime.tryParse((m['created_at'] as String?) ?? '') ??
DateTime.now(),
);
}