aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-05-06 22:05:05 +0200
committerGuido Günther <agx@sigxcpu.org>2015-05-07 10:41:56 +0200
commit51ceb537e0bef66ecac1de1a7792c730486a74b7 (patch)
tree8d3c92d293096e4fa3e990705b3771dd5e1ca1a8
parentff4b3279432b8f0facda456c15a6b2ba597c6909 (diff)
hafas: Detect canceled trips via a flag in HafasBin6TripPartDetail
We currently bubble this up to the whole trip.
-rw-r--r--libplanfahr/providers/hafas-bin6-format.h5
-rw-r--r--libplanfahr/providers/hafas-bin6.c10
2 files changed, 14 insertions, 1 deletions
diff --git a/libplanfahr/providers/hafas-bin6-format.h b/libplanfahr/providers/hafas-bin6-format.h
index 583d21b..7b4fd68 100644
--- a/libplanfahr/providers/hafas-bin6-format.h
+++ b/libplanfahr/providers/hafas-bin6-format.h
@@ -225,11 +225,14 @@ typedef struct _HafasBin6TripPartDetail {
guint16 arr_pred; /* predicted arrival time */ /* 0x02 */
guint16 dep_pos_pred_off; /* offset into string table */ /* 0x04 */
guint16 arr_pos_pred_off; /* offset into string table */ /* 0x06 */
- guint32 unknown0; /* 0x08 */
+ guint16 flags; /* flags */ /* 0x08 */
+ guint16 unknown0; /* 0x0a */
guint16 stop_index; /* index of first stop */ /* 0x0c */
guint16 stops_cnt; /* number of stops */ /* 0x0e */
} HafasBin6TripPartDetail;
+#define HAFAS_BIN6_PART_DETAIL_FLAGS_CANCELED 0x10 /* trip was cancelled */
+
/**
* HafasBin6Stop:
*
diff --git a/libplanfahr/providers/hafas-bin6.c b/libplanfahr/providers/hafas-bin6.c
index 4649a6a..35b071c 100644
--- a/libplanfahr/providers/hafas-bin6.c
+++ b/libplanfahr/providers/hafas-bin6.c
@@ -298,11 +298,14 @@ hafas_bin6_parse_each_trip (const gchar *data, gsize num, guint base, const char
LpfTrip *trip = NULL;
LpfTripPart *part = NULL;
LpfStop *start = NULL, *end = NULL, *astop = NULL;
+ LpfTripStatusFlags status;
GDateTime *dt;
GSList *trips = NULL, *parts = NULL, *stops = NULL;
const char *line;
for (i = 0; i < num; i++) {
+ status = LPF_TRIP_STATUS_FLAGS_NONE;
+
/* The trips itself */
t = HAFAS_BIN6_TRIP(data, i);
day_off = lpf_provider_hafas_bin6_parse_service_day(data, i);
@@ -354,6 +357,11 @@ hafas_bin6_parse_each_trip (const gchar *data, gsize num, guint base, const char
/* trip part details */
pd = HAFAS_BIN6_TRIP_PART_DETAIL(data, i, j);
+ LPF_DEBUG("Trip-Part #%d, Flags: %4d", j, pd->flags);
+ if (pd->flags & HAFAS_BIN6_PART_DETAIL_FLAGS_CANCELED) {
+ status = LPF_TRIP_STATUS_FLAGS_CANCELED;
+ }
+
if (pd->arr_pred != HAFAS_BIN6_NO_REALTIME) {
h = pd->arr_pred / 100;
m = pd->arr_pred % 100;
@@ -415,8 +423,10 @@ hafas_bin6_parse_each_trip (const gchar *data, gsize num, guint base, const char
parts = g_slist_append (parts, part);
part = NULL;
}
+
trip = g_object_new (LPF_TYPE_TRIP,
"parts", parts,
+ "status", status,
NULL);
parts = NULL;
trips = g_slist_append (trips, trip);