Package com.esri.core.geometry
Class Segment
java.lang.Object
com.esri.core.geometry.Geometry
com.esri.core.geometry.Segment
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Line
A base class for segments. Presently only Line segments are supported.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.esri.core.geometry.Geometry
Geometry.GeometryAccelerationDegree, Geometry.GeometryType, Geometry.Type
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) double[]
(package private) double
(package private) double
(package private) double
(package private) double
Fields inherited from class com.esri.core.geometry.Geometry
m_description, m_touchFlag
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_assignVertexDescriptionImpl
(VertexDescription newDescription) (package private) static void
_attributeCopy
(double[] src, int srcStart, double[] dst, int dstStart, int count) (package private) abstract double
_calculateArea2DHelper
(double xorg, double yorg) A helper function for area calculation.(package private) double
_calculateSubLength
(double t) (package private) double
_calculateSubLength
(double t1, double t2) (package private) abstract void
_copyToImpl
(Segment dst) (package private) boolean
_equalsImpl
(Segment other) private void
(package private) double
_getAttributeAsDbl
(int endPoint, int semantics, int ordinate) private int
_getAttributeAsInt
(int endPoint, int semantics, int ordinate) (package private) static int
_getEndPointOffset
(VertexDescription vd, int endPoint) (package private) abstract Point2D
_getTangent
(double t) private Point2D
_getXY
(int endPoint) private Point3D
_getXYZ
(int endPoint) (package private) int
_intersect
(Segment other, Point2D[] intersectionPoints, double[] paramThis, double[] paramOther, double tolerance) (package private) abstract boolean
_isDegenerate
(double tolerance) (package private) int
_isIntersecting
(Segment other, double tolerance, boolean bExcludeExactEndpoints) (package private) abstract boolean
_isIntersectingPoint
(Point2D pt, double tolerance, boolean bExcludeExactEndpoints) (package private) void
_resizeAttributes
(int newSize) (package private) void
private void
(package private) void
_setAttribute
(int endPoint, int semantics, int ordinate, double value) (package private) void
_setAttribute
(int endPoint, int semantics, int ordinate, int value) private void
private void
double
Calculates the area of the geometry.void
Copies this geometry to another geometry of the same type.abstract Segment
cut
(double t1, double t2) Returns subsegment between parameters t1 and t2.(package private) abstract void
cut
(double t1, double t2, SegmentBuffer subSegmentBuffer) Calculates the subsegment between parameters t1 and t2, and stores the result in subSegmentBuffer.double
abstract double
getAttributeAsDbl
(double t, int semantics, int ordinate) Returns the attribute on the segment for the given parameter value.Returns boundary of this geometry.abstract double
getClosestCoordinate
(Point2D inputPoint, boolean bExtrapolate) Finds a closest coordinate on this segment.getCoord2D
(double t) Returns the coordinate of the point on this segment for the given parameter value.abstract void
getCoord2D
(double t, Point2D dst) Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).final int
Returns the topological dimension of the geometry object based on the geometry's type.double
getEndAttributeAsDbl
(int semantics, int ordinate) Returns value of the end vertex attribute's ordinate.int
getEndAttributeAsInt
(int semantics, int ordinate) Returns the value of the end vertex attribute's ordinate.double
getEndX()
Returns the X coordinate of ending point.getEndXY()
Returns XY coordinates of the end point.void
Returns XYZ coordinates of the end point.double
getEndY()
Returns the Y coordinate of ending point.double
getStartAttributeAsDbl
(int semantics, int ordinate) Returns value of the start vertex attribute's ordinate.int
getStartAttributeAsInt
(int semantics, int ordinate) Returns the value of the start vertex attribute's ordinate.double
Returns the X coordinate of starting point.Returns XY coordinates of the start point.void
getStartXY
(Point2D pt) Returns XYZ coordinates of the start point.double
Returns the Y coordinate of starting point.(package private) abstract int
getYMonotonicParts
(SegmentBuffer[] monotonicSegments) Splits this segment into Y monotonic parts and places them into the input array.int
hashCode()
(package private) int
intersect
(Segment other, Point2D[] intersectionPoints, double[] paramThis, double[] paramOther, double tolerance) Calculates intersections of this segment with another segment.(package private) abstract double
intersectionOfYMonotonicWithAxisX
(double y, double xParallel) Calculates intersection point of this segment with an infinite line, parallel to axis X.abstract int
intersectionWithAxis2D
(boolean bAxisX, double ordinate, double[] resultOrdinates, double[] parameters) Calculates intersection points of this segment with an infinite line, parallel to one of the axes.(package private) boolean
isClosed()
Returns true, when this segment is a closed curve (start point is equal to end point exactly).(package private) abstract boolean
isCurve()
(package private) abstract boolean
isDegenerate
(double tolerance) Returns True if the segment is degenerate to a point with relation to the given tolerance.final boolean
isEmpty()
IsEmpty returns TRUE when the Geometry object does not contain geometric information beyond its original initialization state.boolean
Non public abstract version of the function.boolean
isIntersecting
(Point2D pt, double tolerance) Returns TRUE if the point and segment intersect (not disjoint) for the given tolerance.boolean
isIntersecting
(Segment other, double tolerance) Returns TRUE if this segment intersects with the other segment with the given tolerance.(package private) abstract double
lengthToT
(double len) (package private) void
queryCoord
(double t, Point point) void
Returns coordinates of the end point in this segment.queryInterval
(int semantics, int ordinate) Returns the min and max attribute values at the ordinate of the Geometry.void
queryStart
(Point dstPoint) Returns coordinates of the start point in a Point class.(package private) void
reverse()
final void
setEmpty()
Returns the geometry to its original initialization state by releasing all data referenced by the geometry.void
Sets the coordinates of the end point in a Point class.void
setEndAttribute
(int semantics, int ordinate, double value) Sets the value of end vertex attribute.void
setEndAttribute
(int semantics, int ordinate, int value) void
setEndXY
(double x, double y) void
Sets the XY coordinates of the end point.void
setEndXYZ
(double x, double y, double z) void
Sets the XYZ coordinates of the end point.void
Sets the coordinates of the start point in this segment.void
setStartAttribute
(int semantics, int ordinate, double value) Sets the value of the start vertex attribute.void
setStartAttribute
(int semantics, int ordinate, int value) void
setStartXY
(double x, double y) void
setStartXY
(Point2D pt) Sets the XY coordinates of the start point.void
setStartXYZ
(double x, double y, double z) void
setStartXYZ
(Point3D pt) Sets the XYZ coordinates of the start point.(package private) abstract double
tToLength
(double t) Converts curves parameter t to the curve length.Methods inherited from class com.esri.core.geometry.Geometry
_clone, _getImpl, _touch, addAttribute, addID, addM, addZ, applyTransformation, applyTransformation, assignVertexDescription, calculateLength2D, copy, createInstance, dropAllAttributes, dropAttribute, estimateMemorySize, estimateMemorySize, getDescription, getDimensionFromType, getStateFlag, getType, hasAttribute, hasID, hasM, hasZ, isArea, isLinear, isMultiPath, isMultiVertex, isPoint, isSegment, mergeVertexDescription, queryEnvelope, queryEnvelope2D, queryEnvelope3D, queryLooseEnvelope2D, queryLooseEnvelope3D, replaceNaNs, toString, vertex_count, writeReplace
-
Field Details
-
m_xStart
double m_xStart -
m_yStart
double m_yStart -
m_xEnd
double m_xEnd -
m_yEnd
double m_yEnd -
m_attributes
double[] m_attributes
-
-
Constructor Details
-
Segment
public Segment()Creates a segment with start and end points (0,0).
-
-
Method Details
-
getStartXY
Returns XY coordinates of the start point. -
getStartXY
-
setStartXY
Sets the XY coordinates of the start point. -
setStartXY
public void setStartXY(double x, double y) -
getStartXYZ
Returns XYZ coordinates of the start point. Z if 0 if Z is missing. -
setStartXYZ
Sets the XYZ coordinates of the start point. -
setStartXYZ
public void setStartXYZ(double x, double y, double z) -
queryStart
Returns coordinates of the start point in a Point class. -
setStart
Sets the coordinates of the start point in this segment.- Parameters:
srcPoint
- The new start point of this segment.
-
getStartAttributeAsDbl
public double getStartAttributeAsDbl(int semantics, int ordinate) Returns value of the start vertex attribute's ordinate. Throws if the Point is empty.- Parameters:
semantics
- The attribute semantics.ordinate
- The attribute's ordinate. For example, the y coordinate of the NORMAL has ordinate of 1.- Returns:
- Ordinate value as double.
-
getStartAttributeAsInt
public int getStartAttributeAsInt(int semantics, int ordinate) Returns the value of the start vertex attribute's ordinate. The ordinate is always 0 because integer attributes always have one component.- Parameters:
semantics
- The attribute semantics.ordinate
- The attribute's ordinate. For example, the y coordinate of the NORMAL has ordinate of 1.- Returns:
- Ordinate value truncated to 32 bit integer.
-
setStartAttribute
public void setStartAttribute(int semantics, int ordinate, double value) Sets the value of the start vertex attribute.- Parameters:
semantics
- The attribute semantics.value
- is the array to write values to. The attribute type and the number of elements must match the persistence type, as well as the number of components of the attribute.
-
setStartAttribute
public void setStartAttribute(int semantics, int ordinate, int value) -
getStartX
public double getStartX()Returns the X coordinate of starting point.- Returns:
- The X coordinate of starting point.
-
getStartY
public double getStartY()Returns the Y coordinate of starting point.- Returns:
- The Y coordinate of starting point.
-
getEndX
public double getEndX()Returns the X coordinate of ending point.- Returns:
- The X coordinate of ending point.
-
getEndY
public double getEndY()Returns the Y coordinate of ending point.- Returns:
- The Y coordinate of ending point.
-
getEndXY
Returns XY coordinates of the end point.- Returns:
- The XY coordinates of the end point.
-
getEndXY
-
setEndXY
Sets the XY coordinates of the end point.- Parameters:
pt
- The end point of the segment.
-
setEndXY
public void setEndXY(double x, double y) -
getEndXYZ
Returns XYZ coordinates of the end point. Z if 0 if Z is missing.- Returns:
- The XYZ coordinates of the end point.
-
setEndXYZ
Sets the XYZ coordinates of the end point. -
setEndXYZ
public void setEndXYZ(double x, double y, double z) -
queryEnd
Returns coordinates of the end point in this segment.- Parameters:
dstPoint
- The end point of this segment.
-
setEnd
Sets the coordinates of the end point in a Point class.- Parameters:
srcPoint
- The new end point of this segment.
-
getEndAttributeAsDbl
public double getEndAttributeAsDbl(int semantics, int ordinate) Returns value of the end vertex attribute's ordinate. Throws if the Point is empty.- Parameters:
semantics
- The attribute semantics.ordinate
- The attribute's ordinate. For example, the y coordinate of the NORMAL has ordinate of 1.- Returns:
- Ordinate value as double.
-
getEndAttributeAsInt
public int getEndAttributeAsInt(int semantics, int ordinate) Returns the value of the end vertex attribute's ordinate. The ordinate is always 0 because integer attributes always have one component.- Parameters:
semantics
- The attribute semantics.ordinate
- The attribute's ordinate. For example, the y coordinate of the NORMAL has ordinate of 1.- Returns:
- The ordinate value truncated to 32 bit integer.
-
setEndAttribute
public void setEndAttribute(int semantics, int ordinate, double value) Sets the value of end vertex attribute.- Parameters:
semantics
- The attribute semantics.ordinate
- The attribute's ordinate.value
- Is the array to write values to. The attribute type and the number of elements must match the persistence type, as well as the number of components of the attribute.
-
setEndAttribute
public void setEndAttribute(int semantics, int ordinate, int value) -
getDimension
public final int getDimension()Description copied from class:Geometry
Returns the topological dimension of the geometry object based on the geometry's type.Returns 0 for point and multipoint.
Returns 1 for lines and polylines.
Returns 2 for polygons and envelopes
Returns 3 for objects with volume
- Specified by:
getDimension
in classGeometry
- Returns:
- Returns the integer value of the dimension of geometry.
-
isEmpty
public final boolean isEmpty()Description copied from class:Geometry
IsEmpty returns TRUE when the Geometry object does not contain geometric information beyond its original initialization state. -
setEmpty
public final void setEmpty()Description copied from class:Geometry
Returns the geometry to its original initialization state by releasing all data referenced by the geometry. -
calculateArea2D
public double calculateArea2D()Description copied from class:Geometry
Calculates the area of the geometry. If the spatial reference is a Geographic Coordinate System (WGS84) then the 2D area calculation is defined in angular units.- Overrides:
calculateArea2D
in classGeometry
- Returns:
- A double value representing the 2D area of the geometry.
-
intersect
int intersect(Segment other, Point2D[] intersectionPoints, double[] paramThis, double[] paramOther, double tolerance) Calculates intersections of this segment with another segment.Note: This is not a topological operation. It needs to be paired with the Segment.Overlap call.
- Parameters:
other
- The segment to calculate intersection with.intersectionPoints
- The intersection points. Can be NULL.paramThis
- The value of the parameter in the intersection points for this Segment (between 0 and 1). Can be NULL.paramOther
- The value of the parameter in the intersection points for the other Segment (between 0 and 1). Can be NULL.tolerance
- The tolerance value for the intersection calculation. Can be 0.- Returns:
- The number of intersection points, 0 when no intersection points exist.
-
isIntersecting
Returns TRUE if this segment intersects with the other segment with the given tolerance. -
isIntersecting
Returns TRUE if the point and segment intersect (not disjoint) for the given tolerance. -
isEmptyImpl
public boolean isEmptyImpl()Non public abstract version of the function. -
_resizeAttributes
void _resizeAttributes(int newSize) -
_attributeCopy
static void _attributeCopy(double[] src, int srcStart, double[] dst, int dstStart, int count) -
_getXY
-
_setXY
-
_getXYZ
-
_setXYZ
-
_assignVertexDescriptionImpl
- Specified by:
_assignVertexDescriptionImpl
in classGeometry
-
_get
-
_set
-
_getAttributeAsDbl
double _getAttributeAsDbl(int endPoint, int semantics, int ordinate) -
_getAttributeAsInt
private int _getAttributeAsInt(int endPoint, int semantics, int ordinate) -
_setAttribute
void _setAttribute(int endPoint, int semantics, int ordinate, double value) -
_setAttribute
void _setAttribute(int endPoint, int semantics, int ordinate, int value) -
copyTo
Description copied from class:Geometry
Copies this geometry to another geometry of the same type. The result geometry is an exact copy. -
queryInterval
Description copied from class:Geometry
Returns the min and max attribute values at the ordinate of the Geometry.- Specified by:
queryInterval
in classGeometry
- Parameters:
semantics
- The semantics of the interval.ordinate
- The ordinate of the interval.- Returns:
- The interval.
-
queryCoord
-
_equalsImpl
-
hashCode
public int hashCode() -
isClosed
boolean isClosed()Returns true, when this segment is a closed curve (start point is equal to end point exactly). Note, this will return true for lines, that are degenerate to a point too. -
reverse
void reverse() -
_isIntersecting
-
_intersect
-
_calculateArea2DHelper
abstract double _calculateArea2DHelper(double xorg, double yorg) 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. -
_getEndPointOffset
-
getCoord2D
Returns the coordinate of the point on this segment for the given parameter value. -
getCoord2D
Returns the coordinate of the point on this segment for the given parameter value (segments are parametric curves).- 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.dst
- the coordinate where result will be placed.
-
getClosestCoordinate
Finds a closest coordinate on this segment.- Parameters:
inputPoint
- 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();
-
getYMonotonicParts
Splits this segment into Y monotonic parts and places them into the input array.- 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.
-
intersectionWithAxis2D
public abstract int intersectionWithAxis2D(boolean bAxisX, double ordinate, double[] resultOrdinates, double[] parameters) Calculates intersection points of this segment with an infinite line, parallel to one of the axes.- Parameters:
bAxisX
- 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).resultOrdinates
- 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).
-
_reverseImpl
void _reverseImpl() -
isDegenerate
abstract boolean isDegenerate(double tolerance) 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. -
isCurve
abstract boolean isCurve() -
_getTangent
-
_isDegenerate
abstract boolean _isDegenerate(double tolerance) -
_calculateSubLength
double _calculateSubLength(double t) -
_calculateSubLength
double _calculateSubLength(double t1, double t2) -
_copyToImpl
-
cut
Returns subsegment between parameters t1 and t2. The attributes are interpolated along the length of the curve. -
cut
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 abstract double getAttributeAsDbl(double t, int semantics, int ordinate) Returns the attribute on the segment for the given parameter value. The interpolation of attribute is given by the attribute interpolation type. -
_isIntersectingPoint
-
intersectionOfYMonotonicWithAxisX
abstract double intersectionOfYMonotonicWithAxisX(double y, double xParallel) Calculates intersection point of this segment with an infinite line, parallel to axis X. This segment must be to be y-monotonic (or horizontal).- Parameters:
y
- The y coordinate of the line.xParallel
- For segments, that are horizontal, and have y coordinate, this value is returned.- Returns:
- X coordinate of the intersection, or NaN, if no intersection.
-
tToLength
abstract double tToLength(double t) Converts curves parameter t to the curve length. Can be expensive for curves. -
lengthToT
abstract double lengthToT(double len) -
distance
-
getBoundary
Description copied from class:Geometry
Returns boundary of this geometry. Polygon and Envelope boundary is a Polyline. For Polyline and Line, the boundary is a Multi_point consisting of path end points. For Multi_point and Point null is returned.- Specified by:
getBoundary
in classGeometry
- Returns:
- The boundary geometry.
-