GEOS  3.13.0dev
Public Types | Public Member Functions | Static Public Member Functions | List of all members
geos::operation::overlay::snap::GeometrySnapper Class Reference

Snaps the vertices and segments of a geom::Geometry to another Geometry's vertices. More...

#include <GeometrySnapper.h>

Public Types

typedef std::unique_ptr< geom::GeometryGeomPtr
 

Public Member Functions

 GeometrySnapper (const geom::Geometry &g)
 
std::unique_ptr< geom::GeometrysnapTo (const geom::Geometry &g, double snapTolerance)
 Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of the given snap geometry with a given snap tolerance. More...
 
std::unique_ptr< geom::GeometrysnapToSelf (double snapTolerance, bool cleanResult)
 Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of itself with a given snap tolerance and optionally cleaning the result. More...
 

Static Public Member Functions

static void snap (const geom::Geometry &g0, const geom::Geometry &g1, double snapTolerance, geom::GeomPtrPair &ret)
 
static GeomPtr snapToSelf (const geom::Geometry &g0, double snapTolerance, bool cleanResult)
 
static double computeOverlaySnapTolerance (const geom::Geometry &g)
 Estimates the snap tolerance for a Geometry, taking into account its precision model. More...
 
static double computeSizeBasedSnapTolerance (const geom::Geometry &g)
 
static double computeOverlaySnapTolerance (const geom::Geometry &g1, const geom::Geometry &g2)
 Computes the snap tolerance based on input geometries;.
 

Detailed Description

Snaps the vertices and segments of a geom::Geometry to another Geometry's vertices.

Where possible, this operation tries to avoid creating invalid geometries; however, it does not guarantee that output geometries will be valid. It is the responsibility of the caller to check for and handle invalid geometries.

Because too much snapping can result in invalid topology being created, heuristics are used to determine the number and location of snapped vertices that are likely safe to snap. These heuristics may omit some potential snaps that are otherwise within the tolerance.

Constructor & Destructor Documentation

◆ GeometrySnapper()

geos::operation::overlay::snap::GeometrySnapper::GeometrySnapper ( const geom::Geometry g)
inline

Creates a new snapper acting on the given geometry

Parameters
gthe geometry to snap

Member Function Documentation

◆ computeOverlaySnapTolerance()

static double geos::operation::overlay::snap::GeometrySnapper::computeOverlaySnapTolerance ( const geom::Geometry g)
static

Estimates the snap tolerance for a Geometry, taking into account its precision model.

Parameters
ga Geometry
Returns
the estimated snap tolerance

◆ snap()

static void geos::operation::overlay::snap::GeometrySnapper::snap ( const geom::Geometry g0,
const geom::Geometry g1,
double  snapTolerance,
geom::GeomPtrPair &  ret 
)
static

Snaps two geometries together with a given tolerance.

Parameters
g0a geometry to snap
g1a geometry to snap
snapTolerancethe tolerance to use
retthe snapped geometries as a pair of smart pointers (output parameter)

◆ snapTo()

std::unique_ptr<geom::Geometry> geos::operation::overlay::snap::GeometrySnapper::snapTo ( const geom::Geometry g,
double  snapTolerance 
)

Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of the given snap geometry with a given snap tolerance.

Parameters
ga geometry to snap the source to
snapTolerance
Returns
a new snapped Geometry

◆ snapToSelf()

std::unique_ptr<geom::Geometry> geos::operation::overlay::snap::GeometrySnapper::snapToSelf ( double  snapTolerance,
bool  cleanResult 
)

Snaps the vertices in the component geom::LineStrings of the source geometry to the vertices of itself with a given snap tolerance and optionally cleaning the result.

Parameters
snapTolerance
cleanResultclean the result
Returns
a new snapped Geometry

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