GEOS  3.13.0dev
Public Member Functions | Static Public Member Functions | Friends | List of all members
geos::linearref::LinearLocation Class Reference

Represents a location along a LineString or MultiLineString. More...

#include <LinearLocation.h>

Public Member Functions

 LinearLocation (std::size_t segmentIndex=0, double segmentFraction=0.0)
 Creates a location referring to the start of a linear geometry.
 
 LinearLocation (std::size_t componentIndex, std::size_t segmentIndex, double segmentFraction)
 
void clamp (const geom::Geometry *linear)
 Ensures the indexes are valid for a given linear Geometry. More...
 
void snapToVertex (const geom::Geometry *linearGeom, double minDistance)
 Snaps the value of this location to the nearest vertex on the given linear Geometry, if the vertex is closer than minDistance. More...
 
double getSegmentLength (const geom::Geometry *linearGeom) const
 Gets the length of the segment in the given Geometry containing this location. More...
 
void setToEnd (const geom::Geometry *linear)
 Sets the value of this location to refer the end of a linear geometry. More...
 
std::size_t getComponentIndex () const
 Gets the component index for this location. More...
 
std::size_t getSegmentIndex () const
 Gets the segment index for this location. More...
 
double getSegmentFraction () const
 Gets the segment fraction for this location. More...
 
bool isVertex () const
 Tests whether this location refers to a vertex. More...
 
geom::Coordinate getCoordinate (const geom::Geometry *linearGeom) const
 Gets the Coordinate along the given linear Geometry which is referenced by this location. More...
 
std::unique_ptr< geom::LineSegmentgetSegment (const geom::Geometry *linearGeom) const
 Gets a LineSegment representing the segment of the given linear Geometry which contains this location. More...
 
bool isValid (const geom::Geometry *linearGeom) const
 Tests whether this location refers to a valid location on the given linear Geometry. More...
 
int compareTo (const LinearLocation &other) const
 Compares this object with the specified object for order. More...
 
int compareLocationValues (std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1) const
 Compares this object with the specified index values for order. More...
 
bool isOnSameSegment (const LinearLocation &loc) const
 Tests whether two locations are on the same segment in the parent Geometry. More...
 
bool isEndpoint (const geom::Geometry &linearGeom) const
 Tests whether this location is an endpoint of the linear component it refers to. More...
 

Static Public Member Functions

static LinearLocation getEndLocation (const geom::Geometry *linear)
 Gets a location which refers to the end of a linear Geometry. More...
 
static geom::Coordinate pointAlongSegmentByFraction (const geom::Coordinate &p0, const geom::Coordinate &p1, double frac)
 Computes the Coordinate of a point a given fraction along the line segment (p0, p1). More...
 
static int compareLocationValues (std::size_t componentIndex0, std::size_t segmentIndex0, double segmentFraction0, std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1)
 Compares two sets of location values for order. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const LinearLocation &obj)
 

Detailed Description

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.

Member Function Documentation

◆ clamp()

void geos::linearref::LinearLocation::clamp ( const geom::Geometry linear)

Ensures the indexes are valid for a given linear Geometry.

Parameters
lineara linear geometry

Referenced by geos::linearref::LocationIndexedLine::clampIndex().

◆ compareLocationValues() [1/2]

static int geos::linearref::LinearLocation::compareLocationValues ( std::size_t  componentIndex0,
std::size_t  segmentIndex0,
double  segmentFraction0,
std::size_t  componentIndex1,
std::size_t  segmentIndex1,
double  segmentFraction1 
)
static

Compares two sets of location values for order.

Parameters
componentIndex0a component index
segmentIndex0a segment index
segmentFraction0a segment fraction
componentIndex1another component index
segmentIndex1another segment index
segmentFraction1another segment fraction
Returns
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

◆ compareLocationValues() [2/2]

int geos::linearref::LinearLocation::compareLocationValues ( std::size_t  componentIndex1,
std::size_t  segmentIndex1,
double  segmentFraction1 
) const

Compares this object with the specified index values for order.

Parameters
componentIndex1a component index
segmentIndex1a segment index
segmentFraction1a segment fraction
Returns
a negative integer, zero, or a positive integer as this LinearLocation is less than, equal to, or greater than the specified locationValues

◆ compareTo()

int geos::linearref::LinearLocation::compareTo ( const LinearLocation other) const

Compares this object with the specified object for order.

Parameters
otherthe LinearLocation with which this Coordinate is being compared
Returns
a negative integer, zero, or a positive integer as this LinearLocation is less than, equal to, or greater than the specified LinearLocation

◆ getComponentIndex()

std::size_t geos::linearref::LinearLocation::getComponentIndex ( ) const

Gets the component index for this location.

Returns
the component index

◆ getCoordinate()

geom::Coordinate geos::linearref::LinearLocation::getCoordinate ( const geom::Geometry linearGeom) const

Gets the Coordinate along the given linear Geometry which is referenced by this location.

Parameters
linearGeomthe linear geometry referenced by this location
Returns
the Coordinate at the location

Referenced by geos::linearref::LocationIndexedLine::extractPoint().

◆ getEndLocation()

static LinearLocation geos::linearref::LinearLocation::getEndLocation ( const geom::Geometry linear)
static

Gets a location which refers to the end of a linear Geometry.

Parameters
linearthe linear geometry
Returns
a new LinearLocation

Referenced by geos::linearref::LocationIndexedLine::getEndIndex().

◆ getSegment()

std::unique_ptr<geom::LineSegment> geos::linearref::LinearLocation::getSegment ( const geom::Geometry linearGeom) const

Gets a LineSegment representing the segment of the given linear Geometry which contains this location.

Parameters
linearGeoma linear geometry
Returns
the LineSegment containing the location

Referenced by geos::linearref::LocationIndexedLine::extractPoint().

◆ getSegmentFraction()

double geos::linearref::LinearLocation::getSegmentFraction ( ) const

Gets the segment fraction for this location.

Returns
the segment fraction

Referenced by geos::linearref::LocationIndexedLine::extractPoint().

◆ getSegmentIndex()

std::size_t geos::linearref::LinearLocation::getSegmentIndex ( ) const

Gets the segment index for this location.

Returns
the segment index

◆ getSegmentLength()

double geos::linearref::LinearLocation::getSegmentLength ( const geom::Geometry linearGeom) const

Gets the length of the segment in the given Geometry containing this location.

Parameters
linearGeoma linear geometry
Returns
the length of the segment

◆ isEndpoint()

bool geos::linearref::LinearLocation::isEndpoint ( const geom::Geometry linearGeom) const

Tests whether this location is an endpoint of the linear component it refers to.

Parameters
linearGeomthe linear geometry referenced by this location
Returns
true if the location is a component endpoint

◆ isOnSameSegment()

bool geos::linearref::LinearLocation::isOnSameSegment ( const LinearLocation loc) const

Tests whether two locations are on the same segment in the parent Geometry.

Parameters
loca location on the same geometry
Returns
true if the locations are on the same segment of the parent geometry

◆ isValid()

bool geos::linearref::LinearLocation::isValid ( const geom::Geometry linearGeom) const

Tests whether this location refers to a valid location on the given linear Geometry.

Parameters
linearGeoma linear geometry
Returns
true if this location is valid

Referenced by geos::linearref::LocationIndexedLine::isValidIndex().

◆ isVertex()

bool geos::linearref::LinearLocation::isVertex ( ) const

Tests whether this location refers to a vertex.

Returns
true if the location is a vertex

◆ pointAlongSegmentByFraction()

static geom::Coordinate geos::linearref::LinearLocation::pointAlongSegmentByFraction ( const geom::Coordinate p0,
const geom::Coordinate p1,
double  frac 
)
static

Computes the Coordinate of a point a given fraction along the line segment (p0, p1).

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.

Parameters
p0the first point of the line segment
p1the last point of the line segment
fracthe length to the desired point
Returns
the Coordinate of the desired point

◆ setToEnd()

void geos::linearref::LinearLocation::setToEnd ( const geom::Geometry linear)

Sets the value of this location to refer the end of a linear geometry.

Parameters
linearthe linear geometry to set

◆ snapToVertex()

void geos::linearref::LinearLocation::snapToVertex ( const geom::Geometry linearGeom,
double  minDistance 
)

Snaps the value of this location to the nearest vertex on the given linear Geometry, if the vertex is closer than minDistance.

Parameters
linearGeoma linear geometry
minDistancethe minimum allowable distance to a vertex

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