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)voidapplyTransformation(Transformation2D transform)Applies 2D affine transformation in XY plane.(package private) voidapplyTransformation(Transformation3D transform)Applies 3D affine transformation.doublecalculateLength2D()Calculates the length of the geometry.GeometrycreateInstance()Creates an instance of an empty geometry of the same type.Segmentcut(double t1, double t2)Returns subsegment between parameters t1 and t2.(package private) voidcut(double t1, double t2, SegmentBuffer subSegmentBuffer)Calculates the subsegment between parameters t1 and t2, and stores the result in subSegmentBuffer.(package private) booleanequals(Line other)booleanequals(java.lang.Object other)longestimateMemorySize()Returns an estimate of this object size in bytes.doublegetAttributeAsDbl(double t, int semantics, int ordinate)Returns the attribute on the segment for the given parameter value.doublegetClosestCoordinate(Point2D inputPt, boolean bExtrapolate)Finds a closest coordinate on this segment.voidgetCoord2D(double t, Point2D pt)Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).(package private) doublegetCoordX_(double t)(package private) doublegetCoordY_(double t)Geometry.TypegetType()Returns the geometry type.(package private) intgetYMonotonicParts(SegmentBuffer[] monotonicSegments)Splits this segment into Y monotonic parts and places them into the input array.inthashCode()(package private) doubleintersectionOfYMonotonicWithAxisX(double y, double x_parallel)Calculates intersection point of this segment with an infinite line, parallel to axis X.intintersectionWithAxis2D(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) intintersectionWithEnvelope2D(Envelope2D clipEnv2D, boolean includeEnvBoundary, double[] segParams, double[] envelopeDistances)booleanisCurve()Indicates if the line segment is a curve.(package private) booleanisDegenerate(double tolerance)Returns True if the segment is degenerate to a point with relation to the given tolerance.booleanisIntersecting(Point2D pt, double tolerance)Returns True if point and the segment intersect (not disjoint) for the given tolerance.(package private) doublelengthToT(double len)(package private) voidorientBottomUp_()voidqueryEnvelope(Envelope env)Returns the axis aligned bounding box of the geometry.voidqueryEnvelope2D(Envelope2D env)Returns tight bbox of the Geometry in X, Y plane.(package private) voidqueryEnvelope3D(Envelope3D env)Returns tight bbox of the Geometry in 3D.voidreplaceNaNs(int semantics, double value)Replaces NaNs in the attribute with the given value.java.lang.StringtoString()The output of this method can be only used for debugging.(package private) doubletToLength(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:GeometryReturns the geometry type.
-
estimateMemorySize
public long estimateMemorySize()
Description copied from class:GeometryReturns an estimate of this object size in bytes.This estimate doesn't include the size of the
VertexDescriptionobject because instances ofVertexDescriptionare shared among geometry objects.- Specified by:
estimateMemorySizein classGeometry- Returns:
- Returns an estimate of this object size in bytes.
-
calculateLength2D
public double calculateLength2D()
Description copied from class:GeometryCalculates 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:
calculateLength2Din classGeometry- Returns:
- A double value representing the 2D length of the geometry.
-
isDegenerate
boolean isDegenerate(double tolerance)
Description copied from class:SegmentReturns 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:
isDegeneratein classSegment
-
isCurve
public boolean isCurve()
Indicates if the line segment is a curve.
-
_getTangent
Point2D _getTangent(double t)
- Specified by:
_getTangentin classSegment
-
_isDegenerate
boolean _isDegenerate(double tolerance)
- Specified by:
_isDegeneratein classSegment
-
queryEnvelope
public void queryEnvelope(Envelope env)
Description copied from class:GeometryReturns the axis aligned bounding box of the geometry.- Specified by:
queryEnvelopein classGeometry- Parameters:
env- The envelope to return the result in.
-
queryEnvelope2D
public void queryEnvelope2D(Envelope2D env)
Description copied from class:GeometryReturns tight bbox of the Geometry in X, Y plane.- Specified by:
queryEnvelope2Din classGeometry- Parameters:
env- The envelope to return the result in.
-
queryEnvelope3D
void queryEnvelope3D(Envelope3D env)
Description copied from class:GeometryReturns tight bbox of the Geometry in 3D.- Specified by:
queryEnvelope3Din classGeometry- Parameters:
env- The envelope to return the result in.
-
applyTransformation
public void applyTransformation(Transformation2D transform)
Description copied from class:GeometryApplies 2D affine transformation in XY plane.- Specified by:
applyTransformationin classGeometry- Parameters:
transform- The affine transformation to be applied to this geometry.
-
applyTransformation
void applyTransformation(Transformation3D transform)
Description copied from class:GeometryApplies 3D affine transformation. Adds Z attribute if it is missing.- Specified by:
applyTransformationin classGeometry- Parameters:
transform- The affine transformation to be applied to this geometry.
-
createInstance
public Geometry createInstance()
Description copied from class:GeometryCreates an instance of an empty geometry of the same type.- Specified by:
createInstancein classGeometry- Returns:
- The new instance.
-
_calculateArea2DHelper
double _calculateArea2DHelper(double xorg, double yorg)Description copied from class:SegmentA 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:
_calculateArea2DHelperin classSegment
-
tToLength
double tToLength(double t)
Description copied from class:SegmentConverts 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:SegmentReturns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).- Specified by:
getCoord2Din 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:SegmentReturns 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:SegmentCalculates 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:SegmentReturns the attribute on the segment for the given parameter value. The interpolation of attribute is given by the attribute interpolation type.- Specified by:
getAttributeAsDblin classSegment
-
getClosestCoordinate
public double getClosestCoordinate(Point2D inputPt, boolean bExtrapolate)
Description copied from class:SegmentFinds a closest coordinate on this segment.- Specified by:
getClosestCoordinatein 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:SegmentCalculates intersection points of this segment with an infinite line, parallel to one of the axes.- Specified by:
intersectionWithAxis2Din 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:SegmentCalculates 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:
intersectionOfYMonotonicWithAxisXin 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:
_isIntersectingPointin classSegment
-
isIntersecting
public boolean isIntersecting(Point2D pt, double tolerance)
Returns True if point and the segment intersect (not disjoint) for the given tolerance.- Overrides:
isIntersectingin 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:
equalsin 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:GeometryReplaces 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:
replaceNaNsin 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:SegmentSplits this segment into Y monotonic parts and places them into the input array.- Specified by:
getYMonotonicPartsin 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:
_copyToImplin classSegment
-
-