Skip to content

Commit

Permalink
Implement HerkbareBestemming (ritinfo v5)
Browse files Browse the repository at this point in the history
  • Loading branch information
geertw committed Jul 7, 2024
1 parent 4521132 commit f730ffb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
23 changes: 16 additions & 7 deletions api/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion config/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source:
envelopes:
arrivals: "/RIG/InfoPlusDASInterface4"
departures: "/RIG/InfoPlusDVSInterface4"
services: "/RIG/InfoPlusRITInterface2"
services: "/RIG/InfoPlusRITInterface5"
api:
address: ":8080"
stores:
Expand Down
3 changes: 2 additions & 1 deletion models/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions parsers/ritparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit f730ffb

Please sign in to comment.