Class LengthIndexedLine
Supports linear referencing along a linear Geometry using the length along the line as the index. Negative length values are taken as measured in the reverse direction from the end of the geometry. Out-of-range index values are handled by clamping them to the valid range of values. Non-simple lines (i.e. which loop back to cross or touch themselves) are supported.
Inherited Members
Namespace: NetTopologySuite.LinearReferencing
Assembly: NetTopologySuite.dll
Syntax
public class LengthIndexedLine
Constructors
| Edit this page View SourceLengthIndexedLine(Geometry)
Constructs an object which allows a linear Geometry to be linearly referenced using length as an index.
Declaration
public LengthIndexedLine(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | The linear geometry to reference along. |
Properties
| Edit this page View SourceEndIndex
Returns the index of the end of the line.
Declaration
public double EndIndex { get; }
Property Value
Type | Description |
---|---|
double |
StartIndex
Returns the index of the start of the line.
Declaration
public double StartIndex { get; }
Property Value
Type | Description |
---|---|
double |
Methods
| Edit this page View SourceClampIndex(double)
Computes a valid index for this line by clamping the given index to the valid range of index values
Declaration
public double ClampIndex(double index)
Parameters
Type | Name | Description |
---|---|---|
double | index |
Returns
Type | Description |
---|---|
double | A valid index value |
ExtractLine(double, double)
Computes the LineString for the interval
on the line between the given indices.
If the endIndex
lies before the startIndex
,
the computed geometry is reversed.
Declaration
public Geometry ExtractLine(double startIndex, double endIndex)
Parameters
Type | Name | Description |
---|---|---|
double | startIndex | |
double | endIndex |
Returns
Type | Description |
---|---|
Geometry |
ExtractPoint(double)
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.
Declaration
public Coordinate ExtractPoint(double index)
Parameters
Type | Name | Description |
---|---|---|
double | index | The index of the desired point. |
Returns
Type | Description |
---|---|
Coordinate | The Coordinate at the given index. |
Remarks
The Z-ordinate of the computed point will be interpolated from the Z-ordinates of the line segment containing it, if they exist.
ExtractPoint(double, double)
Computes the Coordinate for the point on the line at the given index, offset by the given distance.
Declaration
public Coordinate ExtractPoint(double index, double offsetDistance)
Parameters
Type | Name | Description |
---|---|---|
double | index | The index of the desired point |
double | offsetDistance | The distance the point is offset from the segment (positive is to the left, negative is to the right) |
Returns
Type | Description |
---|---|
Coordinate | The Coordinate at the given index |
Remarks
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.
IndexOf(Coordinate)
Computes the minimum index for a point on the line. If the line is not simple (i.e. loops back on itself) a single point may have more than one possible index. In this case, the smallest index is returned. 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.
Declaration
public double IndexOf(Coordinate pt)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | pt | A point on the line. |
Returns
Type | Description |
---|---|
double | The minimum index of the point. |
See Also
| Edit this page View SourceIndexOfAfter(Coordinate, double)
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.
Use Project(Coordinate) to compute a guaranteed result for points
which may be far from the line.
Declaration
public double IndexOfAfter(Coordinate pt, double minIndex)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | pt | A point on the line. |
double | minIndex | The value the returned index must be greater than. |
Returns
Type | Description |
---|---|
double | The index of the point greater than the given minimum index. |
See Also
| Edit this page View SourceIndicesOf(Geometry)
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).
Declaration
public double[] IndicesOf(Geometry subLine)
Parameters
Type | Name | Description |
---|---|---|
Geometry | subLine | A subLine of the line. |
Returns
Type | Description |
---|---|
double[] | A pair of indices for the start and end of the subline.. |
IsValidIndex(double)
Tests whether an index is in the valid index range for the line.
Declaration
public bool IsValidIndex(double index)
Parameters
Type | Name | Description |
---|---|---|
double | index | The index to test. |
Returns
Type | Description |
---|---|
bool |
|
Project(Coordinate)
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.)
Declaration
public double Project(Coordinate pt)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | pt |
Returns
Type | Description |
---|---|
double |