golifehk/datasources/mtr/bus/BusStop.go

34 lines
786 B
Go
Raw Normal View History

2022-09-14 13:21:39 +00:00
package bus
type BusStop struct {
RouteId string
Direction string
StationSeq int
StationId string
Latitude float64
Longtitude float64
Name *map[string] string
RouteStops *map[int] *BusStop
}
func ( busStop BusStop ) PrevStop() *BusStop {
if v, hasKey := (*busStop.RouteStops)[ busStop.StationSeq - 1 ]; hasKey {
return v
}
return nil
}
func ( busStop BusStop ) NextStop() *BusStop {
if v, hasKey := (*busStop.RouteStops)[ busStop.StationSeq + 1 ]; hasKey {
return v
}
return nil
}
2022-09-15 13:38:04 +00:00
type ByRouteId []BusStop
func (a ByRouteId) Len() int { return len(a) }
func (a ByRouteId) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRouteId) Less(i, j int) bool { return a[i].RouteId < a[j].RouteId }