@Entity(name="Blocks")
public final class Block
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Block(int configRev,
java.lang.String blockId,
java.lang.String serviceId,
int startTime,
int endTime,
java.util.List<Trip> trips)
This constructor called when processing GTFS data and creating a Block to
be stored in the database.
|
Modifier and Type | Method and Description |
---|---|
int |
activeTripIndex(java.util.Date date,
int allowableBeforeTimeSecs)
Determines which trip is currently active and returns the associated
index of that trip such that getTrip(int) can be called to get the trip.
|
static int |
deleteFromRev(org.hibernate.Session session,
int configRev)
Deletes rev from the Blocks, Trips, and Block_to_Trip_joinTable
|
boolean |
equals(java.lang.Object obj)
Required by Hibernate
|
static java.util.List<Block> |
getBlocks(org.hibernate.Session session,
int configRev)
Returns list of Block objects for the specified configRev
|
int |
getConfigRev() |
int |
getEndTime() |
java.lang.String |
getId() |
static java.lang.Object |
getLazyLoadingSyncObject()
So can sync up loading of trip and trip pattern data when trips are all
read at once in another class as opposed to through Block.getTrips().
|
int |
getPathStopTime(int tripIndex,
int stopPathIndex)
Returns the time in msec for how long expected to be at the stop
at the end of the stop path.
|
StopPath |
getPreviousPath(int tripIndex,
int stopPathIndex)
Returns the previous path specified by tripIndex and stopPathIndex
params.
|
java.util.Set<java.lang.String> |
getRouteIds()
Returns collection of route IDs associated with the Block.
|
ScheduleTime |
getScheduleTime(int tripIndex,
int stopPathIndex)
Returns the ScheduleTime for that stop specified by the trip and path
indices.
|
Vector |
getSegmentVector(int tripIndex,
int stopPathIndex,
int segmentIndex)
Returns the Vector of the segment specified.
|
java.lang.String |
getServiceId() |
Location |
getStartLoc()
Returns the location of the first stop of the block.
|
int |
getStartTime() |
StopPath |
getStopPath(int tripIndex,
int stopPathIndex)
Returns the path specified by tripIndex and stopPathIndex params.
|
int |
getStopPathTravelTime(int tripIndex,
int stopPathIndex)
Returns the travel time for the specified path.
|
Trip |
getTrip(int tripIndex)
Returns the trip specified by the tripIndex
|
Trip |
getTrip(java.lang.String tripId)
Returns the trip for the block as specified by the tripId parameter
|
int |
getTripIndex(Trip trip)
Returns for the specified trip the index into the trips list for the
block
|
java.util.Collection<TripPattern> |
getTripPatterns()
Returns the trip patterns associated with the block.
|
java.util.List<Trip> |
getTrips()
Uses lazy initialization to determine the trips for the block.
|
java.util.List<Trip> |
getTripsCurrentlyActive(AvlReport avlReport)
For this block determines which trips are currently active.
|
int |
hashCode()
Required by Hibernate
|
boolean |
hasSchedule()
Returns true if block assignment has a schedule (is not frequency based)
|
boolean |
isActive(java.util.Date date)
Returns true if the time of day of the date passed in is between the
startTime and the endTime for the block.
|
boolean |
isActive(java.util.Date date,
int allowableBeforeTimeSecs,
int allowableAfterStartTimeSecs)
Returns true if the time of day of the date passed in is between
allowableBeforeTimeSecs before the startTime and the endTime for the
block.
|
boolean |
isActive(long epochTime)
Returns true if the time of day of the date passed in is between the
startTime and the endTime for the block.
|
boolean |
isActive(long epochTime,
int allowableBeforeTimeSecs)
Returns true if the time of day of the epoch time passed in is between
allowableBeforeTimeSecs before the startTime and the endTime for the
block.
|
boolean |
isActive(long epochTime,
int allowableBeforeTimeSecs,
int allowableAfterStartTimeSecs)
Returns true if the time of day of the date passed in is between
allowableBeforeTimeSecs before the startTime and the endTime for the
block.
|
boolean |
isBeforeStartTime(java.util.Date date,
int allowableBeforeTimeSecs)
Returns true if the time of day of the date passed in is between
allowableBeforeTimeSecs before the start time and the start time.
|
boolean |
isLayover(int tripIndex,
int stopPathIndex)
Returns true if path is for a stop that is configured to be layover stop
for the trip pattern.
|
boolean |
isNoSchedule()
Returns true if block assignment has no schedule (is frequency based)
|
boolean |
isWaitStop(int tripIndex,
int stopPathIndex)
Indicates that vehicle is not supposed to depart the stop until the
scheduled departure time.
|
static void |
main(java.lang.String[] args)
For debugging
|
boolean |
nearEndOfBlock(SpatialMatch match,
double distance)
Returns true if on last trip of block and within the specified distance
of the end of that last trip.
|
int |
numSegments(int tripIndex,
int stopPathIndex)
Returns number of segments for the path specified
|
int |
numStopPaths(int tripIndex)
Returns number of stopPaths for the trip specified.
|
int |
numTrips()
Returns the number of trips.
|
boolean |
shouldBeExclusive()
Returns true if this block assignment should be exclusive, such that when
a vehicle is assigned to this block any other vehicles assigned to this
block will have their assignments removed.
|
java.lang.String |
toShortString()
Like toString() but only outputs core info.
|
java.lang.String |
toString() |
public Block(int configRev, java.lang.String blockId, java.lang.String serviceId, int startTime, int endTime, java.util.List<Trip> trips)
configRev
- blockId
- startTime
- endTime
- trips
- public static java.util.List<Block> getBlocks(org.hibernate.Session session, int configRev) throws org.hibernate.HibernateException
session
- configRev
- org.hibernate.HibernateException
public static int deleteFromRev(org.hibernate.Session session, int configRev) throws org.hibernate.HibernateException
session
- configRev
- org.hibernate.HibernateException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toShortString()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int activeTripIndex(java.util.Date date, int allowableBeforeTimeSecs)
Often consider a block to be active before its scheduled start time. For this situation the first trip is returned if it is within allowableBeforeTimeSecs before the block is supposed to start.
date
- The current time, to be used for determining if trip active.allowableBeforeTimeSecs
- How much before the block time the block is considered to be
active. Needed because often consider a block to be active
before its scheduled start time. For this situation need to
return first trip.public boolean isActive(java.util.Date date, int allowableBeforeTimeSecs, int allowableAfterStartTimeSecs)
date
- The time checking to see whether block is active forallowableBeforeTimeSecs
- Block considered active if within this number of seconds
before the block start time. Set to 0 if want to know if date
is actually between the block start and end times.allowableAfterStartTimeSecs
- If set to value greater than or equal to zero then block
considered active only if within this number of seconds after
the start time. If less then zero then block considered active
up to the block end time.public boolean isActive(long epochTime, int allowableBeforeTimeSecs, int allowableAfterStartTimeSecs)
date
- The time checking to see whether block is active forallowableBeforeTimeSecs
- Block considered active if within this number of seconds
before the block start time. Set to 0 if want to know if date
is actually between the block start and end times.allowableAfterStartTimeSecs
- If set to value greater than or equal to zero then block
considered active only if within this number of seconds after
the start time. If less then zero then block considered active
up to the block end time.public boolean isActive(long epochTime, int allowableBeforeTimeSecs)
epochTime
- allowableBeforeTimeSecs
- public boolean isActive(java.util.Date date)
date
- public boolean isActive(long epochTime)
epochTime
- public boolean isBeforeStartTime(java.util.Date date, int allowableBeforeTimeSecs)
date
- allowableBeforeTimeSecs
- public java.util.List<Trip> getTripsCurrentlyActive(AvlReport avlReport)
avlReport
- public java.lang.String getId()
public int getConfigRev()
public java.lang.String getServiceId()
public int getStartTime()
public int getEndTime()
public java.util.List<Trip> getTrips()
public static java.lang.Object getLazyLoadingSyncObject()
public boolean isNoSchedule()
public boolean hasSchedule()
public Trip getTrip(int tripIndex)
tripIndex
- public Trip getTrip(java.lang.String tripId)
tripId
- Which trip is to be returnedpublic int getTripIndex(Trip trip)
trip
- Specifies which trip looking forpublic java.util.Set<java.lang.String> getRouteIds()
public java.util.Collection<TripPattern> getTripPatterns()
public int getStopPathTravelTime(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public int getPathStopTime(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public Vector getSegmentVector(int tripIndex, int stopPathIndex, int segmentIndex)
tripIndex
- stopPathIndex
- segmentIndex
- public int numSegments(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public int numStopPaths(int tripIndex)
tripIndex
- public int numTrips()
public boolean isLayover(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public boolean isWaitStop(int tripIndex, int stopPathIndex)
public StopPath getStopPath(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public Location getStartLoc()
public StopPath getPreviousPath(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public ScheduleTime getScheduleTime(int tripIndex, int stopPathIndex)
tripIndex
- stopPathIndex
- public boolean nearEndOfBlock(SpatialMatch match, double distance)
match
- distance
- public boolean shouldBeExclusive()
Current it is configured using Java property instead of in the database.
public static void main(java.lang.String[] args)
args
-