QgsMapToPixelSimplifier class

Implementation of GeometrySimplifier using the "MapToPixel" algorithm.

Simplifies a geometry removing points within of the maximum distance difference that defines the MapToPixel info of a RenderContext request. This class enables simplify the geometries to be rendered in a MapCanvas target to speed up the vector drawing.

Base classes

class QgsAbstractGeometrySimplifier
Abstract base class for simplify geometries using a specific algorithm.

Public types

enum SimplifyAlgorithm { Distance = 0, SnapToGrid = 1, Visvalingam = 2 }
Types of simplification algorithms that can be used.
enum SimplifyFlag { NoFlags = 0, SimplifyGeometry = 1, SimplifyEnvelope = 2 }
Applicable simplification flags.

Public static functions

static auto isGeneralizableByMapBoundingBox(const QgsRectangle& envelope, double map2pixelTol) -> bool
Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context.

Constructors, destructors, conversion operators

QgsMapToPixelSimplifier(int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm = Distance)
Constructor.

Public functions

auto isGeneralizableByMapBoundingBox(const QgsRectangle& envelope) const -> bool
Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context.
void setSimplifyAlgorithm(SimplifyAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
void setSimplifyFlags(int simplifyFlags)
Sets the simplification hints of the vector layer managed.
void setTolerance(double value)
Sets the tolerance of the vector layer managed.
auto simplify(const QgsGeometry& geometry) const -> QgsGeometry override
Returns a simplified version the specified geometry.
auto simplifyAlgorithm() const -> SimplifyAlgorithm
Gets the local simplification algorithm of the vector layer managed.
auto simplifyFlags() const -> int
Gets the simplification hints of the vector layer managed.

Protected static functions

static auto calculateLengthSquared2D(double x1, double y1, double x2, double y2) -> float
Returns the squared 2D-distance of the vector defined by the two points specified.
static auto equalSnapToGrid(double x1, double y1, double x2, double y2, double gridOriginX, double gridOriginY, float gridInverseSizeXY) -> bool
Returns whether the points belong to the same grid.

Protected variables

SimplifyAlgorithm mSimplifyAlgorithm
Current algorithm.
int mSimplifyFlags
Current simplification flags.
double mTolerance
Distance tolerance for the simplification.

Enum documentation

enum QgsMapToPixelSimplifier::SimplifyAlgorithm

Types of simplification algorithms that can be used.

Enumerators
Distance

The simplification uses the distance between points to remove duplicate points.

SnapToGrid

The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points.

Visvalingam

The simplification gives each point in a line an importance weighting, so that least important points are removed first.

enum QgsMapToPixelSimplifier::SimplifyFlag

Applicable simplification flags.

Enumerators
NoFlags

No simplification can be applied.

SimplifyGeometry

The geometries can be simplified using the current map2pixel context state.

SimplifyEnvelope

The geometries can be fully simplified by its BoundingBox.