Class SpeedLimitProspect
java.lang.Object
org.opentrafficsim.road.network.speed.SpeedLimitProspect
- All Implemented Interfaces:
Serializable
Prospect of speed limits ahead, both legal and otherwise (e.g. curve, speed bump).
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Wouter Schakel
- See Also:
-
Constructor Summary
ConstructorDescriptionSpeedLimitProspect
(org.djunits.value.vdouble.scalar.Length odometer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> void
addSpeedInfo
(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType, T speedInfo, Object source) Sets the speed info of a speed limit type.final <T> SpeedLimitInfo
buildSpeedLimitInfo
(org.djunits.value.vdouble.scalar.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.final boolean
containsAddSource
(Object source) Returns whether the given source is already added in the prospect.final boolean
containsRemoveSource
(Object source) Returns whether the given source is already removed in the prospect.final List<org.djunits.value.vdouble.scalar.Length>
Returns the distances at which a change in the prospect is present in order (upstream first).final List<org.djunits.value.vdouble.scalar.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).final List<org.djunits.value.vdouble.scalar.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).final org.djunits.value.vdouble.scalar.Length
Returns the odometer value at which the last update was performed.final <T> T
getSpeedInfoChange
(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType) Returns the speed info of given speed limit type where it changed.final SpeedLimitInfo
getSpeedLimitInfo
(org.djunits.value.vdouble.scalar.Length distance) Returns the speed info at a given location.final SpeedLimitInfo
getSpeedLimitInfo
(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration time) Returns the speed info at a location following an acceleration over some duration.final List<org.djunits.value.vdouble.scalar.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).final void
removeSpeedInfo
(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType, Object source) Removes the speed info of a speed limit type.final boolean
speedInfoChanged
(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType) Returns whether the given speed limit type is changed at the given distance.final String
toString()
void
update
(org.djunits.value.vdouble.scalar.Length newOdometer) Updates the distance values.
-
Constructor Details
-
SpeedLimitProspect
public SpeedLimitProspect(org.djunits.value.vdouble.scalar.Length odometer) Constructor.- Parameters:
odometer
- Length; odometer value
-
-
Method Details
-
update
public void update(org.djunits.value.vdouble.scalar.Length newOdometer) Updates the distance values.- Parameters:
newOdometer
- Length; odometer value
-
containsAddSource
Returns whether the given source is already added in the prospect.- Parameters:
source
- Object; source- Returns:
- whether the given source is already added in the prospect
-
containsRemoveSource
Returns whether the given source is already removed in the prospect.- Parameters:
source
- Object; source- Returns:
- whether the given source is already removed in the prospect
-
getOdometer
public final org.djunits.value.vdouble.scalar.Length getOdometer()Returns the odometer value at which the last update was performed.- Returns:
- Length; odometer value at which the last update was performed
-
addSpeedInfo
public final <T> void addSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType, T speedInfo, Object source) Sets the speed info of a speed limit type.- Type Parameters:
T
- class of speed info- Parameters:
distance
- 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 object- Throws:
IllegalStateException
- 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 null
-
removeSpeedInfo
public final void removeSpeedInfo(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType, Object source) Removes the speed info of a speed limit type.- Parameters:
distance
- Length; distance to remove speed info of a speed limit typespeedLimitType
- SpeedLimitType<?>; speed limit type to remove speed info ofsource
- Object; source object- Throws:
IllegalStateException
- if speed info for a specific speed limit type is set or removed twice at the same distanceIllegalArgumentException
- if the speed limit type isMAX_VEHICLE_SPEED
IllegalArgumentException
- if the distance is negativeNullPointerException
- if any input is null
-
getDistances
Returns the distances at which a change in the prospect is present in order (upstream first). If multiple changes are present at the same distance, only one distance is returned in the list.- Returns:
- distances at which a change in the prospect is present in order (upstream first)
-
getDistances
public final List<org.djunits.value.vdouble.scalar.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). If multiple changes are present at the same distance, only one distance is returned in the list.- Parameters:
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances of- Returns:
- distances at which a change of the given speed limit type in the prospect is present in order
-
getUpstreamDistances
public final List<org.djunits.value.vdouble.scalar.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). If multiple changes are present at the same distance, only one distance is returned in the list.- Parameters:
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances of- Returns:
- distances at which a change of the given speed limit type in the prospect is present in order
-
getDownstreamDistances
public final List<org.djunits.value.vdouble.scalar.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). If multiple changes are present at the same distance, only one distance is returned in the list.- Parameters:
speedLimitType
- SpeedLimitType<?>; speed limit type to get the distances of- Returns:
- distances at which a change of the given speed limit type in the prospect is present in order
-
speedInfoChanged
public final boolean speedInfoChanged(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<?> speedLimitType) Returns whether the given speed limit type is changed at the given distance.- Parameters:
distance
- Length; distance to checkspeedLimitType
- SpeedLimitType<?>; speed limit type to check- Returns:
- whether the given speed limit type is changed at the given distance
- Throws:
NullPointerException
- if distance is null
-
getSpeedInfoChange
public final <T> T getSpeedInfoChange(org.djunits.value.vdouble.scalar.Length distance, SpeedLimitType<T> speedLimitType) Returns the speed info of given speed limit type where it changed. If the change was removing the speed limit type (e.g. end of corner), thennull
is returned.- Type Parameters:
T
- class of the speed limit type info- Parameters:
distance
- Length; distance where the info changedspeedLimitType
- SpeedLimitType<T>; speed limit type- Returns:
- speed info of given speed limit type where it changed,
null
if speed limit type is removed - Throws:
IllegalArgumentException
- if the speed info did not change at the given distance for the speed limit type
-
getSpeedLimitInfo
Returns the speed info at a given location.- Parameters:
distance
- Length; where to get the speed info- Returns:
- speed info at a given distance
- Throws:
NullPointerException
- if distance is null
-
getSpeedLimitInfo
public final SpeedLimitInfo getSpeedLimitInfo(org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration time) Returns the speed info at a location following an acceleration over some duration.- Parameters:
speed
- Speed; current speedacceleration
- Acceleration; acceleration to applytime
- Duration; duration of acceleration- Returns:
- speed info at a given distance
- Throws:
NullPointerException
- if any input is null
-
buildSpeedLimitInfo
public final <T> SpeedLimitInfo buildSpeedLimitInfo(org.djunits.value.vdouble.scalar.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.- Type Parameters:
T
- class of speed info of given speed limit type- Parameters:
distance
- Length; distance to get the speed info atspeedLimitType
- SpeedLimitType<T>; speed limit type of which to include the info- Returns:
- speed limit info with only MAX_VEHICLE_SPEED and the given speed limit type
-
toString
-