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

3
bus.go
View File

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

16
main.go
View File

@ -4,10 +4,26 @@ import (
"net/http" "net/http"
) )
type Route struct {
RouteShortName string `json:"route_short_name"`
RouteLongName string `json:"route_long_name"`
}
type Quay struct { type Quay struct {
ID string `json:"quayid"` ID string `json:"quayid"`
Name string `json:"name"` Name string `json:"name"`
Town string `json:"town"` 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 var BusClient *http.Client