Class CrossSectionElement
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.road.network.lane.CrossSectionElement
-
- All Implemented Interfaces:
Serializable
,Locatable
,EventProducerInterface
,Identifiable
,Drawable
- Direct Known Subclasses:
Lane
,RoadMarkerAlong
,Shoulder
public abstract class CrossSectionElement extends EventProducer implements Locatable, Serializable, Identifiable, Drawable
Cross section elements are used to compose a CrossSectionLink.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $, initial version Aug 19, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<CrossSectionSlice>
crossSectionSlices
The offsets and widths at positions along the line, relative to the design line of the parent link.static double
FIXUPPOINTPROPORTION
At what fraction of the first segment will an extra point be inserted if theMAXIMUMDIRECTIONERROR
is exceeded.protected Length
length
The length of the line.static double
MAXIMUMDIRECTIONERROR
Maximum direction difference w.r.t.protected CrossSectionLink
parentLink
Cross Section Link to which the element belongs.-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Constructor Summary
Constructors Modifier Constructor Description CrossSectionElement(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.protected
CrossSectionElement(CrossSectionLink newCrossSectionLink, SimulatorInterface.TimeDoubleUnit newSimulator, CrossSectionElement cse)
Clone a CrossSectionElement for a new network.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract CrossSectionElement
clone(CrossSectionLink newParentLink, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone the CrossSectionElement for e.g., copying a network.static OTSShape
constructContour(CrossSectionElement cse)
Construct a buffer geometry by offsetting the linear geometry line with a distance and constructing a so-called "buffer" around it.boolean
equals(Object obj)
Length
getBeginWidth()
Retrieve the width at the begin of the parent link.javax.media.j3d.Bounds
getBounds()
OTSLine3D
getCenterLine()
Retrieve the center line of this CrossSectionElement.OTSShape
getContour()
Retrieve the contour of this CrossSectionElement.Length
getDesignLineOffsetAtBegin()
Retrieve the offset from the design line at the begin of the parent link.Length
getDesignLineOffsetAtEnd()
Retrieve the offset from the design line at the end of the parent link.Length
getEndWidth()
Retrieve the width at the end of the parent link.String
getFullId()
Retrieve the id of this CrossSectionElement.String
getId()
Retrieve the id of this CrossSectionElement.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.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.Length
getLateralCenterPosition(double fractionalPosition)
Retrieve the lateral offset from the Link design line at the specified longitudinal position.Length
getLateralCenterPosition(Length longitudinalPosition)
Retrieve the lateral offset from the Link design line at the specified longitudinal position.Length
getLength()
Return the length of this CrossSectionElement as measured along the design line (which equals the center line).DirectedPoint
getLocation()
RoadNetwork
getNetwork()
CrossSectionLink
getParentLink()
Serializable
getSourceId()
Length
getWidth(double fractionalPosition)
Return the width of this CrossSectionElement at a specified fractional longitudinal position.Length
getWidth(Length longitudinalPosition)
Return the width of this CrossSectionElement at a specified longitudinal position.protected abstract double
getZ()
Retrieve the Z offset (used to determine what covers what when drawing).int
hashCode()
String
toString()
-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Field Detail
-
parentLink
protected final CrossSectionLink parentLink
Cross Section Link to which the element belongs.
-
crossSectionSlices
protected final List<CrossSectionSlice> crossSectionSlices
The offsets and widths at positions along the line, relative to the design line of the parent link.
-
length
protected final Length length
The length of the line. Calculated once at the creation.
-
MAXIMUMDIRECTIONERROR
public static final double MAXIMUMDIRECTIONERROR
Maximum direction difference w.r.t. node direction at beginning and end of a CrossSectionElement.
-
FIXUPPOINTPROPORTION
public static final double FIXUPPOINTPROPORTION
At what fraction of the first segment will an extra point be inserted if theMAXIMUMDIRECTIONERROR
is exceeded.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
protected CrossSectionElement(CrossSectionLink newCrossSectionLink, SimulatorInterface.TimeDoubleUnit newSimulator, CrossSectionElement cse) throws NetworkException
Clone a CrossSectionElement for a new network.- Parameters:
newCrossSectionLink
- CrossSectionLink; the new link to which the clone belongsnewSimulator
- SimulatorInterface.TimeDoubleUnit; the new simulator for this networkcse
- CrossSectionElement; the element to clone from- Throws:
NetworkException
- if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
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 Detail
-
getParentLink
public final CrossSectionLink getParentLink()
- Returns:
- parentLink.
-
getNetwork
public final RoadNetwork getNetwork()
- Returns:
- the road network to which the lane belongs
-
getLateralCenterPosition
public final Length getLateralCenterPosition(double fractionalPosition)
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
public final Length getLateralCenterPosition(Length longitudinalPosition)
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
public final Length getWidth(Length longitudinalPosition)
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
public final Length getWidth(double fractionalPosition)
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
public final Length 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
public final Length 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
public final Length 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
public final Length 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
public final Length 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
protected abstract double getZ()
Retrieve the Z offset (used to determine what covers what when drawing).- Returns:
- double; the Z-offset for drawing (what's on top, what's underneath).
-
getCenterLine
public final OTSLine3D getCenterLine()
Retrieve the center line of this CrossSectionElement.- Returns:
- OTSLine3D; the center line of this CrossSectionElement
-
getContour
public final OTSShape getContour()
Retrieve the contour of this CrossSectionElement.- Returns:
- OTSShape; the contour of this CrossSectionElement
-
getId
public final String getId()
Retrieve the id of this CrossSectionElement.- Specified by:
getId
in interfaceIdentifiable
- Returns:
- String; the id of this CrossSectionElement
-
getFullId
public final String 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
public DirectedPoint getLocation()
- Specified by:
getLocation
in interfaceLocatable
-
getSourceId
public Serializable getSourceId()
- Specified by:
getSourceId
in interfaceEventProducerInterface
- Specified by:
getSourceId
in classEventProducer
-
clone
public abstract CrossSectionElement clone(CrossSectionLink newParentLink, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkException
Clone the CrossSectionElement for e.g., copying a network.- Parameters:
newParentLink
- CrossSectionLink; the new link to which the clone belongsnewSimulator
- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- a clone of this object
- Throws:
NetworkException
- in case the cloning fails
-
-