From 51ceb537e0bef66ecac1de1a7792c730486a74b7 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Wed, 6 May 2015 22:05:05 +0200 Subject: hafas: Detect canceled trips via a flag in HafasBin6TripPartDetail We currently bubble this up to the whole trip. --- libplanfahr/providers/hafas-bin6-format.h | 5 ++++- libplanfahr/providers/hafas-bin6.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'libplanfahr/providers') 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); -- cgit v1.2.3