Class: QgsMapToPixelSimplifier

Implementation of a geometry simplifier 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.

Class Hierarchy

Inheritance diagram of qgis.core.QgsMapToPixelSimplifier

Base classes

QgsAbstractGeometrySimplifier

Abstract base class for simplifying geometries using a specific algorithm.

Methods

isGeneralizableByMapBoundingBox

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

setSimplifyAlgorithm

Sets the local simplification algorithm of the vector layer managed

setSimplifyFlags

Sets the simplification hints of the vector layer managed

setTolerance

Sets the tolerance of the vector layer managed

simplifyAlgorithm

Gets the local simplification algorithm of the vector layer managed

simplifyFlags

Gets the simplification hints of the vector layer managed

Static Methods

calculateLengthSquared2D

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

equalSnapToGrid

Returns whether the points belong to the same grid

Attributes

NoFlags

SimplifyEnvelope

SimplifyGeometry

class qgis.core.QgsMapToPixelSimplifier[source]

Bases: QgsAbstractGeometrySimplifier

__init__(simplifyFlags: int, tolerance: float, simplifyAlgorithm: Qgis.VectorSimplificationAlgorithm = Qgis.VectorSimplificationAlgorithm.Distance)

Constructor

Parameters:
  • simplifyFlags (int)

  • tolerance (float)

  • simplifyAlgorithm (Qgis.VectorSimplificationAlgorithm = Qgis.VectorSimplificationAlgorithm.Distance)

__init__(a0: QgsMapToPixelSimplifier)
Parameters:

a0 (QgsMapToPixelSimplifier)

NoFlags = 0
SimplifyEnvelope = 2
class SimplifyFlag

Bases: int

SimplifyGeometry = 1
static calculateLengthSquared2D(x1: float, y1: float, x2: float, y2: float) float[source]

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

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

Return type:

float

static equalSnapToGrid(x1: float, y1: float, x2: float, y2: float, gridOriginX: float, gridOriginY: float, gridInverseSizeXY: float) bool[source]

Returns whether the points belong to the same grid

Parameters:
  • x1 (float)

  • y1 (float)

  • x2 (float)

  • y2 (float)

  • gridOriginX (float)

  • gridOriginY (float)

  • gridInverseSizeXY (float)

Return type:

bool

isGeneralizableByMapBoundingBox(envelope: QgsRectangle, map2pixelTol: float) bool[source]

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

Parameters:
Return type:

bool

isGeneralizableByMapBoundingBox(self, envelope: QgsRectangle) bool[source]

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

Parameters:

envelope (QgsRectangle)

Return type:

bool

setSimplifyAlgorithm(self, simplifyAlgorithm: Qgis.VectorSimplificationAlgorithm)[source]

Sets the local simplification algorithm of the vector layer managed

Parameters:

simplifyAlgorithm (Qgis.VectorSimplificationAlgorithm)

setSimplifyFlags(self, simplifyFlags: int)[source]

Sets the simplification hints of the vector layer managed

Parameters:

simplifyFlags (int)

setTolerance(self, value: float)[source]

Sets the tolerance of the vector layer managed

Parameters:

value (float)

simplifyAlgorithm(self) Qgis.VectorSimplificationAlgorithm[source]

Gets the local simplification algorithm of the vector layer managed

Return type:

Qgis.VectorSimplificationAlgorithm

simplifyFlags(self) int[source]

Gets the simplification hints of the vector layer managed

Return type:

int