diff --git a/api/services.go b/api/services.go index d721c22..5fbfef3 100644 --- a/api/services.go +++ b/api/services.go @@ -101,13 +101,14 @@ func ServiceToJSON(service models.Service, language string, verbose bool) map[st func serviceStopToJSON(stop models.ServiceStop, language string, verbose bool) map[string]interface{} { stopResponse := map[string]interface{}{ - "station": stop.Station, - "station_accessible": stop.StationAccessible, - "assistance_available": stop.AssistanceAvailable, - "stopping_actual": stop.StoppingActual, - "stopping_planned": stop.StoppingPlanned, - "stop_type": stop.StopType, - "do_not_board": stop.DoNotBoard, + "station": stop.Station, + "recognizable_destination": stop.RecognizableDestination, + "station_accessible": stop.StationAccessible, + "assistance_available": stop.AssistanceAvailable, + "stopping_actual": stop.StoppingActual, + "stopping_planned": stop.StoppingPlanned, + "stop_type": stop.StopType, + "do_not_board": stop.DoNotBoard, "arrival_time": localTimeString(stop.ArrivalTime), "arrival_platform_actual": nullString(stop.ArrivalPlatformActual), @@ -126,6 +127,14 @@ func serviceStopToJSON(stop models.ServiceStop, language string, verbose bool) m "material": materialsToJSON(stop.Material, language, verbose), } + if stop.DoNotBoard { + if language == "nl" { + stopResponse["remarks"] = append(stopResponse["tips"].([]interface{}), "Niet instappen") + } else { + stopResponse["remarks"] = append(stopResponse["tips"].([]interface{}), "Do not board") + } + } + return stopResponse } diff --git a/config/example.yaml b/config/example.yaml index f2176c4..9418392 100644 --- a/config/example.yaml +++ b/config/example.yaml @@ -4,7 +4,7 @@ source: envelopes: arrivals: "/RIG/InfoPlusDASInterface4" departures: "/RIG/InfoPlusDVSInterface4" - services: "/RIG/InfoPlusRITInterface2" + services: "/RIG/InfoPlusRITInterface5" api: address: ":8080" stores: diff --git a/models/service.go b/models/service.go index c1371c2..04d25b7 100644 --- a/models/service.go +++ b/models/service.go @@ -37,7 +37,8 @@ type ServicePart struct { // ServiceStop is a stops which is called by a train service. type ServiceStop struct { - Station Station + Station Station + RecognizableDestination *Station StationAccessible bool AssistanceAvailable bool diff --git a/parsers/ritparser.go b/parsers/ritparser.go index 02fc9d1..22e87ad 100644 --- a/parsers/ritparser.go +++ b/parsers/ritparser.go @@ -76,6 +76,12 @@ func ParseRitMessage(reader io.Reader) (service models.Service, err error) { } } + // Check for recognizable destination: + if stopInfo.SelectElement("HerkenbareBestemming") != nil { + recognizableDestination := ParseInfoPlusStation(stopInfo.SelectElement("HerkenbareBestemming").SelectElement("Station")) + serviceStop.RecognizableDestination = &recognizableDestination + } + // Accessibility: serviceStop.StationAccessible = ParseInfoPlusBoolean(stopInfo.SelectElement("StationToegankelijk")) serviceStop.AssistanceAvailable = ParseInfoPlusBoolean(stopInfo.SelectElement("StationReisAssistentie"))