GEOS 3.14.0dev
Public Member Functions | Static Public Member Functions | List of all members
geos::precision::GeometryPrecisionReducer Class Reference

Reduces the precision of a geom::Geometry according to the supplied geom::PrecisionModel, ensuring that the result is valid (unless specified otherwise). More...

#include <GeometryPrecisionReducer.h>

Public Member Functions

 GeometryPrecisionReducer (const geom::PrecisionModel &pm)
 
 GeometryPrecisionReducer (const geom::GeometryFactory &changeFactory)
 Create a reducer that will change the precision model of the new reduced Geometry.
 
void setRemoveCollapsedComponents (bool remove)
 
void setChangePrecisionModel (bool change)
 Sets whether the geom::PrecisionModel of the new reduced Geometry will be changed to be the geom::PrecisionModel supplied to specify the precision reduction. The default is to not change the precision model.
 
void setUseAreaReducer (bool useAR)
 
void setPointwise (bool pointwise)
 Sets whether the precision reduction will be done in pointwise fashion only.
 
std::unique_ptr< geom::Geometryreduce (const geom::Geometry &geom)
 

Static Public Member Functions

static std::unique_ptr< geom::Geometryreduce (const geom::Geometry &g, const geom::PrecisionModel &precModel)
 
static std::unique_ptr< geom::GeometryreducePointwise (const geom::Geometry &g, const geom::PrecisionModel &precModel)
 
static std::unique_ptr< geom::GeometryreduceKeepCollapsed (const geom::Geometry &g, const geom::PrecisionModel &precModel)
 

Detailed Description

Reduces the precision of a geom::Geometry according to the supplied geom::PrecisionModel, ensuring that the result is valid (unless specified otherwise).

By default the reduced result is topologically valid To ensure this a polygonal geometry is reduced in a topologically valid fashion (technically, by using snap-rounding). It can be forced to be reduced pointwise by using setPointwise(boolean). Note that in this case the result geometry may be invalid. Linear and point geometry is always reduced pointwise (i.e. without further change to its topology or structure), since this does not change validity.

By default the geometry precision model is not changed. This can be overridden by usingsetChangePrecisionModel(boolean).

Normally collapsed components (e.g. lines collapsing to a point) are not included in the result. This behavior can be changed by using setRemoveCollapsedComponents(boolean).

Constructor & Destructor Documentation

◆ GeometryPrecisionReducer()

geos::precision::GeometryPrecisionReducer::GeometryPrecisionReducer ( const geom::GeometryFactory changeFactory)
inline

Create a reducer that will change the precision model of the new reduced Geometry.

Parameters
changeFactorythe factory for the created Geometry. Its PrecisionModel will be used for the reduction. NOTE: ownership left to caller must be kept alive for the whole lifetime of the returned Geometry.

Member Function Documentation

◆ reduce()

static std::unique_ptr< geom::Geometry > geos::precision::GeometryPrecisionReducer::reduce ( const geom::Geometry g,
const geom::PrecisionModel precModel 
)
static

Convenience method for doing precision reduction on a single geometry, with collapses removed and keeping the geometry precision model the same, and preserving polygonal topology.

Parameters
gthe geometry to reduce
precModelthe precision model to use
Returns
the reduced geometry

◆ setChangePrecisionModel()

void geos::precision::GeometryPrecisionReducer::setChangePrecisionModel ( bool  change)
inline

Sets whether the geom::PrecisionModel of the new reduced Geometry will be changed to be the geom::PrecisionModel supplied to specify the precision reduction. The default is to not change the precision model.

Parameters
changeif true the precision model of the created Geometry will be the the precisionModel supplied in the constructor.

◆ setPointwise()

void geos::precision::GeometryPrecisionReducer::setPointwise ( bool  pointwise)
inline

Sets whether the precision reduction will be done in pointwise fashion only.

Pointwise precision reduction reduces the precision of the individual coordinates only, but does not attempt to recreate valid topology. This is only relevant for geometries containing polygonal components.

Parameters
pointwiseif reduction should be done pointwise only

◆ setRemoveCollapsedComponents()

void geos::precision::GeometryPrecisionReducer::setRemoveCollapsedComponents ( bool  remove)
inline

Sets whether the reduction will result in collapsed components being removed completely, or simply being collapsed to an (invalid) Geometry of the same type.

Parameters
removeif true collapsed components will be removed

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