Class: QgsMapToPixelSimplifier

class qgis.core.QgsMapToPixelSimplifier

Bases: QgsAbstractGeometrySimplifier

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.

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

QgsMapToPixelSimplifier(QgsMapToPixelSimplifier)

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

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

simplify

simplify(self, geometry: QgsAbstractGeometry) -> QgsAbstractGeometry

simplifyAlgorithm

Gets the local simplification algorithm of the vector layer managed

simplifyFlags

Gets the simplification hints of the vector layer managed

Attributes

Distance

NoFlags

SimplifyEnvelope

SimplifyGeometry

SnapToGrid

SnappedToGridGlobal

Visvalingam

Distance = 0
NoFlags = 0
class SimplifyAlgorithm

Bases: int

SimplifyEnvelope = 2
class SimplifyFlag

Bases: int

SimplifyGeometry = 1
SnapToGrid = 1
SnappedToGridGlobal = 3
Visvalingam = 2
calculateLengthSquared2D(x1: float, y1: float, x2: float, y2: float)float

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

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

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

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

isGeneralizableByMapBoundingBox(self, envelope: QgsRectangle) -> bool Returns whether the envelope can be replaced by its BBOX when is applied the specified map2pixel context

Parameters
Return type

bool

setSimplifyAlgorithm(self, simplifyAlgorithm: QgsMapToPixelSimplifier.SimplifyAlgorithm)

Sets the local simplification algorithm of the vector layer managed

Parameters

simplifyAlgorithm (QgsMapToPixelSimplifier.SimplifyAlgorithm) –

setSimplifyFlags(self, simplifyFlags: int)

Sets the simplification hints of the vector layer managed

Parameters

simplifyFlags (int) –

setTolerance(self, value: float)

Sets the tolerance of the vector layer managed

Parameters

value (float) –

simplify(self, geometry: QgsGeometry)QgsGeometry

simplify(self, geometry: QgsAbstractGeometry) -> QgsAbstractGeometry

Parameters

geometry (QgsGeometry) –

Return type

QgsGeometry

simplifyAlgorithm(self)QgsMapToPixelSimplifier.SimplifyAlgorithm

Gets the local simplification algorithm of the vector layer managed

Return type

QgsMapToPixelSimplifier.SimplifyAlgorithm

simplifyFlags(self)int

Gets the simplification hints of the vector layer managed

Return type

int