rt

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package rt provides support for GTFS-RealTime. This API is under development and will change.

Index

Constants

This section is empty.

Variables

View Source
var (
	E001 = nec("Not in POSIX time", "E001")
	E002 = nec("stop_time_updates not strictly sorted", "E002")
	E003 = nec("GTFS-rt trip_id does not exist in GTFS data", "E003")
	E004 = nec("GTFS-rt route_id does not exist in GTFS data", "E004")
	// E006 = nec("Missing required trip field for frequency-based exact_times = 0", "E006")
	E009 = nec("GTFS-rt stop_sequence isn't provided for trip that visits same stop_id more than once", "E009")
	// E010 = nec("location_type not 0 in stops.txt (Note that this is implemented but not executed because it's specific to GTFS - see issue #1"E026")", "E010")
	E011 = nec("GTFS-rt stop_id does not exist in GTFS data", "E011")
	// E012 = nec("Header timestamp should be greater than or equal to all other timestamps", "E012")
	// E013 = nec("Frequency type 0 trip schedule_relationship should be UNSCHEDULED or empty", "E013")
	E015 = nec("All stop_ids referenced in GTFS-rt feeds must have the location_type = 0", "E015")
	// E016 = nec("trip_ids with schedule_relationship ADDED must not be in GTFS data", "E016")
	// E017 = nec("GTFS-rt content changed but has the same header timestamp", "E017")
	E018 = nec("GTFS-rt header timestamp decreased between two sequential iterations", "E018") // same as E012?
	// E019 = nec("GTFS-rt frequency type 1 trip start_time must be a multiple of GTFS headway_secs later than GTFS start_time", "E019")
	E020 = nec("Invalid start_time format", "E020")
	E021 = nec("Invalid start_date format", "E021")
	E022 = nec("Sequential stop_time_update times are not increasing", "E022")
	// E023 = nec("trip start_time does not match first GTFS arrival_time", "E023")
	E024 = nec("trip direction_id does not match GTFS data", "E024")
	E025 = nec("stop_time_update arrival time is after departure time", "E025")
	E026 = nec("Invalid vehicle position", "E026")
	// E027 = nec("Invalid vehicle bearing", "E027")
	// E028 = nec("Vehicle position outside agency coverage area", "E028")
	E029 = nec("Vehicle position far from trip shape", "E029")
	// E030 = nec("GTFS-rt alert trip_id does not belong to GTFS-rt alert route_id  in GTFS trips.txt", "E030")
	// E031 = nec("Alert informed_entity.route_id does not match informed_entity.trip.route_id", "E031")
	// E032 = nec("Alert does not have an informed_entity", "E032")
	// E033 = nec("Alert informed_entity does not have any specifiers", "E033")
	// E034 = nec("GTFS-rt agency_id does not exist in GTFS data", "E034")
	// E035 = nec("GTFS-rt trip.trip_id does not belong to GTFS-rt trip.route_id in GTFS trips.txt", "E035")
	E036 = nec("Sequential stop_time_updates have the same stop_sequence", "E036")
	E037 = nec("Sequential stop_time_updates have the same stop_id", "E037")
	E038 = nec("Invalid header.gtfs_realtime_version", "E038")
	E039 = nec("FULL_DATASET feeds should not include entity.is_deleted", "E039")
	E040 = nec("stop_time_update doesn't contain stop_id or stop_sequence", "E040")
	E041 = nec("StopTimeUpdates are required unless the trip is canceled", "E041")
	E042 = nec("arrival or departure provided for NO_DATA stop_time_update", "E042")
	E043 = nec("stop_time_update doesn't have arrival or departure", "E043")
	E044 = nec("stop_time_update arrival/departure doesn't have delay or time", "E044")
	// E045 = nec("GTFS-rt stop_time_update stop_sequence and stop_id do not match GTFS", "E045")
	// E046 = nec("GTFS-rt stop_time_update without time doesn't have arrival/departure time in GTFS", "E046")
	// E047 = nec("VehiclePosition and TripUpdate ID pairing mismatch", "E047")
	E048 = nec("header timestamp not populated (GTFS-rt v2.0 and higher)", "E048")
	E049 = nec("header incrementality not populated (GTFS-rt v2.0 and higher)", "E049")
	E050 = nec("timestamp is in the future", "E050")
)

Errors https://github.com/CUTR-at-USF/gtfs-realtime-validator/blob/master/RULES.md

Functions

func FlexDecode added in v0.14.0

func FlexDecode(data []byte, msg protoreflect.ProtoMessage) error

func ReadFile

func ReadFile(filename string) (*pb.FeedMessage, error)

ReadFile opens a message from a file.

func ReadURL

func ReadURL(address string, opts ...request.RequestOption) (*pb.FeedMessage, error)

ReadURL opens a message from a url.

Types

type EntityCounts added in v0.14.0

type EntityCounts struct {
	Alert      int
	TripUpdate int
	Vehicle    int
}

type RTTripStat added in v0.16.0

type RTTripStat struct {
	AgencyID                string
	RouteID                 string
	TripScheduledIDs        []string
	TripRtIDs               []string
	TripScheduledCount      int
	TripScheduledMatched    int
	TripScheduledNotMatched int
	TripRtCount             int
	TripRtMatched           int
	TripRtNotMatched        int
	// Not found / added
	TripRtNotFoundIDs   []string
	TripRtAddedIDs      []string
	TripRtNotFoundCount int
	TripRtAddedCount    int
}

type RealtimeError

type RealtimeError struct {
	// contains filtered or unexported fields
}

RealtimeError is a GTFS RealTime error.

func (RealtimeError) EntityJson added in v0.16.0

func (e RealtimeError) EntityJson() tt.Map

Return as tt.Map, not map[string]any

func (RealtimeError) Geometry added in v0.16.0

func (e RealtimeError) Geometry() tt.Geometry

type RealtimeWarning

type RealtimeWarning struct {
	RealtimeError
}

RealtimeWarning is a GTFS RealTime warning.

type Validator

type Validator struct {
	Timezone            string
	MaxDistanceFromTrip float64
	// contains filtered or unexported fields
}

Validator validates RT messages based on data from a static feed. It can be initialized through NewValidatorFromReader or through the Copier Validator interface.

func NewValidator

func NewValidator() *Validator

NewValidator returns an initialized validator.

func (*Validator) EntityCounts added in v0.14.0

func (fi *Validator) EntityCounts(msg *pb.FeedMessage) EntityCounts

func (*Validator) SetGeomCache

func (fi *Validator) SetGeomCache(g *xy.GeomCache)

SetGeomCache sets a shared geometry cache.

func (*Validator) TripUpdateStats added in v0.14.0

func (fi *Validator) TripUpdateStats(now time.Time, msg *pb.FeedMessage) ([]RTTripStat, error)

func (*Validator) Validate

func (fi *Validator) Validate(ent tl.Entity) []error

Validate gets a stream of entities from Copier to build up the cache.

func (*Validator) ValidateFeedEntity

func (fi *Validator) ValidateFeedEntity(ent *pb.FeedEntity, current *pb.FeedMessage) (errs []error)

// ValidateFeedEntity .

func (*Validator) ValidateFeedMessage

func (fi *Validator) ValidateFeedMessage(current *pb.FeedMessage, previous *pb.FeedMessage) (errs []error)

ValidateFeedMessage .

func (*Validator) ValidateHeader

func (fi *Validator) ValidateHeader(header *pb.FeedHeader, current *pb.FeedMessage) (errs []error)

ValidateHeader .

func (*Validator) ValidateStopTimeUpdate

func (fi *Validator) ValidateStopTimeUpdate(st *pb.TripUpdate_StopTimeUpdate, tripUpdate *pb.TripUpdate, current *pb.FeedMessage) (errs []error)

ValidateStopTimeUpdate .

func (*Validator) ValidateTripUpdate

func (fi *Validator) ValidateTripUpdate(tripUpdate *pb.TripUpdate, current *pb.FeedMessage) (errs []error)

ValidateTripUpdate .

func (*Validator) ValidateVehiclePosition added in v0.14.0

func (fi *Validator) ValidateVehiclePosition(ent *pb.VehiclePosition) (errs []error)

func (*Validator) VehiclePositionStats added in v0.14.0

func (fi *Validator) VehiclePositionStats(now time.Time, msg *pb.FeedMessage) ([]RTTripStat, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL