Class CrossSectionElement
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.road.network.lane.CrossSectionElement
- All Implemented Interfaces:
Serializable
,Remote
,Locatable
,org.djutils.event.EventProducer
,org.opentrafficsim.base.Identifiable
,Drawable
public class CrossSectionElement
extends org.djutils.event.LocalEventProducer
implements Locatable, Serializable, org.opentrafficsim.base.Identifiable, Drawable
Cross section elements are used to compose a CrossSectionLink.
Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<CrossSectionSlice>
The offsets and widths at positions along the line, relative to the design line of the parent link.static final double
At what fraction of the first segment will an extra point be inserted if theMAXIMUMDIRECTIONERROR
is exceeded.protected final Length
The length of the line.static final double
Maximum direction difference w.r.t.protected final CrossSectionLink
Cross Section Link to which the element belongs.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorsConstructorDescriptionCrossSectionElement
(CrossSectionLink parentLink, String id, List<CrossSectionSlice> crossSectionSlices) Construct a new CrossSectionElement.CrossSectionElement
(CrossSectionLink parentLink, String id, Length lateralOffset, Length width) Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction, with the direction from the StartNode towards the EndNode as the longitudinal direction.CrossSectionElement
(CrossSectionLink parentLink, String id, Length lateralOffsetAtBegin, Length lateralOffsetAtEnd, Length beginWidth, Length endWidth, boolean fixGradualLateralOffset) Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction, with the direction from the StartNode towards the EndNode as the longitudinal direction. -
Method Summary
Modifier and TypeMethodDescriptionstatic OtsShape
Construct a buffer geometry by offsetting the linear geometry line with a distance and constructing a so-called "buffer" around it.boolean
final Length
Retrieve the width at the begin of the parent link.final OtsLine3d
Retrieve the center line of this CrossSectionElement.final OtsShape
Retrieve the contour of this CrossSectionElement.final Length
Retrieve the offset from the design line at the begin of the parent link.final Length
Retrieve the offset from the design line at the end of the parent link.final Length
Retrieve the width at the end of the parent link.final String
Retrieve the id of this CrossSectionElement.final String
getId()
Retrieve the id of this CrossSectionElement.final Length
getLateralBoundaryPosition
(LateralDirectionality lateralDirection, double fractionalLongitudinalPosition) Return the lateral offset from the design line of the parent Link of the Left or Right boundary of this CrossSectionElement at the specified fractional longitudinal position.final Length
getLateralBoundaryPosition
(LateralDirectionality lateralDirection, Length longitudinalPosition) Return the lateral offset from the design line of the parent Link of the Left or Right boundary of this CrossSectionElement at the specified longitudinal position.final Length
getLateralCenterPosition
(double fractionalPosition) Retrieve the lateral offset from the Link design line at the specified longitudinal position.final Length
getLateralCenterPosition
(Length longitudinalPosition) Retrieve the lateral offset from the Link design line at the specified longitudinal position.final Length
Return the length of this CrossSectionElement as measured along the design line (which equals the center line).final RoadNetwork
final CrossSectionLink
final Length
getWidth
(double fractionalPosition) Return the width of this CrossSectionElement at a specified fractional longitudinal position.final Length
Return the width of this CrossSectionElement at a specified longitudinal position.double
getZ()
Retrieve the Z offset (used to determine what covers what when drawing).int
hashCode()
toString()
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Field Details
-
parentLink
Cross Section Link to which the element belongs. -
crossSectionSlices
The offsets and widths at positions along the line, relative to the design line of the parent link. -
length
The length of the line. Calculated once at the creation. -
MAXIMUMDIRECTIONERROR
public static final double MAXIMUMDIRECTIONERRORMaximum direction difference w.r.t. node direction at beginning and end of a CrossSectionElement. -
FIXUPPOINTPROPORTION
public static final double FIXUPPOINTPROPORTIONAt what fraction of the first segment will an extra point be inserted if theMAXIMUMDIRECTIONERROR
is exceeded.- See Also:
-
-
Constructor Details
-
CrossSectionElement
public CrossSectionElement(CrossSectionLink parentLink, String id, List<CrossSectionSlice> crossSectionSlices) throws OtsGeometryException, NetworkException Construct a new CrossSectionElement. Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction, with the direction from the StartNode towards the EndNode as the longitudinal direction.- Parameters:
id
- String; The id of the CrossSectionElement. Should be unique within the parentLink.parentLink
- CrossSectionLink; Link to which the element belongs.crossSectionSlices
- List<CrossSectionSlice>; the offsets and widths at positions along the line, relative to the design line of the parent link. If there is just one with and offset, there should just be one element in the list with Length = 0. If there are more slices, the last one should be at the length of the design line. If not, a NetworkException is thrown.- Throws:
OtsGeometryException
- when creation of the geometry failsNetworkException
- when id equal to null or not unique, or there are multiple slices and the last slice does not end at the length of the design line.
-
CrossSectionElement
public CrossSectionElement(CrossSectionLink parentLink, String id, Length lateralOffsetAtBegin, Length lateralOffsetAtEnd, Length beginWidth, Length endWidth, boolean fixGradualLateralOffset) throws OtsGeometryException, NetworkException Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction, with the direction from the StartNode towards the EndNode as the longitudinal direction.- Parameters:
id
- String; The id of the CrossSectionElement. Should be unique within the parentLink.parentLink
- CrossSectionLink; Link to which the element belongs.lateralOffsetAtBegin
- Length; the lateral offset of the design line of the new CrossSectionLink with respect to the design line of the parent Link at the start of the parent LinklateralOffsetAtEnd
- Length; the lateral offset of the design line of the new CrossSectionLink with respect to the design line of the parent Link at the end of the parent LinkbeginWidth
- Length; width at start, positioned symmetrically around the design lineendWidth
- Length; width at end, positioned symmetrically around the design linefixGradualLateralOffset
- boolean; true if gradualLateralOffset needs to be fixed- Throws:
OtsGeometryException
- when creation of the geometry failsNetworkException
- when id equal to null or not unique
-
CrossSectionElement
public CrossSectionElement(CrossSectionLink parentLink, String id, Length lateralOffset, Length width) throws OtsGeometryException, NetworkException Note: LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction, with the direction from the StartNode towards the EndNode as the longitudinal direction.- Parameters:
id
- String; The id of the CrosssSectionElement. Should be unique within the parentLink.parentLink
- CrossSectionLink; Link to which the element belongs.lateralOffset
- Length; the lateral offset of the design line of the new CrossSectionLink with respect to the design line of the parent Linkwidth
- Length; width, positioned symmetrically around the design line- Throws:
OtsGeometryException
- when creation of the geometry failsNetworkException
- when id equal to null or not unique
-
-
Method Details
-
getParentLink
- Returns:
- parentLink.
-
getNetwork
- Returns:
- the road network to which the lane belongs
-
getLateralCenterPosition
Retrieve the lateral offset from the Link design line at the specified longitudinal position.- Parameters:
fractionalPosition
- double; fractional longitudinal position on this Lane- Returns:
- Length; the lateralCenterPosition at the specified longitudinal position
-
getLateralCenterPosition
Retrieve the lateral offset from the Link design line at the specified longitudinal position.- Parameters:
longitudinalPosition
- Length; the longitudinal position on this Lane- Returns:
- Length; the lateralCenterPosition at the specified longitudinal position
-
getWidth
Return the width of this CrossSectionElement at a specified longitudinal position.- Parameters:
longitudinalPosition
- Length; the longitudinal position- Returns:
- Length; the width of this CrossSectionElement at the specified longitudinal position.
-
getWidth
Return the width of this CrossSectionElement at a specified fractional longitudinal position.- Parameters:
fractionalPosition
- double; the fractional longitudinal position- Returns:
- Length; the width of this CrossSectionElement at the specified fractional longitudinal position.
-
getLength
Return the length of this CrossSectionElement as measured along the design line (which equals the center line).- Returns:
- Length; the length of this CrossSectionElement
-
getDesignLineOffsetAtBegin
Retrieve the offset from the design line at the begin of the parent link.- Returns:
- Length; the offset of this CrossSectionElement at the begin of the parent link
-
getDesignLineOffsetAtEnd
Retrieve the offset from the design line at the end of the parent link.- Returns:
- Length; the offset of this CrossSectionElement at the end of the parent link
-
getBeginWidth
Retrieve the width at the begin of the parent link.- Returns:
- Length; the width of this CrossSectionElement at the begin of the parent link
-
getEndWidth
Retrieve the width at the end of the parent link.- Returns:
- Length; the width of this CrossSectionElement at the end of the parent link
-
getZ
public double getZ()Retrieve the Z offset (used to determine what covers what when drawing). -
getCenterLine
Retrieve the center line of this CrossSectionElement.- Returns:
- OtsLine3d; the center line of this CrossSectionElement
-
getContour
Retrieve the contour of this CrossSectionElement.- Returns:
- OtsShape; the contour of this CrossSectionElement
-
getId
Retrieve the id of this CrossSectionElement.- Specified by:
getId
in interfaceorg.opentrafficsim.base.Identifiable
- Returns:
- String; the id of this CrossSectionElement
-
getFullId
Retrieve the id of this CrossSectionElement.- Returns:
- String; the id of this CrossSectionElement
-
getLateralBoundaryPosition
public final Length getLateralBoundaryPosition(LateralDirectionality lateralDirection, double fractionalLongitudinalPosition) Return the lateral offset from the design line of the parent Link of the Left or Right boundary of this CrossSectionElement at the specified fractional longitudinal position.- Parameters:
lateralDirection
- LateralDirectionality; LEFT, or RIGHTfractionalLongitudinalPosition
- double; ranges from 0.0 (begin of parentLink) to 1.0 (end of parentLink)- Returns:
- Length
-
getLateralBoundaryPosition
public final Length getLateralBoundaryPosition(LateralDirectionality lateralDirection, Length longitudinalPosition) Return the lateral offset from the design line of the parent Link of the Left or Right boundary of this CrossSectionElement at the specified longitudinal position.- Parameters:
lateralDirection
- LateralDirectionality; LEFT, or RIGHTlongitudinalPosition
- Length; the position along the length of this CrossSectionElement- Returns:
- Length
-
constructContour
public static OtsShape constructContour(CrossSectionElement cse) throws OtsGeometryException, NetworkException Construct a buffer geometry by offsetting the linear geometry line with a distance and constructing a so-called "buffer" around it.- Parameters:
cse
- CrossSectionElement; the cross section element to construct the contour for- Returns:
- OtsShape; the geometry belonging to this CrossSectionElement.
- Throws:
OtsGeometryException
- when construction of the geometry failsNetworkException
- when the resulting contour is degenerate (cannot happen; we hope)
-
getLocation
- Specified by:
getLocation
in interfaceLocatable
-
getBounds
-
toString
-
hashCode
public int hashCode() -
equals
-