public class SpeedLimitProspect extends Object implements Serializable
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
SpeedLimitProspect(Length odometer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> void |
addSpeedInfo(Length distance,
SpeedLimitType<T> speedLimitType,
T speedInfo,
Object source)
Sets the speed info of a speed limit type.
|
<T> SpeedLimitInfo |
buildSpeedLimitInfo(Length distance,
SpeedLimitType<T> speedLimitType)
Builds speed limit info with only MAX_VEHICLE_SPEED and the given speed limit type, where the speed info is obtained at
the given distance.
|
boolean |
containsAddSource(Object source)
Returns whether the given source is already added in the prospect.
|
boolean |
containsRemoveSource(Object source)
Returns whether the given source is already removed in the prospect.
|
List<Length> |
getDistances()
Returns the distances at which a change in the prospect is present in order (upstream first).
|
List<Length> |
getDistances(SpeedLimitType<?> speedLimitType)
Returns the distances at which a change of the given speed limit type in the prospect is present in order (most upstream
first).
|
List<Length> |
getDownstreamDistances(SpeedLimitType<?> speedLimitType)
Returns the downstream distances at which a change of the given speed limit type in the prospect is present in order
(most upstream first).
|
Length |
getOdometer()
Returns the odometer value at which the last update was performed.
|
<T> T |
getSpeedInfoChange(Length distance,
SpeedLimitType<T> speedLimitType)
Returns the speed info of given speed limit type where it changed.
|
SpeedLimitInfo |
getSpeedLimitInfo(Length distance)
Returns the speed info at a given location.
|
SpeedLimitInfo |
getSpeedLimitInfo(Speed speed,
Acceleration acceleration,
Duration time)
Returns the speed info at a location following an acceleration over some duration.
|
List<Length> |
getUpstreamDistances(SpeedLimitType<?> speedLimitType)
Returns the upstream distances at which a change of the given speed limit type in the prospect is present in order (most
upstream first).
|
void |
removeSpeedInfo(Length distance,
SpeedLimitType<?> speedLimitType,
Object source)
Removes the speed info of a speed limit type.
|
boolean |
speedInfoChanged(Length distance,
SpeedLimitType<?> speedLimitType)
Returns whether the given speed limit type is changed at the given distance.
|
String |
toString() |
void |
update(Length newOdometer)
Updates the distance values.
|
public SpeedLimitProspect(Length odometer)
odometer
- Length; odometer valuepublic void update(Length newOdometer)
newOdometer
- Length; odometer valuepublic final boolean containsAddSource(Object source)
source
- Object; sourcepublic final boolean containsRemoveSource(Object source)
source
- Object; sourcepublic final Length getOdometer()
public final <T> void addSpeedInfo(Length distance, SpeedLimitType<T> speedLimitType, T speedInfo, Object source)
T
- class of speed infodistance
- Length; location to set info for a speed limit typespeedLimitType
- SpeedLimitType<T>; speed limit type to set the info forspeedInfo
- T; speed info to setsource
- Object; source objectIllegalStateException
- if speed info for a specific speed limit type is set or removed twice at the same distanceIllegalStateException
- if speed info for a specific speed limit type is set twice with negative distanceNullPointerException
- if any input is nullpublic final void removeSpeedInfo(Length distance, SpeedLimitType<?> speedLimitType, Object source)
distance
- Length; distance to remove speed info of a speed limit typespeedLimitType
- SpeedLimitType<?>; speed limit type to remove speed info ofsource
- Object; source objectIllegalStateException
- if speed info for a specific speed limit type is set or removed twice at the same distanceIllegalArgumentException
- if the speed limit type is MAX_VEHICLE_SPEED
IllegalArgumentException
- if the distance is negativeNullPointerException
- if any input is nullpublic final List<Length> getDistances()
public final List<Length> getDistances(SpeedLimitType<?> speedLimitType)
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances ofpublic final List<Length> getUpstreamDistances(SpeedLimitType<?> speedLimitType)
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances ofpublic final List<Length> getDownstreamDistances(SpeedLimitType<?> speedLimitType)
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances ofpublic final boolean speedInfoChanged(Length distance, SpeedLimitType<?> speedLimitType)
distance
- Length; distance to checkspeedLimitType
- SpeedLimitType<?>; speed limit type to checkNullPointerException
- if distance is nullpublic final <T> T getSpeedInfoChange(Length distance, SpeedLimitType<T> speedLimitType)
null
is returned.T
- class of the speed limit type infodistance
- Length; distance where the info changedspeedLimitType
- SpeedLimitType<T>; speed limit typenull
if speed limit type is removedIllegalArgumentException
- if the speed info did not change at the given distance for the speed limit typepublic final SpeedLimitInfo getSpeedLimitInfo(Length distance)
distance
- Length; where to get the speed infoNullPointerException
- if distance is nullpublic final SpeedLimitInfo getSpeedLimitInfo(Speed speed, Acceleration acceleration, Duration time)
speed
- Speed; current speedacceleration
- Acceleration; acceleration to applytime
- Duration; duration of accelerationNullPointerException
- if any input is nullpublic final <T> SpeedLimitInfo buildSpeedLimitInfo(Length distance, SpeedLimitType<T> speedLimitType)
T
- class of speed info of given speed limit typedistance
- Length; distance to get the speed info atspeedLimitType
- SpeedLimitType<T>; speed limit type of which to include the infoCopyright © 2014–2019 Delft University of Technology. All rights reserved.