com.vividsolutions.jts.linearref

Class LocationIndexedLine


public class LocationIndexedLine
extends java.lang.Object

Supports linear referencing along a linear Geometry using LinearLocations as the index.

Constructor Summary

LocationIndexedLine(Geometry linearGeom)
Constructs an object which allows linear referencing along a given linear Geometry.

Method Summary

LinearLocation
clampIndex(LinearLocation index)
Computes a valid index for this line by clamping the given index to the valid range of index values
Geometry
extractLine(LinearLocation startIndex, LinearLocation endIndex)
Computes the LineString for the interval on the line between the given indices.
Coordinate
extractPoint(LinearLocation index)
Computes the Coordinate for the point on the line at the given index.
LinearLocation
getEndIndex()
Returns the index of the end of the line
LinearLocation
getStartIndex()
Returns the index of the start of the line
LinearLocation
indexOf(Coordinate pt)
Computes the index for a given point on the line.
LinearLocation[]
indicesOf(Geometry subLine)
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.
LinearLocation
project(Coordinate pt)
Computes the index for the closest point on the line to the given point.

Constructor Details

LocationIndexedLine

public LocationIndexedLine(Geometry linearGeom)
Constructs an object which allows linear referencing along a given linear Geometry.
Parameters:
linearGeom - the linear geometry to reference along

Method Details

clampIndex

public LinearLocation clampIndex(LinearLocation index)
Computes a valid index for this line by clamping the given index to the valid range of index values
Returns:
a valid index value

extractLine

public Geometry extractLine(LinearLocation startIndex,
                            LinearLocation endIndex)
Computes the LineString for the interval on the line between the given indices.
Parameters:
startIndex - the index of the start of the interval
endIndex - the index of the end of the interval
Returns:
the linear interval between the indices

extractPoint

public Coordinate extractPoint(LinearLocation index)
Computes the Coordinate 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.
Parameters:
Returns:
the Coordinate at the given index

getEndIndex

public LinearLocation getEndIndex()
Returns the index of the end of the line
Returns:

getStartIndex

public LinearLocation getStartIndex()
Returns the index of the start of the line
Returns:

indexOf

public LinearLocation indexOf(Coordinate pt)
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(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:
project

indicesOf

public LinearLocation[] indicesOf(Geometry subLine)
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 occcur in the same order).
Parameters:
subLine - a subLine of the line
Returns:
a pair of indices for the start and end of the subline.

isValidIndex

public boolean isValidIndex(LinearLocation index)
Tests whether an index is in the valid index range for the line.
Parameters:
Returns:
true if the index is in the valid range

project

public LinearLocation project(Coordinate pt)
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