GEOS  3.9.1dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geos::operation::overlay::snap::LineStringSnapper Class Reference

Snaps the vertices and segments of a LineString to a set of target snap vertices. More...

#include <LineStringSnapper.h>

Public Member Functions

 LineStringSnapper (const geom::Coordinate::Vect &nSrcPts, double nSnapTol)
 
std::unique_ptr< geom::Coordinate::VectsnapTo (const geom::Coordinate::ConstVect &snapPts)
 
void setAllowSnappingToSourceVertices (bool allow)
 

Private Member Functions

void snapVertices (geom::CoordinateList &srcCoords, const geom::Coordinate::ConstVect &snapPts)
 
geom::Coordinate::ConstVect::const_iterator findSnapForVertex (const geom::Coordinate &pt, const geom::Coordinate::ConstVect &snapPts)
 
void snapSegments (geom::CoordinateList &srcCoords, const geom::Coordinate::ConstVect &snapPts)
 Snap segments of the source to nearby snap vertices. More...
 
geom::CoordinateList::iterator findSegmentToSnap (const geom::Coordinate &snapPt, geom::CoordinateList::iterator from, geom::CoordinateList::iterator too_far)
 Finds a src segment which snaps to (is close to) the given snap point. More...
 
geom::CoordinateList::iterator findVertexToSnap (const geom::Coordinate &snapPt, geom::CoordinateList::iterator from, geom::CoordinateList::iterator too_far)
 
 LineStringSnapper (const LineStringSnapper &other)=delete
 
LineStringSnapperoperator= (const LineStringSnapper &rhs)=delete
 

Private Attributes

const geom::Coordinate::VectsrcPts
 
double snapTolerance
 
bool allowSnappingToSourceVertices
 
bool isClosed
 

Detailed Description

Snaps the vertices and segments of a LineString to a set of target snap vertices.

A snapping distance tolerance is used to control where snapping is performed.

Definition at line 51 of file LineStringSnapper.h.

Constructor & Destructor Documentation

geos::operation::overlay::snap::LineStringSnapper::LineStringSnapper ( const geom::Coordinate::Vect nSrcPts,
double  nSnapTol 
)
inline

Creates a new snapper using the given points as source points to be snapped.

Parameters
nSrcPtsthe points to snap
nSnapTolthe snap tolerance to use

Definition at line 62 of file LineStringSnapper.h.

geos::operation::overlay::snap::LineStringSnapper::LineStringSnapper ( const LineStringSnapper other)
privatedelete

Member Function Documentation

geom::CoordinateList::iterator geos::operation::overlay::snap::LineStringSnapper::findSegmentToSnap ( const geom::Coordinate snapPt,
geom::CoordinateList::iterator  from,
geom::CoordinateList::iterator  too_far 
)
private

Finds a src segment which snaps to (is close to) the given snap point.

Only a single segment is selected for snapping. This prevents multiple segments snapping to the same snap vertex, which would almost certainly cause invalid geometry to be created. (The heuristic approach to snapping used here is really only appropriate when snap pts snap to a unique spot on the src geometry.)

Also, if the snap vertex occurs as a vertex in the src coordinate list, no snapping is performed (may be changed using setAllowSnappingToSourceVertices).

Parameters
froman iterator to first point of first segment to be checked
too_faran iterator to last point of last segment to be checked
Returns
an iterator to the snapped segment or too_far if no segment needs snapping (either none within snapTol distance, or one found on the snapPt)
geom::Coordinate::ConstVect::const_iterator geos::operation::overlay::snap::LineStringSnapper::findSnapForVertex ( const geom::Coordinate pt,
const geom::Coordinate::ConstVect snapPts 
)
private
geom::CoordinateList::iterator geos::operation::overlay::snap::LineStringSnapper::findVertexToSnap ( const geom::Coordinate snapPt,
geom::CoordinateList::iterator  from,
geom::CoordinateList::iterator  too_far 
)
private
LineStringSnapper& geos::operation::overlay::snap::LineStringSnapper::operator= ( const LineStringSnapper rhs)
privatedelete
void geos::operation::overlay::snap::LineStringSnapper::setAllowSnappingToSourceVertices ( bool  allow)
inline

Definition at line 77 of file LineStringSnapper.h.

void geos::operation::overlay::snap::LineStringSnapper::snapSegments ( geom::CoordinateList srcCoords,
const geom::Coordinate::ConstVect snapPts 
)
private

Snap segments of the source to nearby snap vertices.

Source segments are "cracked" at a snap vertex. A single input segment may be snapped several times to different snap vertices.

For each distinct snap vertex, at most one source segment is snapped to. This prevents "cracking" multiple segments at the same point, which would likely cause topology collapse when being used on polygonal linework.

Parameters
srcCoordsthe coordinates of the source linestring to be snapped the object will be modified (coords snapped)
snapPtsthe target snap vertices
std::unique_ptr<geom::Coordinate::Vect> geos::operation::overlay::snap::LineStringSnapper::snapTo ( const geom::Coordinate::ConstVect snapPts)
void geos::operation::overlay::snap::LineStringSnapper::snapVertices ( geom::CoordinateList srcCoords,
const geom::Coordinate::ConstVect snapPts 
)
private

Member Data Documentation

bool geos::operation::overlay::snap::LineStringSnapper::allowSnappingToSourceVertices
private

Definition at line 88 of file LineStringSnapper.h.

bool geos::operation::overlay::snap::LineStringSnapper::isClosed
private

Definition at line 89 of file LineStringSnapper.h.

double geos::operation::overlay::snap::LineStringSnapper::snapTolerance
private

Definition at line 86 of file LineStringSnapper.h.

const geom::Coordinate::Vect& geos::operation::overlay::snap::LineStringSnapper::srcPts
private

Definition at line 84 of file LineStringSnapper.h.


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