import 'package:latlong2/latlong.dart'; import 'camera_profile.dart'; class PendingUpload { final LatLng coord; final double direction; final CameraProfile profile; final int? originalNodeId; // If this is an edit, the ID of the original OSM node int attempts; bool error; PendingUpload({ required this.coord, required this.direction, required this.profile, this.originalNodeId, this.attempts = 0, this.error = false, }); // True if this is an edit of an existing camera, false if it's a new camera bool get isEdit => originalNodeId != null; Map toJson() => { 'lat': coord.latitude, 'lon': coord.longitude, 'dir': direction, 'profile': profile.toJson(), 'originalNodeId': originalNodeId, 'attempts': attempts, 'error': error, }; factory PendingUpload.fromJson(Map j) => PendingUpload( coord: LatLng(j['lat'], j['lon']), direction: j['dir'], profile: j['profile'] is Map ? CameraProfile.fromJson(j['profile']) : CameraProfile.genericAlpr(), originalNodeId: j['originalNodeId'], attempts: j['attempts'] ?? 0, error: j['error'] ?? false, ); }