QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
QgsMapToPixelSimplifier Class Reference

Implementation of GeometrySimplifier using the "MapToPixel" algorithm. More...

#include <qgsmaptopixelgeometrysimplifier.h>

Inheritance diagram for QgsMapToPixelSimplifier:
Inheritance graph
[legend]

Public Types

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

Public Member Functions

 QgsMapToPixelSimplifier (int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm=Distance)
 Constructor. More...
 
virtual ~QgsMapToPixelSimplifier ()
 
bool isGeneralizableByMapBoundingBox (const QgsRectangle &envelope) const
 Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context. More...
 
void setSimplifyAlgorithm (SimplifyAlgorithm simplifyAlgorithm)
 Sets the local simplification algorithm of the vector layer managed. More...
 
void setSimplifyFlags (int simplifyFlags)
 Sets the simplification hints of the vector layer managed. More...
 
virtual QgsGeometrysimplify (QgsGeometry *geometry) const override
 Returns a simplified version the specified geometry. More...
 
SimplifyAlgorithm simplifyAlgorithm () const
 Gets the local simplification algorithm of the vector layer managed. More...
 
int simplifyFlags () const
 Gets the simplification hints of the vector layer managed. More...
 
virtual bool simplifyGeometry (QgsGeometry *geometry) const override
 Simplifies the specified geometry. More...
 
virtual bool simplifyPoints (QgsWKBTypes::Type wkbType, QgsConstWkbPtr &sourceWkbPtr, QPolygonF &targetPoints) const
 Simplifies the specified WKB-point array. More...
 
- Public Member Functions inherited from QgsAbstractGeometrySimplifier
virtual ~QgsAbstractGeometrySimplifier ()
 

Static Public Member Functions

static bool isGeneralizableByMapBoundingBox (const QgsRectangle &envelope, double map2pixelTol)
 Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context. More...
 
static bool simplifyGeometry (QgsGeometry *geometry, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm=Distance)
 Simplifies the geometry when is applied the specified map2pixel context. More...
 
static bool simplifyPoints (QgsWKBTypes::Type wkbType, QgsConstWkbPtr &sourceWkbPtr, QPolygonF &targetPoints, int simplifyFlags, double tolerance, SimplifyAlgorithm simplifyAlgorithm=Distance)
 Simplifies the WKB-point array when is applied the specified map2pixel context. More...
 
- Static Public Member Functions inherited from QgsAbstractGeometrySimplifier
static bool isGeneralizableByDeviceBoundingBox (const QgsRectangle &envelope, float mapToPixelTol=1.0f)
 Returns whether the device-envelope can be replaced by its BBOX when is applied the specified tolerance. More...
 
static bool isGeneralizableByDeviceBoundingBox (const QVector< QPointF > &points, float mapToPixelTol=1.0f)
 Returns whether the device-geometry can be replaced by its BBOX when is applied the specified tolerance. More...
 

Static Protected Member Functions

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

Protected Attributes

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

Detailed Description

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.

Definition at line 32 of file qgsmaptopixelgeometrysimplifier.h.

Member Enumeration Documentation

◆ SimplifyAlgorithm

Types of simplification algorithms that can be used.

Enumerator
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.

Definition at line 36 of file qgsmaptopixelgeometrysimplifier.h.

◆ SimplifyFlag

Applicable simplification flags.

Enumerator
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.

Definition at line 48 of file qgsmaptopixelgeometrysimplifier.h.

Constructor & Destructor Documentation

◆ QgsMapToPixelSimplifier()

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

Constructor.

Definition at line 24 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ ~QgsMapToPixelSimplifier()

QgsMapToPixelSimplifier::~QgsMapToPixelSimplifier ( )
virtual

Definition at line 31 of file qgsmaptopixelgeometrysimplifier.cpp.

Member Function Documentation

◆ calculateLengthSquared2D()

float QgsMapToPixelSimplifier::calculateLengthSquared2D ( double  x1,
double  y1,
double  x2,
double  y2 
)
staticprotected

Returns the squared 2D-distance of the vector defined by the two points specified.

Definition at line 39 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ equalSnapToGrid()

bool QgsMapToPixelSimplifier::equalSnapToGrid ( double  x1,
double  y1,
double  x2,
double  y2,
double  gridOriginX,
double  gridOriginY,
float  gridInverseSizeXY 
)
staticprotected

Returns whether the points belong to the same grid.

Definition at line 48 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ isGeneralizableByMapBoundingBox() [1/2]

bool QgsMapToPixelSimplifier::isGeneralizableByMapBoundingBox ( const QgsRectangle envelope,
double  map2pixelTol 
)
static

Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context.

Definition at line 471 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ isGeneralizableByMapBoundingBox() [2/2]

bool QgsMapToPixelSimplifier::isGeneralizableByMapBoundingBox ( const QgsRectangle envelope) const
inline

Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context.

Definition at line 101 of file qgsmaptopixelgeometrysimplifier.h.

◆ setSimplifyAlgorithm()

void QgsMapToPixelSimplifier::setSimplifyAlgorithm ( SimplifyAlgorithm  simplifyAlgorithm)
inline

Sets the local simplification algorithm of the vector layer managed.

Definition at line 84 of file qgsmaptopixelgeometrysimplifier.h.

◆ setSimplifyFlags()

void QgsMapToPixelSimplifier::setSimplifyFlags ( int  simplifyFlags)
inline

Sets the simplification hints of the vector layer managed.

Definition at line 79 of file qgsmaptopixelgeometrysimplifier.h.

◆ simplify()

QgsGeometry * QgsMapToPixelSimplifier::simplify ( QgsGeometry geometry) const
overridevirtual

Returns a simplified version the specified geometry.

Returns a simplified version the specified geometry (Removing duplicated points) when is applied the specified map2pixel context.

Implements QgsAbstractGeometrySimplifier.

Definition at line 478 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ simplifyAlgorithm()

SimplifyAlgorithm QgsMapToPixelSimplifier::simplifyAlgorithm ( ) const
inline

Gets the local simplification algorithm of the vector layer managed.

Definition at line 82 of file qgsmaptopixelgeometrysimplifier.h.

◆ simplifyFlags()

int QgsMapToPixelSimplifier::simplifyFlags ( ) const
inline

Gets the simplification hints of the vector layer managed.

Definition at line 77 of file qgsmaptopixelgeometrysimplifier.h.

◆ simplifyGeometry() [1/2]

bool QgsMapToPixelSimplifier::simplifyGeometry ( QgsGeometry geometry) const
overridevirtual

Simplifies the specified geometry.

Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context.

Implements QgsAbstractGeometrySimplifier.

Definition at line 531 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ simplifyGeometry() [2/2]

bool QgsMapToPixelSimplifier::simplifyGeometry ( QgsGeometry geometry,
int  simplifyFlags,
double  tolerance,
SimplifyAlgorithm  simplifyAlgorithm = Distance 
)
static

Simplifies the geometry when is applied the specified map2pixel context.

Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context.

Definition at line 492 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ simplifyPoints() [1/2]

bool QgsMapToPixelSimplifier::simplifyPoints ( QgsWKBTypes::Type  wkbType,
QgsConstWkbPtr sourceWkbPtr,
QPolygonF targetPoints 
) const
virtual

Simplifies the specified WKB-point array.

Definition at line 589 of file qgsmaptopixelgeometrysimplifier.cpp.

◆ simplifyPoints() [2/2]

bool QgsMapToPixelSimplifier::simplifyPoints ( QgsWKBTypes::Type  wkbType,
QgsConstWkbPtr sourceWkbPtr,
QPolygonF targetPoints,
int  simplifyFlags,
double  tolerance,
SimplifyAlgorithm  simplifyAlgorithm = Distance 
)
static

Simplifies the WKB-point array when is applied the specified map2pixel context.

Simplifies the WKB-point array (Removing duplicated points) when is applied the specified map2pixel context.

Simplify the WKB-geometry using the specified tolerance

Definition at line 537 of file qgsmaptopixelgeometrysimplifier.cpp.

Member Data Documentation

◆ mSimplifyAlgorithm

SimplifyAlgorithm QgsMapToPixelSimplifier::mSimplifyAlgorithm
protected

Current algorithm.

Definition at line 64 of file qgsmaptopixelgeometrysimplifier.h.

◆ mSimplifyFlags

int QgsMapToPixelSimplifier::mSimplifyFlags
protected

Current simplification flags.

Definition at line 61 of file qgsmaptopixelgeometrysimplifier.h.

◆ mTolerance

double QgsMapToPixelSimplifier::mTolerance
protected

Distance tolerance for the simplification.

Definition at line 67 of file qgsmaptopixelgeometrysimplifier.h.


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