Add 'interesting routes' to quays

This way only the routes we're actually interested in will be
displayed.
main
Jasper Bok 2023-08-06 23:18:47 +02:00
parent 6d211b5a1e
commit b920893097
2 changed files with 23 additions and 4 deletions

5
bus.go
View File

@ -103,7 +103,10 @@ func getDepartures(quay Quay) ([]Departure, error) {
if err != nil {
return departures, err
}
departures = append(departures, d)
if quay.IsInterestingDeparture(d) {
departures = append(departures, d)
}
}
}

22
main.go
View File

@ -4,10 +4,26 @@ import (
"net/http"
)
type Route struct {
RouteShortName string `json:"route_short_name"`
RouteLongName string `json:"route_long_name"`
}
type Quay struct {
ID string `json:"quayid"`
Name string `json:"name"`
Town string `json:"town"`
ID string `json:"quayid"`
Name string `json:"name"`
Town string `json:"town"`
RoutesOfInterest []Route
}
func (q Quay) IsInterestingDeparture(d Departure) bool {
for _, route := range q.RoutesOfInterest {
if (route.RouteShortName == d.RouteShortName) && (route.RouteLongName == d.StopHeadsign) {
return true
}
}
return false
}
var BusClient *http.Client