Add 'interesting routes' to quays
This way only the routes we're actually interested in will be displayed.main
parent
6d211b5a1e
commit
b920893097
5
bus.go
5
bus.go
|
@ -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
22
main.go
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue