Class LinearLocation
Represents a location along a LineString or MultiLineString.
The referenced geometry is not maintained within this location,
but must be provided for operations which require it.
Various methods are provided to manipulate the location value
and query the geometry it references.
Inherited Members
Namespace: NetTopologySuite.LinearReferencing
Assembly: NetTopologySuite.dll
Syntax
public class LinearLocation : IComparable<LinearLocation>, IComparable
Constructors
| Edit this page View SourceLinearLocation()
Initializes a new instance of the LinearLocation class: creates a location referring to the start of a linear geometry.
Declaration
public LinearLocation()
LinearLocation(LinearLocation)
Creates a new location equal to a given one.
Declaration
public LinearLocation(LinearLocation loc)
Parameters
Type | Name | Description |
---|---|---|
LinearLocation | loc | A linear location |
LinearLocation(int, double)
Initializes a new instance of the LinearLocation class: creates a location referring to the start of a linear geometry.
Declaration
public LinearLocation(int segmentIndex, double segmentFraction)
Parameters
Type | Name | Description |
---|---|---|
int | segmentIndex | Index of the segment. |
double | segmentFraction | The segment fraction. |
LinearLocation(int, int, double)
Initializes a new instance of the LinearLocation class: creates a location referring to the start of a linear geometry.
Declaration
public LinearLocation(int componentIndex, int segmentIndex, double segmentFraction)
Parameters
Type | Name | Description |
---|---|---|
int | componentIndex | Index of the component. |
int | segmentIndex | Index of the segment. |
double | segmentFraction | The segment fraction. |
Properties
| Edit this page View SourceComponentIndex
Gets the component index for this location.
Declaration
public int ComponentIndex { get; }
Property Value
Type | Description |
---|---|
int |
IsVertex
Tests whether this location refers to a vertex:
returns true
if the location is a vertex.
Declaration
public bool IsVertex { get; }
Property Value
Type | Description |
---|---|
bool |
SegmentFraction
Gets the segment fraction for this location.
Declaration
public double SegmentFraction { get; }
Property Value
Type | Description |
---|---|
double |
SegmentIndex
Gets the segment index for this location.
Declaration
public int SegmentIndex { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceClamp(Geometry)
Ensures the indexes are valid for a given linear Geometry.
Declaration
public void Clamp(Geometry linear)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linear | A linear geometry. |
CompareLocationValues(int, int, double)
Compares this object with the specified index values for order.
Declaration
public int CompareLocationValues(int componentIndex1, int segmentIndex1, double segmentFraction1)
Parameters
Type | Name | Description |
---|---|---|
int | componentIndex1 | The component index. |
int | segmentIndex1 | The segment index. |
double | segmentFraction1 | The segment fraction. |
Returns
Type | Description |
---|---|
int | A negative integer, zero, or a positive integer as this |
CompareLocationValues(int, int, double, int, int, double)
Compares two sets of location values for order.
Declaration
public static int CompareLocationValues(int componentIndex0, int segmentIndex0, double segmentFraction0, int componentIndex1, int segmentIndex1, double segmentFraction1)
Parameters
Type | Name | Description |
---|---|---|
int | componentIndex0 | The first component index. |
int | segmentIndex0 | The first segment index. |
double | segmentFraction0 | The first segment fraction. |
int | componentIndex1 | The second component index. |
int | segmentIndex1 | The second segment index. |
double | segmentFraction1 | The second segment fraction. |
Returns
Type | Description |
---|---|
int | A negative integer, zero, or a positive integer as the first set of location values is less than, equal to, or greater than the second set of locationValues. |
CompareTo(LinearLocation)
Compares the current instance with another object of the same type.
Declaration
public int CompareTo(LinearLocation other)
Parameters
Type | Name | Description |
---|---|---|
LinearLocation | other | The |
Returns
Type | Description |
---|---|
int | A negative integer, zero, or a positive integer as this
|
CompareTo(object)
Compares the current instance with another object of the same type.
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The |
Returns
Type | Description |
---|---|
int | A negative integer, zero, or a positive integer as this
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
Copy()
Declaration
public LinearLocation Copy()
Returns
Type | Description |
---|---|
LinearLocation |
GetCoordinate(Geometry)
Gets the Coordinate along the given linear Geometry which is referenced by this location.
Declaration
public Coordinate GetCoordinate(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | A linear geometry. |
Returns
Type | Description |
---|---|
Coordinate | The Coordinate at the location. |
GetEndLocation(Geometry)
Gets a location which refers to the end of a linear Geometry.
Declaration
public static LinearLocation GetEndLocation(Geometry linear)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linear | The linear geometry. |
Returns
Type | Description |
---|---|
LinearLocation | A new |
GetSegment(Geometry)
Gets a LineSegment representing the segment of the given linear Geometry which contains this location.
Declaration
public LineSegment GetSegment(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | A linear geometry |
Returns
Type | Description |
---|---|
LineSegment | the |
GetSegmentLength(Geometry)
Gets the length of the segment in the given Geometry containing this location.
Declaration
public double GetSegmentLength(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | A linear geometry. |
Returns
Type | Description |
---|---|
double | The length of the segment. |
IsEndpoint(Geometry)
Tests whether this location is an endpoint of the linear component it refers to.
Declaration
public bool IsEndpoint(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | The linear geometry referenced by this location |
Returns
Type | Description |
---|---|
bool | True if the location is a component endpoint |
IsOnSameSegment(LinearLocation)
Tests whether two locations are on the same segment in the parent Geometry.
Declaration
public bool IsOnSameSegment(LinearLocation loc)
Parameters
Type | Name | Description |
---|---|---|
LinearLocation | loc | A location on the same geometry |
Returns
Type | Description |
---|---|
bool |
|
IsValid(Geometry)
Tests whether this location refers to a valid location on the given linear Geometry.
Declaration
public bool IsValid(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | A linear geometry. |
Returns
Type | Description |
---|---|
bool |
|
PointAlongSegmentByFraction(Coordinate, Coordinate, double)
Computes the Coordinate of a point a given fraction
along the line segment (p0, p1)
.
Declaration
public static Coordinate PointAlongSegmentByFraction(Coordinate p0, Coordinate p1, double fraction)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p0 | The first point of the line segment. |
Coordinate | p1 | The last point of the line segment. |
double | fraction | The length to the desired point. |
Returns
Type | Description |
---|---|
Coordinate |
Remarks
If the fraction is greater than 1.0 the last point of the segment is returned.
If the fraction is less than or equal to 0.0 the first point of the segment is returned.
The Z ordinate is interpolated from the Z-ordinates of the given points, if they are specified.
SetToEnd(Geometry)
Sets the value of this location to refer to the end of a linear geometry.
Declaration
public void SetToEnd(Geometry linear)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linear | The linear geometry to use to set the end. |
SnapToVertex(Geometry, double)
Snaps the value of this location to
the nearest vertex on the given linear Geometry,
if the vertex is closer than minDistance
.
Declaration
public void SnapToVertex(Geometry linearGeom, double minDistance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | A linear geometry. |
double | minDistance | The minimum allowable distance to a vertex. |
ToLowest(Geometry)
Converts a linear location to the lowest equivalent location index. The lowest index has the lowest possible component and segment indices. Specifically:
- if the location point is an endpoint, a location value is returned as (nseg-1, 1.0)
- if the location point is ambiguous (i.e. an endpoint and a startpoint), the lowest endpoint location is returned If the location index is already the lowest possible value, the original location is returned.
Declaration
public LinearLocation ToLowest(Geometry linearGeom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | linearGeom | The linear geometry referenced by this location. |
Returns
Type | Description |
---|---|
LinearLocation | The lowest equivalent location. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |