public class Timetable extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
List<FrequencyEntry> |
frequencyEntries
Contains one FrequencyEntry object for each block of frequency-based trips.
|
TripPattern |
pattern
A circular reference between TripPatterns and their scheduled (non-updated) timetables.
|
ServiceDate |
serviceDate
The ServiceDate for which this (updated) timetable is valid.
|
List<TripTimes> |
tripTimes
Contains one TripTimes object for each scheduled trip (even cancelled ones) and possibly
additional TripTimes objects for unscheduled trips.
|
Constructor and Description |
---|
Timetable(TripPattern pattern)
Construct an empty Timetable.
|
Modifier and Type | Method and Description |
---|---|
void |
addFrequencyEntry(FrequencyEntry freq)
Add a frequency entry to this Timetable.
|
void |
addTripTimes(TripTimes tt)
Add a trip to this Timetable.
|
TripTimes |
createUpdatedTripTimes(GtfsRealtime.TripUpdate tripUpdate,
TimeZone timeZone,
ServiceDate updateServiceDate)
Apply the TripUpdate to the appropriate TripTimes from this Timetable.
|
void |
finish()
Finish off a Timetable once all TripTimes have been added to it.
|
int |
getBestDwellTime(int stopIndex)
Returns the shortest possible dwell time at this stop
|
int |
getBestRunningTime(int stopIndex)
Returns the shortest possible running time for this stop
|
int |
getMaxTime() |
int |
getMinTime() |
TripTimes |
getNextCallNRideTrip(State s0,
ServiceDay serviceDay,
int stopIndex,
boolean boarding,
int directTime) |
TripTimes |
getNextTrip(State s0,
ServiceDay serviceDay,
int stopIndex,
boolean boarding)
Get the next (previous) trip that departs (arrives) from the specified stop at or after
(before) the specified time.
|
TripTimes |
getNextTrip(State s0,
ServiceDay serviceDay,
int stopIndex,
boolean boarding,
double flexOffsetScale,
int flexPreBoardDirectTime,
int flexPostAlightDirectTime)
Get the next (previous) trip that departs (arrives) from the specified stop at or after
(before) the specified time.
|
int |
getTripIndex(FeedScopedId tripId) |
int |
getTripIndex(String tripId) |
TripTimes |
getTripTimes(int tripIndex) |
TripTimes |
getTripTimes(Trip trip) |
boolean |
isValidFor(ServiceDate serviceDate) |
void |
setServiceCodes(Map<FeedScopedId,Integer> serviceCodes)
Find and cache service codes.
|
TripTimes |
setTripTimes(int tripIndex,
TripTimes tt)
Set new trip times for trip given a trip index
|
boolean |
temporallyViable(ServiceDay sd,
long searchTime,
int bestWait,
boolean boarding)
Before performing the relatively expensive iteration over all the trips in this pattern, check whether it's even
possible to board any of them given the time at which we are searching, and whether it's possible that any of
them could improve on the best known time.
|
public final TripPattern pattern
public final List<TripTimes> tripTimes
public final List<FrequencyEntry> frequencyEntries
public final ServiceDate serviceDate
public Timetable(TripPattern pattern)
public boolean temporallyViable(ServiceDay sd, long searchTime, int bestWait, boolean boarding)
bestWait
- -1 means there is not yet any best known time.public TripTimes getNextTrip(State s0, ServiceDay serviceDay, int stopIndex, boolean boarding, double flexOffsetScale, int flexPreBoardDirectTime, int flexPostAlightDirectTime)
getNextTrip(State, ServiceDay, int, boolean)
).s0
- State to evaluate the method at; the method uses the state's time.serviceDay
- Only consider trips if their service_id is active on this daystopIndex
- Index of stop in the trip to evaluate departure or arrival atboarding
- If true, find next trip which departs specified stop; if false, find
previous trip which arrives at specified stopflexOffsetScale
- For GTFS-Flex routing, a control parameter to determine the amount of
seconds to offset the scheduled timepoint due to a board/alight in
the middle of a
FlexPatternHop
.
Use the percentage in [0, 1] ([-1, 0]) from the beginning (end) of
the hop at which the board (alight) is taking place. Note that the
value is expected to be negative when evaluating alight points. Use
0 if this is not a flag stop or deviated-route board (alight) point.flexPreBoardDirectTime
- For GTFS-Flex routing, the amount of time the vehicle travels
before rejoining the route, or 0 if this is not a deviated-
route board (alight) point.flexPostAlightDirectTime
- For GTFS-Flex routing, the amount of time the vehicle
travels after leaving the route, or 0 if this is not a
deviated-route board (alight) point.public TripTimes getNextTrip(State s0, ServiceDay serviceDay, int stopIndex, boolean boarding)
s0
- State to evaluate the method at; the method uses the state's time.serviceDay
- Only consider trips if their service_id is active on this daystopIndex
- index of stop in the trip to evaluate departure or arrival atboarding
- if true, find next trip which departs specified stop; if false, find
previous trip which arrives at specified stoppublic TripTimes getNextCallNRideTrip(State s0, ServiceDay serviceDay, int stopIndex, boolean boarding, int directTime)
public void finish()
public int getTripIndex(FeedScopedId tripId)
public int getTripIndex(String tripId)
public TripTimes getTripTimes(int tripIndex)
public TripTimes setTripTimes(int tripIndex, TripTimes tt)
tripIndex
- trip index of triptt
- new trip times for trippublic TripTimes createUpdatedTripTimes(GtfsRealtime.TripUpdate tripUpdate, TimeZone timeZone, ServiceDate updateServiceDate)
TimetableSnapshot
performs the
protective copying of this Timetable. It is not done in this update method to avoid
repeatedly cloning the same Timetable when several updates are applied to it at once. We
assume here that all trips in a timetable are from the same feed, which should always be the
case.tripUpdate
- GTFS-RT trip updatetimeZone
- time zone of trip updateupdateServiceDate
- service date of trip updatepublic void addTripTimes(TripTimes tt)
public void addFrequencyEntry(FrequencyEntry freq)
public int getBestRunningTime(int stopIndex)
public int getBestDwellTime(int stopIndex)
public boolean isValidFor(ServiceDate serviceDate)
public void setServiceCodes(Map<FeedScopedId,Integer> serviceCodes)
public int getMaxTime()
public int getMinTime()
Copyright © 2019. All rights reserved.