Class: QgsScaleUtils

Contains utility functions for working with map scales.

List of all members, including inherited members

Static Methods

equalToOrGreaterThanMinimumScale

Returns whether the scale is equal to or greater than the minScale, taking non-round numbers into account.

lessThanMaximumScale

Returns whether the scale is less than the maxScale, taking non-round numbers into account.

loadScaleList

Load scales from the given file

saveScaleList

Save scales to the given file

class qgis.core.QgsScaleUtils[source]

Bases: object

static equalToOrGreaterThanMinimumScale(scale: float, minScale: float) bool[source]

Returns whether the scale is equal to or greater than the minScale, taking non-round numbers into account.

Parameters:
  • scale (float) – The current scale to be compared.

  • minScale (float) – The minimum map scale (i.e. most “zoomed out” scale) at which features, labels or diagrams will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

Added in version 3.40.

Return type:

bool

static lessThanMaximumScale(scale: float, maxScale: float) bool[source]

Returns whether the scale is less than the maxScale, taking non-round numbers into account.

Parameters:
  • scale (float) – The current scale to be compared.

  • maxScale (float) – The maximum map scale (i.e. most “zoomed in” scale) at which features, labels or diagrams will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

Added in version 3.40.

Return type:

bool

static loadScaleList(fileName: str | None, scales: Iterable[str | None], errorMessage: str | None) bool[source]

Load scales from the given file

Parameters:
  • fileName (Optional[str]) – the name of the file to process

  • scales (Iterable[Optional[str]]) – it will contain loaded scales

  • errorMessage (Optional[str]) – it will contain the error message if something went wrong

Return type:

bool

Returns:

True on success and False if failed

static saveScaleList(fileName: str | None, scales: Iterable[str | None], errorMessage: str | None) bool[source]

Save scales to the given file

Parameters:
  • fileName (Optional[str]) – the name of the output file

  • scales (Iterable[Optional[str]]) – the list of scales to save

  • errorMessage (Optional[str]) – it will contain the error message if something went wrong

Return type:

bool

Returns:

True on success and False if failed