Package com.esri.core.geometry
Class Line
- java.lang.Object
-
- com.esri.core.geometry.Geometry
-
- com.esri.core.geometry.Segment
-
- com.esri.core.geometry.Line
-
- All Implemented Interfaces:
java.io.Serializable
public final class Line extends Segment implements java.io.Serializable
A straight line between a pair of points.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.esri.core.geometry.Geometry
Geometry.GeometryAccelerationDegree, Geometry.GeometryType, Geometry.Type
-
-
Field Summary
-
Fields inherited from class com.esri.core.geometry.Segment
m_attributes, m_xEnd, m_xStart, m_yEnd, m_yStart
-
Fields inherited from class com.esri.core.geometry.Geometry
m_description, m_touchFlag
-
-
Constructor Summary
Constructors Constructor Description Line()
Creates a line segment.Line(double x1, double y1, double x2, double y2)
Line(VertexDescription vd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) double
_calculateArea2DHelper(double xorg, double yorg)
A helper function for area calculation.(package private) void
_copyToImpl(Segment dst)
(package private) Point2D
_getTangent(double t)
(package private) static Point2D
_intersectHelper1(Line line1, Line line2, double tolerance)
(package private) double
_intersection(Point2D pt, double tolerance, boolean bExcludeExactEndPoints)
(package private) static int
_intersectLineLine(Line line1, Line line2, Point2D[] intersectionPoints, double[] param1, double[] param2, double tolerance)
(package private) int
_intersectLineLineExact(Line line1, Line line2, Point2D[] intersectionPoints, double[] param1, double[] param2)
(package private) boolean
_isDegenerate(double tolerance)
(package private) static boolean
_isIntersectingHelper(Line line1, Line line2)
(package private) static int
_isIntersectingLineLine(Line line1, Line line2, double tolerance, boolean bExcludeExactEndpoints)
(package private) boolean
_isIntersectingPoint(Point2D pt, double tolerance, boolean bExcludeExactEndpoints)
(package private) boolean
_projectionIntersect(Line other)
(package private) boolean
_projectionIntersectHelper(Line other, Point2D v, boolean bStart)
(package private) int
_side(double ptX, double ptY)
(package private) int
_side(Point2D pt)
void
applyTransformation(Transformation2D transform)
Applies 2D affine transformation in XY plane.(package private) void
applyTransformation(Transformation3D transform)
Applies 3D affine transformation.double
calculateLength2D()
Calculates the length of the geometry.Geometry
createInstance()
Creates an instance of an empty geometry of the same type.Segment
cut(double t1, double t2)
Returns subsegment between parameters t1 and t2.(package private) void
cut(double t1, double t2, SegmentBuffer subSegmentBuffer)
Calculates the subsegment between parameters t1 and t2, and stores the result in subSegmentBuffer.(package private) boolean
equals(Line other)
boolean
equals(java.lang.Object other)
long
estimateMemorySize()
Returns an estimate of this object size in bytes.double
getAttributeAsDbl(double t, int semantics, int ordinate)
Returns the attribute on the segment for the given parameter value.double
getClosestCoordinate(Point2D inputPt, boolean bExtrapolate)
Finds a closest coordinate on this segment.void
getCoord2D(double t, Point2D pt)
Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).(package private) double
getCoordX_(double t)
(package private) double
getCoordY_(double t)
Geometry.Type
getType()
Returns the geometry type.(package private) int
getYMonotonicParts(SegmentBuffer[] monotonicSegments)
Splits this segment into Y monotonic parts and places them into the input array.int
hashCode()
(package private) double
intersectionOfYMonotonicWithAxisX(double y, double x_parallel)
Calculates intersection point of this segment with an infinite line, parallel to axis X.int
intersectionWithAxis2D(boolean b_axis_x, double ordinate, double[] result_ordinates, double[] parameters)
Calculates intersection points of this segment with an infinite line, parallel to one of the axes.(package private) int
intersectionWithEnvelope2D(Envelope2D clipEnv2D, boolean includeEnvBoundary, double[] segParams, double[] envelopeDistances)
boolean
isCurve()
Indicates if the line segment is a curve.(package private) boolean
isDegenerate(double tolerance)
Returns True if the segment is degenerate to a point with relation to the given tolerance.boolean
isIntersecting(Point2D pt, double tolerance)
Returns True if point and the segment intersect (not disjoint) for the given tolerance.(package private) double
lengthToT(double len)
(package private) void
orientBottomUp_()
void
queryEnvelope(Envelope env)
Returns the axis aligned bounding box of the geometry.void
queryEnvelope2D(Envelope2D env)
Returns tight bbox of the Geometry in X, Y plane.(package private) void
queryEnvelope3D(Envelope3D env)
Returns tight bbox of the Geometry in 3D.void
replaceNaNs(int semantics, double value)
Replaces NaNs in the attribute with the given value.java.lang.String
toString()
The output of this method can be only used for debugging.(package private) double
tToLength(double t)
Converts curves parameter t to the curve length.-
Methods inherited from class com.esri.core.geometry.Segment
_assignVertexDescriptionImpl, _attributeCopy, _calculateSubLength, _calculateSubLength, _equalsImpl, _getAttributeAsDbl, _getEndPointOffset, _intersect, _isIntersecting, _resizeAttributes, _reverseImpl, _setAttribute, _setAttribute, calculateArea2D, copyTo, distance, getBoundary, getCoord2D, getDimension, getEndAttributeAsDbl, getEndAttributeAsInt, getEndX, getEndXY, getEndXY, getEndXYZ, getEndY, getStartAttributeAsDbl, getStartAttributeAsInt, getStartX, getStartXY, getStartXY, getStartXYZ, getStartY, intersect, isClosed, isEmpty, isEmptyImpl, isIntersecting, queryCoord, queryEnd, queryInterval, queryStart, reverse, setEmpty, setEnd, setEndAttribute, setEndAttribute, setEndXY, setEndXY, setEndXYZ, setEndXYZ, setStart, setStartAttribute, setStartAttribute, setStartXY, setStartXY, setStartXYZ, setStartXYZ
-
Methods inherited from class com.esri.core.geometry.Geometry
_clone, _getImpl, _touch, addAttribute, addID, addM, addZ, assignVertexDescription, copy, dropAllAttributes, dropAttribute, estimateMemorySize, getDescription, getDimensionFromType, getStateFlag, hasAttribute, hasID, hasM, hasZ, isArea, isLinear, isMultiPath, isMultiVertex, isPoint, isSegment, mergeVertexDescription, queryLooseEnvelope2D, queryLooseEnvelope3D, vertex_count, writeReplace
-
-
-
-
Constructor Detail
-
Line
public Line()
Creates a line segment.
-
Line
Line(VertexDescription vd)
-
Line
public Line(double x1, double y1, double x2, double y2)
-
-
Method Detail
-
getType
public Geometry.Type getType()
Description copied from class:Geometry
Returns the geometry type.
-
estimateMemorySize
public long estimateMemorySize()
Description copied from class:Geometry
Returns an estimate of this object size in bytes.This estimate doesn't include the size of the
VertexDescription
object because instances ofVertexDescription
are shared among geometry objects.- Specified by:
estimateMemorySize
in classGeometry
- Returns:
- Returns an estimate of this object size in bytes.
-
calculateLength2D
public double calculateLength2D()
Description copied from class:Geometry
Calculates the length of the geometry. If the spatial reference is a Geographic Coordinate System (a system where coordinates are defined using angular units such as longitude and latitude) then the 2D distance calculation is returned in angular units. In cases where length must be calculated on a Geographic Coordinate System consider the using the geodeticLength method on theGeometryEngine
- Overrides:
calculateLength2D
in classGeometry
- Returns:
- A double value representing the 2D length of the geometry.
-
isDegenerate
boolean isDegenerate(double tolerance)
Description copied from class:Segment
Returns True if the segment is degenerate to a point with relation to the given tolerance. For Lines this means the line length is not longer than the tolerance. For the curves, the distance between the segment endpoints should not be longer than the tolerance and the distance from the line, connecting the endpoints to the furtherst point on the segment is not larger than the tolerance.- Specified by:
isDegenerate
in classSegment
-
isCurve
public boolean isCurve()
Indicates if the line segment is a curve.
-
_getTangent
Point2D _getTangent(double t)
- Specified by:
_getTangent
in classSegment
-
_isDegenerate
boolean _isDegenerate(double tolerance)
- Specified by:
_isDegenerate
in classSegment
-
queryEnvelope
public void queryEnvelope(Envelope env)
Description copied from class:Geometry
Returns the axis aligned bounding box of the geometry.- Specified by:
queryEnvelope
in classGeometry
- Parameters:
env
- The envelope to return the result in.
-
queryEnvelope2D
public void queryEnvelope2D(Envelope2D env)
Description copied from class:Geometry
Returns tight bbox of the Geometry in X, Y plane.- Specified by:
queryEnvelope2D
in classGeometry
- Parameters:
env
- The envelope to return the result in.
-
queryEnvelope3D
void queryEnvelope3D(Envelope3D env)
Description copied from class:Geometry
Returns tight bbox of the Geometry in 3D.- Specified by:
queryEnvelope3D
in classGeometry
- Parameters:
env
- The envelope to return the result in.
-
applyTransformation
public void applyTransformation(Transformation2D transform)
Description copied from class:Geometry
Applies 2D affine transformation in XY plane.- Specified by:
applyTransformation
in classGeometry
- Parameters:
transform
- The affine transformation to be applied to this geometry.
-
applyTransformation
void applyTransformation(Transformation3D transform)
Description copied from class:Geometry
Applies 3D affine transformation. Adds Z attribute if it is missing.- Specified by:
applyTransformation
in classGeometry
- Parameters:
transform
- The affine transformation to be applied to this geometry.
-
createInstance
public Geometry createInstance()
Description copied from class:Geometry
Creates an instance of an empty geometry of the same type.- Specified by:
createInstance
in classGeometry
- Returns:
- The new instance.
-
_calculateArea2DHelper
double _calculateArea2DHelper(double xorg, double yorg)
Description copied from class:Segment
A helper function for area calculation. Calculates the Integral(y(t) * x'(t) * dt) for t = [0, 1]. The area of a ring is caluclated as a sum of the results of CalculateArea2DHelper.- Specified by:
_calculateArea2DHelper
in classSegment
-
tToLength
double tToLength(double t)
Description copied from class:Segment
Converts curves parameter t to the curve length. Can be expensive for curves.
-
getCoordX_
double getCoordX_(double t)
-
getCoordY_
double getCoordY_(double t)
-
getCoord2D
public void getCoord2D(double t, Point2D pt)
Description copied from class:Segment
Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).- Specified by:
getCoord2D
in classSegment
- Parameters:
t
- the parameter coordinate along the segment from 0.0 to 1.0. Value of 0 returns the start point, 1 returns end point.pt
- the coordinate where result will be placed.
-
cut
public Segment cut(double t1, double t2)
Description copied from class:Segment
Returns subsegment between parameters t1 and t2. The attributes are interpolated along the length of the curve.
-
cut
void cut(double t1, double t2, SegmentBuffer subSegmentBuffer)
Description copied from class:Segment
Calculates the subsegment between parameters t1 and t2, and stores the result in subSegmentBuffer. The attributes are interpolated along the length of the curve.
-
getAttributeAsDbl
public double getAttributeAsDbl(double t, int semantics, int ordinate)
Description copied from class:Segment
Returns the attribute on the segment for the given parameter value. The interpolation of attribute is given by the attribute interpolation type.- Specified by:
getAttributeAsDbl
in classSegment
-
getClosestCoordinate
public double getClosestCoordinate(Point2D inputPt, boolean bExtrapolate)
Description copied from class:Segment
Finds a closest coordinate on this segment.- Specified by:
getClosestCoordinate
in classSegment
- Parameters:
inputPt
- The 2D point to find the closest coordinate on this segment.bExtrapolate
- TRUE if the segment is extrapolated at the end points along the end point tangents. Otherwise the result is limited to values between 0 and 1.- Returns:
- The parametric coordinate t on the segment (0 corresponds to the start point, 1 corresponds to the end point). Use getCoord2D to obtain the 2D coordinate on the segment from t. To find the distance, call (inputPoint.sub(seg.getCoord2D(t))).length();
-
intersectionWithAxis2D
public int intersectionWithAxis2D(boolean b_axis_x, double ordinate, double[] result_ordinates, double[] parameters)
Description copied from class:Segment
Calculates intersection points of this segment with an infinite line, parallel to one of the axes.- Specified by:
intersectionWithAxis2D
in classSegment
- Parameters:
b_axis_x
- TRUE if the function works with the line parallel to the axis X.ordinate
- The ordinate value of the line (x for axis Y, y for axis X).result_ordinates
- The value of ordinate in the intersection points One ordinate is equal to the ordinate parameter. This parameter can be NULL.parameters
- The value of the parameter in the intersection points (between 0 and 1). This parameter can be NULL.- Returns:
- The number of intersection points, 0 when no intersection points exist, -1 when the segment coincides with the line (infinite number of intersection points).
-
intersectionWithEnvelope2D
int intersectionWithEnvelope2D(Envelope2D clipEnv2D, boolean includeEnvBoundary, double[] segParams, double[] envelopeDistances)
-
intersectionOfYMonotonicWithAxisX
double intersectionOfYMonotonicWithAxisX(double y, double x_parallel)
Description copied from class:Segment
Calculates intersection point of this segment with an infinite line, parallel to axis X. This segment must be to be y-monotonic (or horizontal).- Specified by:
intersectionOfYMonotonicWithAxisX
in classSegment
- Parameters:
y
- The y coordinate of the line.x_parallel
- For segments, that are horizontal, and have y coordinate, this value is returned.- Returns:
- X coordinate of the intersection, or NaN, if no intersection.
-
_isIntersectingPoint
boolean _isIntersectingPoint(Point2D pt, double tolerance, boolean bExcludeExactEndpoints)
- Specified by:
_isIntersectingPoint
in classSegment
-
isIntersecting
public boolean isIntersecting(Point2D pt, double tolerance)
Returns True if point and the segment intersect (not disjoint) for the given tolerance.- Overrides:
isIntersecting
in classSegment
-
orientBottomUp_
void orientBottomUp_()
-
_side
int _side(Point2D pt)
-
_side
int _side(double ptX, double ptY)
-
_intersection
double _intersection(Point2D pt, double tolerance, boolean bExcludeExactEndPoints)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
equals
boolean equals(Line other)
-
_projectionIntersectHelper
boolean _projectionIntersectHelper(Line other, Point2D v, boolean bStart)
-
_projectionIntersect
boolean _projectionIntersect(Line other)
-
_isIntersectingLineLine
static int _isIntersectingLineLine(Line line1, Line line2, double tolerance, boolean bExcludeExactEndpoints)
-
_intersectLineLineExact
int _intersectLineLineExact(Line line1, Line line2, Point2D[] intersectionPoints, double[] param1, double[] param2)
-
_intersectLineLine
static int _intersectLineLine(Line line1, Line line2, Point2D[] intersectionPoints, double[] param1, double[] param2, double tolerance)
-
replaceNaNs
public void replaceNaNs(int semantics, double value)
Description copied from class:Geometry
Replaces NaNs in the attribute with the given value. If the geometry is not empty, it adds the attribute if geometry does not have it yet, and replaces the values. If the geometry is empty, it adds the attribute and does not set any values.- Specified by:
replaceNaNs
in classGeometry
- Parameters:
semantics
- The semantics for which to replace the NaNs.value
- The value to replace NaNs with.
-
getYMonotonicParts
int getYMonotonicParts(SegmentBuffer[] monotonicSegments)
Description copied from class:Segment
Splits this segment into Y monotonic parts and places them into the input array.- Specified by:
getYMonotonicParts
in classSegment
- Parameters:
monotonicSegments
- The in/out array of SegmentBuffer structures that will be filled with the monotonic parts. The monotonicSegments array must contain at least 3 elements.- Returns:
- The number of monotonic parts if the split had happened. Returns 0 if the segment is already monotonic.
-
_copyToImpl
void _copyToImpl(Segment dst)
- Specified by:
_copyToImpl
in classSegment
-
-