Class: QgsTolerance

Provides calculations for tolerance values in map units.

Enums

UnitType

alias of MapToolUnit

Static Methods

defaultTolerance

Static function to get default tolerance value for a layer.

toleranceInMapUnits

Static function to translate tolerance value into layer units

toleranceInProjectUnits

Static function to translate tolerance value into map units

vertexSearchRadius

Static function to get vertex tolerance value.

class qgis.core.QgsTolerance[source]

Bases: object

UnitType

alias of MapToolUnit

static defaultTolerance(layer: QgsMapLayer | None, mapSettings: QgsMapSettings) float[source]

Static function to get default tolerance value for a layer. The value is read from settings and transformed if necessary.

Return type:

float

Returns:

value of default tolerance in layer units

Parameters:
static toleranceInMapUnits(tolerance: float, layer: QgsMapLayer | None, mapSettings: QgsMapSettings, units: Qgis.MapToolUnit = Qgis.MapToolUnit.Layer) float[source]

Static function to translate tolerance value into layer units

Parameters:
  • tolerance (float) – tolerance value to be translated

  • layer (Optional[QgsMapLayer]) – reference layer

  • mapSettings (QgsMapSettings) – settings of the map

  • units (Qgis.MapToolUnit = Qgis.MapToolUnit.Layer) – type of units to be translated

Return type:

float

Returns:

value of tolerance in layer units

static toleranceInProjectUnits(tolerance: float, layer: QgsMapLayer | None, mapSettings: QgsMapSettings, units: Qgis.MapToolUnit) float[source]

Static function to translate tolerance value into map units

Parameters:
  • tolerance (float) – tolerance value to be translated

  • layer (Optional[QgsMapLayer]) – source layer necessary in case tolerance is in layer units

  • mapSettings (QgsMapSettings) – settings of the map

  • units (Qgis.MapToolUnit) – type of units to be translated

Return type:

float

Returns:

value of tolerance in map units

static vertexSearchRadius(mapSettings: QgsMapSettings) float[source]

Static function to get vertex tolerance value. The value is read from settings and transformed if necessary.

Return type:

float

Returns:

value of vertex tolerance in map units (not layer units)

Parameters:

mapSettings (QgsMapSettings)

static vertexSearchRadius(layer: QgsMapLayer | None, mapSettings: QgsMapSettings) float[source]

Static function to get vertex tolerance value for a layer. The value is read from settings and transformed if necessary.

Return type:

float

Returns:

value of vertex tolerance in layer units

Parameters: