Public Access
feat(transport_helper: add "ref" to Segments for journeyDetails later
This commit is contained in:
@@ -309,7 +309,9 @@ class Route {
|
|||||||
class Segment {
|
class Segment {
|
||||||
static const String tableName = "segment";
|
static const String tableName = "segment";
|
||||||
|
|
||||||
|
// TODO: add attribute for departures on the way?
|
||||||
int? id;
|
int? id;
|
||||||
|
String ref;
|
||||||
Station startPoint;
|
Station startPoint;
|
||||||
Station endPoint;
|
Station endPoint;
|
||||||
DateTime startTime;
|
DateTime startTime;
|
||||||
@@ -318,6 +320,7 @@ class Segment {
|
|||||||
|
|
||||||
Segment({
|
Segment({
|
||||||
this.id, // might throw errors - needs testing, I guess
|
this.id, // might throw errors - needs testing, I guess
|
||||||
|
required this.ref,
|
||||||
required this.startPoint,
|
required this.startPoint,
|
||||||
required this.endPoint,
|
required this.endPoint,
|
||||||
required this.startTime,
|
required this.startTime,
|
||||||
@@ -327,6 +330,7 @@ class Segment {
|
|||||||
|
|
||||||
Map<String, Object?> toMap() {
|
Map<String, Object?> toMap() {
|
||||||
return {
|
return {
|
||||||
|
"ref": ref,
|
||||||
"startpoint": startPoint.id,
|
"startpoint": startPoint.id,
|
||||||
"endpoint": endPoint.id,
|
"endpoint": endPoint.id,
|
||||||
"starttime": startTime,
|
"starttime": startTime,
|
||||||
@@ -338,6 +342,7 @@ class Segment {
|
|||||||
factory Segment.fromMap(Map<String, Object?> map) {
|
factory Segment.fromMap(Map<String, Object?> map) {
|
||||||
return Segment(
|
return Segment(
|
||||||
id: map["id"] as int,
|
id: map["id"] as int,
|
||||||
|
ref: map["ref"] as String,
|
||||||
startPoint: map["startPoint"] as Station,
|
startPoint: map["startPoint"] as Station,
|
||||||
endPoint: map["endPoint"] as Station,
|
endPoint: map["endPoint"] as Station,
|
||||||
startTime: map["startTime"] as DateTime,
|
startTime: map["startTime"] as DateTime,
|
||||||
@@ -348,6 +353,7 @@ class Segment {
|
|||||||
|
|
||||||
factory Segment.fromJson(Map<String, dynamic> json) {
|
factory Segment.fromJson(Map<String, dynamic> json) {
|
||||||
Segment tmp = Segment(
|
Segment tmp = Segment(
|
||||||
|
ref: json["JourneyDetail"]["ref"],
|
||||||
startPoint: Station.fromJson(json["Origin"]),
|
startPoint: Station.fromJson(json["Origin"]),
|
||||||
endPoint: Station.fromJson(json["Destination"]),
|
endPoint: Station.fromJson(json["Destination"]),
|
||||||
startTime: json["Origin"]["rtTime"],
|
startTime: json["Origin"]["rtTime"],
|
||||||
@@ -372,6 +378,8 @@ class Segment {
|
|||||||
String vehicle = Vehicle.tableName;
|
String vehicle = Vehicle.tableName;
|
||||||
database.execute("""
|
database.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS $tableName(
|
CREATE TABLE IF NOT EXISTS $tableName(
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
ref TEXT,
|
||||||
startpoint TEXT,
|
startpoint TEXT,
|
||||||
endpoint TEXT,
|
endpoint TEXT,
|
||||||
starttime TEXT,
|
starttime TEXT,
|
||||||
@@ -943,4 +951,4 @@ enum VehicleType {
|
|||||||
subway,
|
subway,
|
||||||
regionalTrain,
|
regionalTrain,
|
||||||
PLACEHOLDER,
|
PLACEHOLDER,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user