Documentation ¶
Overview ¶
Package trimet provides methods to interact with the Trimet API.
Index ¶
- Constants
- func RequestArrivals(apiKey string, ids []int) ([]byte, error)
- func RequestGTFSFile(baseURL string) (*zip.ReadCloser, error)
- type CSV
- type CalendarDate
- type Position
- type Route
- type RouteType
- type Shape
- type Stop
- type StopTime
- type StopTimeEvent
- func (z *StopTimeEvent) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *StopTimeEvent) EncodeMsg(en *msgp.Writer) (err error)
- func (z *StopTimeEvent) MarshalMsg(b []byte) (o []byte, err error)
- func (z *StopTimeEvent) Msgsize() (s int)
- func (z *StopTimeEvent) UnmarshalMsg(bts []byte) (o []byte, err error)
- type StopTimeUpdate
- func (z *StopTimeUpdate) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *StopTimeUpdate) EncodeMsg(en *msgp.Writer) (err error)
- func (z *StopTimeUpdate) MarshalMsg(b []byte) (o []byte, err error)
- func (z *StopTimeUpdate) Msgsize() (s int)
- func (z *StopTimeUpdate) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Time
- func (i *Time) ExtensionType() int8
- func (i *Time) Len() int
- func (i *Time) MarshalBinaryTo(b []byte) error
- func (i *Time) MarshalText() ([]byte, error)
- func (i *Time) Scan(src interface{}) error
- func (i *Time) UnmarshalBinary(b []byte) error
- func (i *Time) UnmarshalText(b []byte) error
- func (i *Time) Value() (driver.Value, error)
- type Trip
- type TripDescriptor
- func (z *TripDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TripDescriptor) EncodeMsg(en *msgp.Writer) (err error)
- func (z *TripDescriptor) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TripDescriptor) Msgsize() (s int)
- func (z *TripDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
- type TripUpdate
- type TripUpdatesMsg
- func (z *TripUpdatesMsg) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TripUpdatesMsg) EncodeMsg(en *msgp.Writer) (err error)
- func (z *TripUpdatesMsg) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TripUpdatesMsg) Msgsize() (s int)
- func (z *TripUpdatesMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
- type VehicleDescriptor
- func (z *VehicleDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *VehicleDescriptor) EncodeMsg(en *msgp.Writer) (err error)
- func (z *VehicleDescriptor) MarshalMsg(b []byte) (o []byte, err error)
- func (z *VehicleDescriptor) Msgsize() (s int)
- func (z *VehicleDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
- type VehiclePosition
- func (z *VehiclePosition) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *VehiclePosition) EncodeMsg(en *msgp.Writer) (err error)
- func (z *VehiclePosition) MarshalMsg(b []byte) (o []byte, err error)
- func (z *VehiclePosition) Msgsize() (s int)
- func (z *VehiclePosition) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
const ( BaseTrimetURL = "https://developer.trimet.org" GTFS = "/schedule/gtfs.zip" Stops = "/ws/V1/stops" Arrivals = "/ws/v2/arrivals" Vehicles = "/ws/v2/vehicles" VehiclesGTFS = "/ws/gtfs/VehiclePositions" Routes = "/ws/V1/routeConfig" TripUpdateURL = "/ws/V1/TripUpdate" )
Trimet API Routes
Variables ¶
This section is empty.
Functions ¶
func RequestArrivals ¶
RequestArrivals makes a request to the trimet arrivals API endpoint. It MUST have an array of ids as trimet limits reponses to 10 locations.
func RequestGTFSFile ¶
func RequestGTFSFile(baseURL string) (*zip.ReadCloser, error)
RequestGTFSFile makes a request to download the current GTFS data set from Trimet. It returns an array of stops from the file.
Types ¶
type CSV ¶
type CSV struct {
// contains filtered or unexported fields
}
CSV ...
func ReadGTFSCSV ¶
ReadGTFSCSV reads a GTFS txt file and returns a CSV object.
func ReadZippedGTFSCSV ¶
func ReadZippedGTFSCSV(z *zip.ReadCloser, fileName string) (*CSV, error)
ReadZippedGTFSCSV opens a GTFS.zip file and extracts fileName as a CSV object.
type CalendarDate ¶
type CalendarDate struct { ServiceID string `json:"service_id" msg:"service_id"` Date time.Time `json:"date" msg:"date"` ExceptionType int `json:"exception_type" msg:"exception_type"` }
CalendarDate ...
func NewCalendarDateFromRow ¶
func NewCalendarDateFromRow(row []string) (*CalendarDate, error)
NewCalendarDateFromRow takes a single row from processing a calendar_dates.txt and creates a CalendarDate.
func (*CalendarDate) DecodeMsg ¶
func (z *CalendarDate) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (CalendarDate) EncodeMsg ¶
func (z CalendarDate) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (CalendarDate) MarshalMsg ¶
func (z CalendarDate) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (CalendarDate) Msgsize ¶
func (z CalendarDate) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CalendarDate) UnmarshalMsg ¶
func (z *CalendarDate) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Position ¶
type Position struct { Latitude float32 `json:"lat" msg:"lat"` Longitude float32 `json:"lng" msg:"lng"` Bearing float32 `json:"bearing" msg:"bearing"` Odometer float64 `json:"odometer" msg:"odometer"` Speed float32 `json:"speed" msg:"speed"` }
Position is a geographic position of a vehicle.
func (*Position) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Route ¶
type Route struct { RouteID string `json:"id" msg:"id"` AgencyID string `json:"agency_id" msg:"agency_id"` ShortName string `json:"short_name" msg:"short_name"` LongName string `json:"long_name" msg:"long_name"` Type int `json:"type" msg:"type"` URL string `json:"url" msg:"url"` Color string `json:"color" msg:"color"` TextColor string `json:"text_color" msg:"text_color"` SortOrder int `json:"sort_order" msg:"sort_order"` }
Route represents a single route from a GTFS feed.
func (*Route) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type RouteType ¶
type RouteType int
RouteType indicates the type of vehicle serving the route
const ( RouteTypeTram RouteType = iota RouteTypeSubway RouteTypeRail RouteTypeBus RouteTypeFerry RouteTypeCableCar RouteTypeGondola RouteTypeFunicular )
Defines the types of vehicles serving a route.
func (RouteType) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Shape ¶
type Shape struct { ID string `json:"id" msg:"id"` PointLat float64 `json:"pt_lat" msg:"pt_lat"` PointLng float64 `json:"pt_lng" msg:"pt_lng"` PointSequence int `json:"pt_sequence" msg:"pt_sequence"` DistTraveled *float64 `json:"dist_traveled" msg:"dist_traveled"` }
Shape describe the physical path that a vehicle takes, and are defined in the file shapes.txt. Shapes belong to Trips, and consist of a sequence of points. Tracing the points in order provides the path of the vehicle. The points do not need to match stop locations.
func (*Shape) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type Stop ¶
type Stop struct { ID string `json:"id" msg:"id"` Code string `json:"code" msg:"code"` Name string `json:"name" msg:"name"` Desc string `json:"desc" msg:"desc"` Lat float64 `json:"lat" msg:"lat"` Lon float64 `json:"lng" msg:"lng"` ZoneID string `json:"zone_id" msg:"zone_id"` URL string `json:"url" msg:"url"` LocationType int `json:"location_type" msg:"location_type"` ParentStation string `json:"parent_station" msg:"parent_station"` Direction string `json:"direction" msg:"direction"` Position string `json:"position" msg:"position"` WheelchairBoarding int `json:"wheelchair_boarding" msg:"wheelchair_boarding"` }
Stop represents a single stop from a GTFS feed.
func NewStopFromRow ¶
NewStopFromRow takes a single row from processing a stops.txt file and creates a Stop.
func (*Stop) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type StopTime ¶
type StopTime struct { TripID string `json:"trip_id" msg:"trip_id"` ArrivalTime *Time `json:"arrival_time" msg:"arrival_time,extension"` DepartureTime *Time `json:"departure_time" msg:"departure_time,extension"` StopID string `json:"stop_id" msg:"stop_id"` StopSequence int `json:"stop_sequence" msg:"stop_sequence"` StopHeadsign *string `json:"stop_headsign" msg:"stop_headsign"` PickupType int `json:"pickup_type" msg:"pickup_type"` DropOffType int `json:"drop_off_type" msg:"drop_off_type"` ShapeDistTraveled *float64 `json:"shape_dist_traveled" msg:"shape_dist_traveled"` Timepoint *int `json:"timepoint" msg:"timepoint"` ContinuousDropOff int `json:"continuous_drop_off" msg:"continuous_drop_off"` ContinuousPickup int `json:"continuous_pickup" msg:"continuous_pickup"` }
StopTime is a single stop time from a GTFS feed.
func NewStopTimeFromRow ¶
NewStopTimeFromRow takes a single row from processing a stop_times.txt file and creates a StopTime.
func (*StopTime) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type StopTimeEvent ¶
type StopTimeEvent struct { Delay *int32 `json:"delay" msg:"delay"` Time *time.Time `json:"time" msg:"time"` Uncertainty *int32 `json:"uncertainty" msg:"uncertainty"` }
StopTimeEvent contains timing information for a single predicted event.
func (*StopTimeEvent) DecodeMsg ¶
func (z *StopTimeEvent) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*StopTimeEvent) EncodeMsg ¶
func (z *StopTimeEvent) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*StopTimeEvent) MarshalMsg ¶
func (z *StopTimeEvent) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*StopTimeEvent) Msgsize ¶
func (z *StopTimeEvent) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*StopTimeEvent) UnmarshalMsg ¶
func (z *StopTimeEvent) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type StopTimeUpdate ¶
type StopTimeUpdate struct { StopSequence *uint32 `json:"stop_sequence" msg:"stop_sequence"` StopID *string `json:"stop_id" msg:"stop_id"` Arrival StopTimeEvent `json:"arrival" msg:"arrival"` Departure StopTimeEvent `json:"departure" msg:"departure"` ScheduleRelationship *int32 `json:"schedule_relationship" msg:"schedule_relationship"` }
StopTimeUpdate is a realtime update for arrival and/or departure events for a given stop on a trip.
func (*StopTimeUpdate) DecodeMsg ¶
func (z *StopTimeUpdate) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*StopTimeUpdate) EncodeMsg ¶
func (z *StopTimeUpdate) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*StopTimeUpdate) MarshalMsg ¶
func (z *StopTimeUpdate) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*StopTimeUpdate) Msgsize ¶
func (z *StopTimeUpdate) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*StopTimeUpdate) UnmarshalMsg ¶
func (z *StopTimeUpdate) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Time ¶
Time is represented in the GTFS feeds as a duration of time since midnight. Note that for trips that start the previous day and end past midnight, Time can go past 24:00:00.
func (*Time) ExtensionType ¶
func (*Time) MarshalBinaryTo ¶
func (*Time) MarshalText ¶
MarshalText converts a time into text.
func (*Time) UnmarshalBinary ¶
func (*Time) UnmarshalText ¶
UnmarshalText converts text into a Time value. It expects the time to be in HH:MM:SS format.
type Trip ¶
type Trip struct { ID string `json:"id" msg:"id"` RouteID string `json:"route_id" msg:"route_id"` ServiceID string `json:"service_id" msg:"service_id"` DirectionID *int `json:"direction_id" msg:"direction_id"` BlockID *string `json:"block_id" msg:"block_id"` ShapeID *string `json:"shape_id" msg:"shape_id"` Headsign *string `json:"headsign" msg:"headsign"` ShortName *string `json:"short_name" msg:"short_name"` BikesAllowed int `json:"bikes_allowed" msg:"bikes_allowed"` WheelchairAccessible int `json:"wheelchair_accessible" msg:"wheelchair_accessible"` }
Trip ...
func NewTripFromRow ¶
NewTripFromRow takes a single row from processing a trips.txt file and creates a Trip.
func (*Trip) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type TripDescriptor ¶
type TripDescriptor struct { TripID *string `json:"trip_id" msg:"trip_id"` RouteID *string `json:"route_id" msg:"route_id"` }
TripDescriptor identifies an instance of a GTFS trip, or all instances of a trip along a route.
func (*TripDescriptor) DecodeMsg ¶
func (z *TripDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TripDescriptor) EncodeMsg ¶
func (z *TripDescriptor) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TripDescriptor) MarshalMsg ¶
func (z *TripDescriptor) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TripDescriptor) Msgsize ¶
func (z *TripDescriptor) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TripDescriptor) UnmarshalMsg ¶
func (z *TripDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TripUpdate ¶
type TripUpdate struct { Trip TripDescriptor `json:"trip" msg:"trip"` Vehicle VehicleDescriptor `json:"vehicle" msg:"vehicle"` StopTimeUpdates []StopTimeUpdate `json:"stop_time_update" msg:"stop_time_update"` Timestamp *time.Time `json:"timestamp" msg:"timestamp"` Delay *int32 `json:"delay" msg:"delay"` }
TripUpdate is a realtime update on the progress of a vehile along a trip.
func RequestTripUpdate ¶
func RequestTripUpdate(baseURL, apiKey string) ([]TripUpdate, error)
RequestTripUpdate makes a request to the trimet TripUpdate GTFS API endpoint.
func (*TripUpdate) DecodeMsg ¶
func (z *TripUpdate) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TripUpdate) EncodeMsg ¶
func (z *TripUpdate) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TripUpdate) MarshalMsg ¶
func (z *TripUpdate) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TripUpdate) Msgsize ¶
func (z *TripUpdate) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TripUpdate) UnmarshalMsg ¶
func (z *TripUpdate) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TripUpdatesMsg ¶
type TripUpdatesMsg struct {
TripUpdates []TripUpdate `json:"trip_updates" msg:"trip_update"`
}
TripUpdatesMsg ...
func (*TripUpdatesMsg) DecodeMsg ¶
func (z *TripUpdatesMsg) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TripUpdatesMsg) EncodeMsg ¶
func (z *TripUpdatesMsg) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TripUpdatesMsg) MarshalMsg ¶
func (z *TripUpdatesMsg) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TripUpdatesMsg) Msgsize ¶
func (z *TripUpdatesMsg) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TripUpdatesMsg) UnmarshalMsg ¶
func (z *TripUpdatesMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type VehicleDescriptor ¶
type VehicleDescriptor struct { ID *string `json:"id" msg:"id"` Label *string `json:"label" msg:"label"` }
VehicleDescriptor contains identification information for a vehicle performing a trip.
func (*VehicleDescriptor) DecodeMsg ¶
func (z *VehicleDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*VehicleDescriptor) EncodeMsg ¶
func (z *VehicleDescriptor) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*VehicleDescriptor) MarshalMsg ¶
func (z *VehicleDescriptor) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*VehicleDescriptor) Msgsize ¶
func (z *VehicleDescriptor) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*VehicleDescriptor) UnmarshalMsg ¶
func (z *VehicleDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type VehiclePosition ¶
type VehiclePosition struct { Trip TripDescriptor `json:"trip" msg:"trip"` Vehicle VehicleDescriptor `json:"vehicle" msg:"vehicle"` Position Position `json:"position" msg:"position"` CurrentStopSequence uint32 `json:"current_stop_sequence" msg:"current_stop_sequence"` StopID string `json:"stop_id" msg:"stop_id"` CurrentStatus int32 `json:"current_status" msg:"current_status"` Timestamp uint64 `json:"timestamp" msg:"timestamp"` CongestionLevel int32 `json:"congestion_level" msg:"congestion_level"` OccupancyStatus int32 `json:"occupancy_status" msg:"occupancy_status"` }
VehiclePosition is the realtime position information for a given vehicle.
func RequestVehiclePositions ¶
func RequestVehiclePositions(baseURL string, appID string, since uint64) ([]VehiclePosition, error)
RequestVehiclePositions contacts the Trimet Vehicles GTFS API and retrieves all vehicles updated after the 'since' value. If no 'since' value is specified, it defaults to retrieving them all since midnight of the service day.
func (*VehiclePosition) DecodeMsg ¶
func (z *VehiclePosition) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*VehiclePosition) EncodeMsg ¶
func (z *VehiclePosition) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*VehiclePosition) MarshalMsg ¶
func (z *VehiclePosition) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*VehiclePosition) Msgsize ¶
func (z *VehiclePosition) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*VehiclePosition) UnmarshalMsg ¶
func (z *VehiclePosition) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler