Class: QgsMapToPixelSimplifier

class qgis.core.QgsMapToPixelSimplifier(simplifyFlags: int, tolerance: float, simplifyAlgorithm: QgsMapToPixelSimplifier.SimplifyAlgorithm = QgsMapToPixelSimplifier.Distance)

Bases: QgsAbstractGeometrySimplifier

Constructor

QgsMapToPixelSimplifier(QgsMapToPixelSimplifier)

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.

Parameters
  • simplifyFlags (int) –

  • tolerance (float) –

  • simplifyAlgorithm

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

Returns a simplified version the specified geometry

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