Package org.locationtech.jts.linearref
Class LocationIndexedLine
java.lang.Object
org.locationtech.jts.linearref.LocationIndexedLine
Supports linear referencing
along a linear
Geometry
using LinearLocation
s as the index.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocationIndexedLine
(Geometry linearGeom) Constructs an object which allows linear referencing along a given linearGeometry
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
clampIndex
(LinearLocation index) Computes a valid index for this line by clamping the given index to the valid range of index valuesextractLine
(LinearLocation startIndex, LinearLocation endIndex) Computes theLineString
for the interval on the line between the given indices.extractPoint
(LinearLocation index) Computes theCoordinate
for the point on the line at the given index.extractPoint
(LinearLocation index, double offsetDistance) Computes theCoordinate
for the point on the line at the given index, offset by the given distance.Returns the index of the end of the lineReturns the index of the start of the lineindexOf
(Coordinate pt) Computes the index for a given point on the line.indexOfAfter
(Coordinate pt, LinearLocation minIndex) Finds the index for a point on the line which is greater than the given index.Computes the indices for a subline of the line.boolean
isValidIndex
(LinearLocation index) Tests whether an index is in the valid index range for the line.project
(Coordinate pt) Computes the index for the closest point on the line to the given point.
-
Field Details
-
linearGeom
-
-
Constructor Details
-
LocationIndexedLine
Constructs an object which allows linear referencing along a given linearGeometry
.- Parameters:
linearGeom
- the linear geometry to reference along
-
-
Method Details
-
checkGeometryType
private void checkGeometryType() -
extractPoint
Computes theCoordinate
for the point on the line at the given index. If the index is out of range the first or last point on the line will be returned. The Z-ordinate of the computed point will be interpolated from the Z-ordinates of the line segment containing it, if they exist.- Parameters:
index
- the index of the desired point- Returns:
- the Coordinate at the given index
-
extractPoint
Computes theCoordinate
for the point on the line at the given index, offset by the given distance. If the index is out of range the first or last point on the line will be returned. The computed point is offset to the left of the line if the offset distance is positive, to the right if negative. The Z-ordinate of the computed point will be interpolated from the Z-ordinates of the line segment containing it, if they exist.- Parameters:
index
- the index of the desired pointoffsetDistance
- the distance the point is offset from the segment (positive is to the left, negative is to the right)- Returns:
- the Coordinate at the given index
-
extractLine
Computes theLineString
for the interval on the line between the given indices. If the start location is after the end location, the computed linear geometry has reverse orientation to the input line.- Parameters:
startIndex
- the index of the start of the intervalendIndex
- the index of the end of the interval- Returns:
- the linear geometry between the indices
-
indexOf
Computes the index for a given point on the line.The supplied point does not necessarily have to lie precisely on the line, but if it is far from the line the accuracy and performance of this function is not guaranteed. Use
project(org.locationtech.jts.geom.Coordinate)
to compute a guaranteed result for points which may be far from the line.- Parameters:
pt
- a point on the line- Returns:
- the index of the point
- See Also:
-
indexOfAfter
Finds the index for a point on the line which is greater than the given index. If no such index exists, returns minIndex. This method can be used to determine all indexes for a point which occurs more than once on a non-simple line. It can also be used to disambiguate cases where the given point lies slightly off the line and is equidistant from two different points on the line. The supplied point does not necessarily have to lie precisely on the line, but if it is far from the line the accuracy and performance of this function is not guaranteed. Useproject(org.locationtech.jts.geom.Coordinate)
to compute a guaranteed result for points which may be far from the line.- Parameters:
pt
- a point on the lineminIndex
- the value the returned index must be greater than- Returns:
- the index of the point greater than the given minimum index
- See Also:
-
indicesOf
Computes the indices for a subline of the line. (The subline must conform to the line; that is, all vertices in the subline (except possibly the first and last) must be vertices of the line and occur in the same order).- Parameters:
subLine
- a subLine of the line- Returns:
- a pair of indices for the start and end of the subline.
-
project
Computes the index for the closest point on the line to the given point. If more than one point has the closest distance the first one along the line is returned. (The point does not necessarily have to lie precisely on the line.)- Parameters:
pt
- a point on the line- Returns:
- the index of the point
-
getStartIndex
Returns the index of the start of the line- Returns:
- the location index
-
getEndIndex
Returns the index of the end of the line- Returns:
- the location index
-
isValidIndex
Tests whether an index is in the valid index range for the line.- Parameters:
index
- the index to test- Returns:
true
if the index is in the valid range
-
clampIndex
Computes a valid index for this line by clamping the given index to the valid range of index values- Returns:
- a valid index value
-