public class OTSLine3D extends Object implements Locatable, Serializable
Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2015-07-16 10:20:53 +0200 (Thu, 16 Jul 2015) $, @version $Revision: 1124 $, by $Author: pknoppers $,
initial version Jul 22, 2015
Modifier and Type | Class and Description |
---|---|
static class |
OTSLine3D.FractionalFallback
Fallback method for when fractional projection fails as the point is beyond the line or from numerical limitations.
|
static class |
OTSLine3D.OffsetMethod
Which offsetLine method to use...
|
Modifier and Type | Field and Description |
---|---|
static OTSLine3D.OffsetMethod |
OFFSETMETHOD
Which offset line method to use...
|
Constructor and Description |
---|
OTSLine3D(com.vividsolutions.jts.geom.Coordinate[] coordinates)
Construct a new OTSLine3D from an array of Coordinate.
|
OTSLine3D(com.vividsolutions.jts.geom.Geometry geometry)
Construct a new OTSLine3D from a Geometry.
|
OTSLine3D(com.vividsolutions.jts.geom.LineString lineString)
Construct a new OTSLine3D from a LineString.
|
OTSLine3D(List<OTSPoint3D> pointList)
Construct a new OTSLine3D from a List<OTSPoint3D>.
|
OTSLine3D(OTSPoint3D... points)
Construct a new OTSLine3D.
|
OTSLine3D(Path2D path)
Construct a new OTSShape (closed shape) from a Path2D.
|
Modifier and Type | Method and Description |
---|---|
static OTSLine3D |
concatenate(double toleranceSI,
OTSLine3D... lines)
Concatenate several OTSLine3D instances.
|
static OTSLine3D |
concatenate(double toleranceSI,
OTSLine3D line1,
OTSLine3D line2)
Concatenate two OTSLine3D instances.
|
static OTSLine3D |
concatenate(OTSLine3D... lines)
Concatenate several OTSLine3D instances.
|
static OTSLine3D |
createAndCleanOTSLine3D(List<OTSPoint3D> pointList)
Create an OTSLine3D, while cleaning repeating successive points.
|
static OTSLine3D |
createAndCleanOTSLine3D(OTSPoint3D... points)
Create an OTSLine3D, while cleaning repeating successive points.
|
boolean |
equals(Object obj) |
OTSLine3D |
extract(double start,
double end)
Create a new OTSLine3D that covers a sub-section of this OTSLine3D.
|
OTSLine3D |
extract(Length start,
Length end)
Create a new OTSLine3D that covers a sub-section of this OTSLine3D.
|
OTSLine3D |
extractFractional(double start,
double end)
Construct a new OTSLine3D covering the indicated fraction of this OTSLine3D.
|
OTSPoint3D |
get(int i)
Return one point of this OTSLine3D.
|
javax.media.j3d.Bounds |
getBounds() |
OTSPoint3D |
getCentroid()
Retrieve the centroid of this OTSLine3D.
|
com.vividsolutions.jts.geom.Coordinate[] |
getCoordinates()
Construct a Coordinate array and fill it with the points of this OTSLine3D.
|
com.vividsolutions.jts.geom.Envelope |
getEnvelope()
Get the bounding rectangle of this OTSLine3D.
|
OTSPoint3D |
getFirst()
Return the first point of this OTSLine3D.
|
OTSPoint3D |
getLast()
Return the last point of this OTSLine3D.
|
Length |
getLength()
Return the length of this OTSLine3D in meters.
|
double |
getLengthSI()
Return the length of this OTSLine3D as a double value in SI units.
|
com.vividsolutions.jts.geom.LineString |
getLineString()
Construct a LineString from this OTSLine3D.
|
DirectedPoint |
getLocation() |
DirectedPoint |
getLocation(Length position)
Get the location at a position on the line, with its direction.
|
DirectedPoint |
getLocationExtended(Length position)
Get the location at a position on the line, with its direction.
|
DirectedPoint |
getLocationExtendedSI(double positionSI)
Get the location at a position on the line, with its direction.
|
DirectedPoint |
getLocationFraction(double fraction)
Get the location at a fraction of the line, with its direction.
|
DirectedPoint |
getLocationFraction(double fraction,
double tolerance)
Get the location at a fraction of the line, with its direction.
|
DirectedPoint |
getLocationFractionExtended(double fraction)
Get the location at a fraction of the line (or outside the line), with its direction.
|
DirectedPoint |
getLocationSI(double positionSI)
Get the location at a position on the line, with its direction.
|
OTSPoint3D[] |
getPoints()
Return an array of OTSPoint3D that represents this OTSLine3D.
|
int |
hashCode() |
static void |
main(String[] args) |
OTSLine3D |
noiseFilteredLine(double noiseLevel)
Construct a line that is equal to this line except for segments that are shorter than the noiseLevel.
|
OTSLine3D |
noiseFilterRamerDouglasPeuker(double epsilon,
boolean useHorizontalDistance)
Clean up a list of points that describe a polyLine by removing points that lie within epsilon distance of a more
straightened version of the line.
|
OTSLine3D |
offsetLine(double offset)
Construct parallel line.
TODO Let the Z-component of the result follow the Z-values of the reference line. |
OTSLine3D |
offsetLine(double[] relativeFractions,
double[] offsets)
Create a line at linearly varying offset from this line.
|
OTSLine3D |
offsetLine(double offsetAtStart,
double offsetAtEnd)
Create a line at linearly varying offset from this line.
|
double |
projectFractional(Direction start,
Direction end,
double x,
double y,
OTSLine3D.FractionalFallback fallback)
Returns the fractional projection of a point to a line.
|
double |
projectOrthogonal(double x,
double y)
Returns the fractional position along this line of the orthogonal projection of point (x, y) on this line.
|
OTSLine3D |
reverse()
Construct a new OTSLine3D with all points of this OTSLine3D in reverse order.
|
int |
size()
Return the number of points in this OTSLine3D.
|
String |
toExcel() |
String |
toPlot() |
String |
toString() |
OTSLine3D |
truncate(double lengthSI)
Truncate a line at the given length (less than the length of the line, and larger than zero) and return a new line.
|
public static final OTSLine3D.OffsetMethod OFFSETMETHOD
public OTSLine3D(OTSPoint3D... points) throws OTSGeometryException
points
- the array of points to construct this OTSLine3D from.OTSGeometryException
- when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(com.vividsolutions.jts.geom.Coordinate[] coordinates) throws OTSGeometryException
coordinates
- the array of coordinates to construct this OTSLine3D fromOTSGeometryException
- when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(com.vividsolutions.jts.geom.LineString lineString) throws OTSGeometryException
lineString
- the lineString to construct this OTSLine3D from.OTSGeometryException
- when the provided LineString does not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(com.vividsolutions.jts.geom.Geometry geometry) throws OTSGeometryException
geometry
- the geometry to construct this OTSLine3D fromOTSGeometryException
- when the provided Geometry do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(List<OTSPoint3D> pointList) throws OTSGeometryException
pointList
- the list of points to construct this OTSLine3D from.OTSGeometryException
- when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(Path2D path) throws OTSGeometryException
path
- the Path2D to construct this OTSLine3D from.OTSGeometryException
- when the provided points do not constitute a valid line (too few points or identical
adjacent points)public final OTSLine3D offsetLine(double offset)
offset
- double; offset distance from the reference line; positive is LEFT, negative is RIGHTpublic final OTSLine3D noiseFilteredLine(double noiseLevel)
noiseLevel
- double; the minimum segment length that is not removedpublic final OTSLine3D noiseFilterRamerDouglasPeuker(double epsilon, boolean useHorizontalDistance)
epsilon
- double; maximal deviationuseHorizontalDistance
- boolean; if true; the horizontal distance is used; if false; the 3D distance is usedpublic final OTSLine3D offsetLine(double offsetAtStart, double offsetAtEnd) throws OTSGeometryException
offsetAtStart
- double; offset at the start of the reference line (positive value is Left, negative value is Right)offsetAtEnd
- double; offset at the end of the reference line (positive value is Left, negative value is Right)OTSGeometryException
- when this method fails to create the offset linepublic final OTSLine3D offsetLine(double[] relativeFractions, double[] offsets) throws OTSGeometryException
relativeFractions
- double[]; positional fractions for which the offsets have to be generatedoffsets
- double[]; offsets at the relative positions (positive value is Left, negative value is Right)OTSGeometryException
- when this method fails to create the offset linepublic static OTSLine3D concatenate(OTSLine3D... lines) throws OTSGeometryException
lines
- OTSLine3D... one or more OTSLine3D. The last point of the first must match the first of the
second, etc.OTSGeometryException
- if zero lines are given, or when there is a gap between consecutive linespublic static OTSLine3D concatenate(double toleranceSI, OTSLine3D line1, OTSLine3D line2) throws OTSGeometryException
toleranceSI
- the tolerance between the end point of a line and the first point of the next lineline1
- OTSLine3D; first lineline2
- OTSLine3D; second lineOTSGeometryException
- if zero lines are given, or when there is a gap between consecutive linespublic static OTSLine3D concatenate(double toleranceSI, OTSLine3D... lines) throws OTSGeometryException
toleranceSI
- the tolerance between the end point of a line and the first point of the next linelines
- OTSLine3D... one or more OTSLine3D. The last point of the first must match the first of the
second, etc.OTSGeometryException
- if zero lines are given, or when there is a gap between consecutive linespublic final OTSLine3D reverse()
public final OTSLine3D extractFractional(double start, double end) throws OTSGeometryException
start
- double; starting point, valid range [0..end)end
- double; ending point, valid range (start..1]OTSGeometryException
- when start >= end, or start < 0, or end > 1public final OTSLine3D extract(Length start, Length end) throws OTSGeometryException
start
- Length; the length along this OTSLine3D where the sub-section starts, valid range [0..end)end
- Length; length along this OTSLine3D where the sub-section ends, valid range
(start..length (length is the length of this OTSLine3D)OTSGeometryException
- when start >= end, or start < 0, or end > lengthpublic final OTSLine3D extract(double start, double end) throws OTSGeometryException
start
- double; length along this OTSLine3D where the sub-section starts, valid range [0..end)end
- double; length along this OTSLine3D where the sub-section ends, valid range
(start..length (length is the length of this OTSLine3D)OTSGeometryException
- when start >= end, or start < 0, or end > lengthpublic static OTSLine3D createAndCleanOTSLine3D(OTSPoint3D... points) throws OTSGeometryException
points
- the coordinates of the line as OTSPoint3DOTSGeometryException
- when number of points < 2public static OTSLine3D createAndCleanOTSLine3D(List<OTSPoint3D> pointList) throws OTSGeometryException
pointList
- List<OTSPoint3D>; list of the coordinates of the line as OTSPoint3D; any duplicate points in this
list are removed (this method may modify the provided list)OTSGeometryException
- when number of non-equal points < 2public final com.vividsolutions.jts.geom.Coordinate[] getCoordinates()
public final com.vividsolutions.jts.geom.LineString getLineString()
public final int size()
public final OTSPoint3D getFirst()
public final OTSPoint3D getLast()
public final OTSPoint3D get(int i) throws OTSGeometryException
i
- int; the index of the point to retrieveOTSGeometryException
- when i < 0 or i > the number of pointspublic final double getLengthSI()
public final Length getLength()
public final OTSPoint3D[] getPoints()
public final DirectedPoint getLocationExtended(Length position)
position
- the position on the line for which to calculate the point on, before, of after the linepublic final DirectedPoint getLocationExtendedSI(double positionSI)
positionSI
- the position on the line for which to calculate the point on, before, of after the line, in SI unitspublic final DirectedPoint getLocationFraction(double fraction) throws OTSGeometryException
fraction
- the fraction for which to calculate the point on the lineOTSGeometryException
- when fraction less than 0.0 or more than 1.0.public final DirectedPoint getLocationFraction(double fraction, double tolerance) throws OTSGeometryException
fraction
- the fraction for which to calculate the point on the linetolerance
- the delta from 0.0 and 1.0 that will be forgivenOTSGeometryException
- when fraction less than 0.0 or more than 1.0.public final DirectedPoint getLocationFractionExtended(double fraction)
fraction
- the fraction for which to calculate the point on the linepublic final DirectedPoint getLocation(Length position) throws OTSGeometryException
position
- the position on the line for which to calculate the point on the lineOTSGeometryException
- when position less than 0.0 or more than line length.public final DirectedPoint getLocationSI(double positionSI) throws OTSGeometryException
positionSI
- the position on the line for which to calculate the point on the lineOTSGeometryException
- when position less than 0.0 or more than line length.public final OTSLine3D truncate(double lengthSI) throws OTSGeometryException
lengthSI
- the location where to truncate the lineOTSGeometryException
- when position less than 0.0 or more than line length.public final double projectOrthogonal(double x, double y)
x
- x-coordinate of point to projecty
- y-coordinate of point to projectpublic final double projectFractional(Direction start, Direction end, double x, double y, OTSLine3D.FractionalFallback fallback)
____________________________ G . . | | . . . | . . . . helper lines | . . . | _.._.._ projection line | I. . . |____________________________| _.'._ . L F. _.' . '-. . .. B _.' . '-. . . _.\ . . D . . _.' : . . J . . _.' \ . . .. . _.' : . M . . ..-' \ . . . /H. A . . . / . . C _________/ . . . . . . K . . . . . . . . . . . . N . . . . . . . . . . . . . . . . . .E . . . . . .Fractional projection may fail in three cases.
orthoFallback = true
, or NaN
if orthoFallback = false
.start
- direction in first pointend
- direction in last pointx
- x-coordinate of point to projecty
- y-coordinate of point to projectfallback
- fallback method for when fractional projection failspublic final OTSPoint3D getCentroid()
public final com.vividsolutions.jts.geom.Envelope getEnvelope()
public DirectedPoint getLocation()
getLocation
in interface Locatable
public final String toExcel()
public final String toPlot()
public static void main(String[] args) throws OTSGeometryException
args
- String[]; the command line arguments (not used)OTSGeometryException
- in case of errorCopyright © 2014–2018 Delft University of Technology. All rights reserved.