GEOS 3.14.0dev
Public Member Functions | List of all members
geos::linearref::LocationIndexedLine Class Reference

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

#include <LocationIndexedLine.h>

Public Member Functions

 LocationIndexedLine (const geom::Geometry *p_linearGeom)
 Constructs an object which allows linear referencing along a given linear Geometry.
 
geom::Coordinate extractPoint (const LinearLocation &index) const
 Computes the Coordinate for the point on the line at the given index.
 
geom::Coordinate extractPoint (const LinearLocation &index, double offsetDistance) const
 Computes the Coordinate for the point on the line at the given index, offset by the given distance.
 
std::unique_ptr< geom::GeometryextractLine (const LinearLocation &startIndex, const LinearLocation &endIndex) const
 Computes the LineString for the interval on the line between the given indices.
 
LinearLocation indexOf (const geom::Coordinate &pt) const
 Computes the index for a given point on the line.
 
LinearLocation indexOfAfter (const geom::Coordinate &pt, const LinearLocation &minIndex) const
 Finds the index for a point on the line which is greater than the given index.
 
LinearLocationindicesOf (const geom::Geometry *subLine) const
 Computes the indices for a subline of the line.
 
LinearLocation project (const geom::Coordinate &pt) const
 Computes the index for the closest point on the line to the given point.
 
LinearLocation getStartIndex () const
 Returns the index of the start of the line.
 
LinearLocation getEndIndex () const
 Returns the index of the end of the line.
 
bool isValidIndex (const LinearLocation &index) const
 Tests whether an index is in the valid index range for the line.
 
LinearLocation clampIndex (const LinearLocation &index) const
 Computes a valid index for this line by clamping the given index to the valid range of index values.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ LocationIndexedLine()

geos::linearref::LocationIndexedLine::LocationIndexedLine ( const geom::Geometry p_linearGeom)
inline

Constructs an object which allows linear referencing along a given linear Geometry.

Parameters
p_linearGeomthe linear geometry to reference along

Member Function Documentation

◆ clampIndex()

LinearLocation geos::linearref::LocationIndexedLine::clampIndex ( const LinearLocation index) const
inline

Computes a valid index for this line by clamping the given index to the valid range of index values.

Returns
a valid index value

References geos::linearref::LinearLocation::clamp().

◆ extractLine()

std::unique_ptr< geom::Geometry > geos::linearref::LocationIndexedLine::extractLine ( const LinearLocation startIndex,
const LinearLocation endIndex 
) const
inline

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.

Parameters
startIndexthe index of the start of the interval
endIndexthe index of the end of the interval
Returns
the linear interval between the indices

◆ extractPoint() [1/2]

geom::Coordinate geos::linearref::LocationIndexedLine::extractPoint ( const LinearLocation index) const
inline

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. The Z-ordinate of the computed point will be interpolated from the Z-ordinates of the line segment containing it, if they exist.

Parameters
indexthe index of the desired point
Returns
the Coordinate at the given index

References geos::linearref::LinearLocation::getCoordinate().

◆ extractPoint() [2/2]

geom::Coordinate geos::linearref::LocationIndexedLine::extractPoint ( const LinearLocation index,
double  offsetDistance 
) const
inline

Computes the Coordinate 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
indexthe index of the desired point
offsetDistancethe 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

References geos::linearref::LinearLocation::getSegment(), and geos::linearref::LinearLocation::getSegmentFraction().

◆ getEndIndex()

LinearLocation geos::linearref::LocationIndexedLine::getEndIndex ( ) const
inline

Returns the index of the end of the line.

Returns
the end index

◆ getStartIndex()

LinearLocation geos::linearref::LocationIndexedLine::getStartIndex ( ) const
inline

Returns the index of the start of the line.

Returns
the start index

◆ indexOf()

LinearLocation geos::linearref::LocationIndexedLine::indexOf ( const geom::Coordinate pt) const
inline

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 to compute a guaranteed result for points which may be far from the line.

Parameters
pta point on the line
Returns
the index of the point
See also
project

◆ indexOfAfter()

LinearLocation geos::linearref::LocationIndexedLine::indexOfAfter ( const geom::Coordinate pt,
const LinearLocation minIndex 
) const
inline

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 to compute a guaranteed result for points which may be far from the line.

Parameters
pta point on the line
minIndexthe value the returned index must be greater than
Returns
the index of the point greater than the given minimum index
See also
project

◆ indicesOf()

LinearLocation * geos::linearref::LocationIndexedLine::indicesOf ( const geom::Geometry subLine) const
inline

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
subLinea subLine of the line
Returns
a pair of indices for the start and end of the subline.

◆ isValidIndex()

bool geos::linearref::LocationIndexedLine::isValidIndex ( const LinearLocation index) const
inline

Tests whether an index is in the valid index range for the line.

Parameters
indexthe index to test
Returns
true if the index is in the valid range

References geos::linearref::LinearLocation::isValid().

◆ project()

LinearLocation geos::linearref::LocationIndexedLine::project ( const geom::Coordinate pt) const
inline

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
pta point on the line
Returns
the index of the point

The documentation for this class was generated from the following file: