busdepartures/quay.go

29 lines
756 B
Go

package main
import (
"fmt"
"net/url"
)
type Quay struct {
ID string `json:"quayid" toml:"id"`
Name string `json:"name" toml:"name"`
Town string `json:"town" toml:"town"`
RoutesOfInterest []Route `toml:"routes_of_interest"`
}
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
}
func (q Quay) GetBrengUrl() string {
param := fmt.Sprintf("{\"quayid\":\"%s\",\"name\":\"%s\",\"town\":\"%s\"}", q.ID, q.Name, q.Town)
return fmt.Sprintf("https://www.breng.nl/nl/resultaten/halte-informatie/?stop=%s", url.QueryEscape(param))
}