change app name, add route calculator
This commit is contained in:
@@ -81,37 +81,71 @@ class YearlyMileage {
|
||||
);
|
||||
}
|
||||
|
||||
class LocoSummary {
|
||||
final String locoType, locoClass, locoNumber, locoName, locoOperator;
|
||||
final String? locoNotes, locoEvn;
|
||||
final int locoId;
|
||||
final int? locoJourneys;
|
||||
final double? locoMileage;
|
||||
class Loco {
|
||||
final int id;
|
||||
final String type, number, locoClass;
|
||||
final String? name, operator, notes, evn;
|
||||
|
||||
LocoSummary({
|
||||
required this.locoType,
|
||||
Loco({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.number,
|
||||
required this.name,
|
||||
required this.locoClass,
|
||||
required this.locoNumber,
|
||||
required this.locoName,
|
||||
required this.locoOperator,
|
||||
this.locoNotes,
|
||||
this.locoEvn,
|
||||
required this.locoId,
|
||||
this.locoMileage,
|
||||
this.locoJourneys,
|
||||
required this.operator,
|
||||
this.notes,
|
||||
this.evn,
|
||||
});
|
||||
|
||||
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
|
||||
locoType: json['loco_type'],
|
||||
factory Loco.fromJson(Map<String, dynamic> json) => Loco(
|
||||
id: json['loco_id'],
|
||||
type: json['loco_type'],
|
||||
number: json['loco_number'],
|
||||
name: json['loco_name'] ?? "",
|
||||
locoClass: json['loco_class'],
|
||||
operator: json['loco_operator'],
|
||||
notes: json['loco_notes'],
|
||||
evn: json['loco_evn'],
|
||||
);
|
||||
}
|
||||
|
||||
class LocoSummary extends Loco {
|
||||
final double? mileage;
|
||||
final int? journeys;
|
||||
|
||||
LocoSummary({
|
||||
required int locoId,
|
||||
required String locoType,
|
||||
required String locoNumber,
|
||||
required String locoName,
|
||||
required String locoClass,
|
||||
required String locoOperator,
|
||||
String? locoNotes,
|
||||
String? locoEvn,
|
||||
this.mileage,
|
||||
this.journeys,
|
||||
}) : super(
|
||||
id: locoId,
|
||||
type: locoType,
|
||||
number: locoNumber,
|
||||
name: locoName,
|
||||
locoClass: locoClass,
|
||||
operator: locoOperator,
|
||||
notes: locoNotes,
|
||||
evn: locoEvn,
|
||||
);
|
||||
|
||||
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
|
||||
locoId: json['loco_id'],
|
||||
locoType: json['loco_type'],
|
||||
locoNumber: json['loco_number'],
|
||||
locoName: json['loco_name'] ?? "",
|
||||
locoClass: json['loco_class'],
|
||||
locoOperator: json['loco_operator'],
|
||||
locoNotes: json['loco_notes'],
|
||||
locoEvn: json['loco_evn'],
|
||||
locoId: json['loco_id'],
|
||||
locoMileage: (json['loco_mileage'] as num).toDouble(),
|
||||
locoJourneys: json['loco_journeys'],
|
||||
mileage: (json['loco_mileage'] as num?)?.toDouble(),
|
||||
journeys: json['loco_journeys'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,34 +187,6 @@ class TripSummary {
|
||||
);
|
||||
}
|
||||
|
||||
class Loco {
|
||||
final int id;
|
||||
final String type, number, name, locoClass, operator;
|
||||
final String? notes, evn;
|
||||
|
||||
Loco({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.number,
|
||||
required this.name,
|
||||
required this.locoClass,
|
||||
required this.operator,
|
||||
this.notes,
|
||||
this.evn,
|
||||
});
|
||||
|
||||
factory Loco.fromJson(Map<String, dynamic> json) => Loco(
|
||||
id: json['loco_id'],
|
||||
type: json['loco_type'],
|
||||
number: json['loco_number'],
|
||||
name: json['loco_name'] ?? "",
|
||||
locoClass: json['loco_class'],
|
||||
operator: json['loco_operator'],
|
||||
notes: json['loco_notes'],
|
||||
evn: json['loco_evn'],
|
||||
);
|
||||
}
|
||||
|
||||
class Leg {
|
||||
final int id, tripId, timezone, driving;
|
||||
final String start, end, route, network, notes, headcode, user;
|
||||
@@ -224,3 +230,58 @@ class Leg {
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
class RouteError {
|
||||
final String error;
|
||||
final String msg;
|
||||
|
||||
RouteError({required this.error, required this.msg});
|
||||
|
||||
factory RouteError.fromJson(Map<String, dynamic> json) {
|
||||
return RouteError(error: json["error"], msg: json["msg"]);
|
||||
}
|
||||
}
|
||||
|
||||
class RouteResult {
|
||||
final List<String> inputRoute;
|
||||
final List<String> calculatedRoute;
|
||||
final List<double> costs;
|
||||
final double distance;
|
||||
|
||||
RouteResult({
|
||||
required this.inputRoute,
|
||||
required this.calculatedRoute,
|
||||
required this.costs,
|
||||
required this.distance,
|
||||
});
|
||||
|
||||
factory RouteResult.fromJson(Map<String, dynamic> json) {
|
||||
return RouteResult(
|
||||
inputRoute: List<String>.from(json['input_route']),
|
||||
calculatedRoute: List<String>.from(json['calculated_route']),
|
||||
costs: (json['costs'] as List).map((e) => (e as num).toDouble()).toList(),
|
||||
distance: (json['distance'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Station {
|
||||
final int id;
|
||||
final String name;
|
||||
final String network;
|
||||
final String country;
|
||||
|
||||
Station({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.network,
|
||||
required this.country,
|
||||
});
|
||||
|
||||
factory Station.fromJson(Map<String, dynamic> json) => Station(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
network: json['network'],
|
||||
country: json['country'],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user