Class: QgsAbstractProfileGenerator

Abstract base class for objects which generate elevation profiles.

The generation is typically done in a background thread, so it is necessary to keep all structures required for generating the profile away from the original profile source because it may change at any time.

Because the data needs to be copied (to avoid the need for locking), it is highly desirable to use copy-on-write where possible. This way, the overhead of copying (both memory and CPU) will be kept low. Qt containers and various Qt classes use implicit sharing.

The scenario will be:

  • elevation profile job (doing preparation in the GUI thread) calls QgsAbstractProfileSource.createProfileGenerator() and gets an instance of this class. The instance is initialized at that point and should not need additional calls to the source.

  • profile job (still in GUI thread) stores the generator for later use.

  • profile job (in worker thread) calls QgsAbstractProfileGenerator.generateProfile()

  • profile job (again in GUI thread) will check errors() and report them

Added in version 3.26.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: feedback(), generateProfile(), sourceId(), takeResults()

Abstract Methods

feedback

Access to feedback object of the generator (may be None)

generateProfile

Generate the profile (based on data stored in the class).

sourceId

Returns a unique identifier representing the source of the profile.

takeResults

Takes results from the generator.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAbstractProfileGenerator. See the FAQ for more details.

flags

Returns flags which reflect how the profile generator operates.

class qgis.core.QgsAbstractProfileGenerator[source]

Bases: object

abstract feedback(self) QgsFeedback | None[source]

Access to feedback object of the generator (may be None)

Return type:

Optional[QgsFeedback]

virtual flags(self) Qgis.ProfileGeneratorFlags[source]

Returns flags which reflect how the profile generator operates.

Return type:

Qgis.ProfileGeneratorFlags

abstract generateProfile(self, context: QgsProfileGenerationContext = QgsProfileGenerationContext()) bool[source]

Generate the profile (based on data stored in the class).

Returns True if the profile was generated successfully (i.e. the generation was not canceled early).

Parameters:

context (QgsProfileGenerationContext = QgsProfileGenerationContext())

Return type:

bool

abstract sourceId(self) str[source]

Returns a unique identifier representing the source of the profile.

For generators associated with a map layer the source ID will match the layer’s QgsMapLayer.id(). Other (non-map-layer) sources will have a different unique ID with its own custom interpretation.gen

Return type:

str

abstract takeResults(self) QgsAbstractProfileResults | None[source]

Takes results from the generator.

Ownership is transferred to the caller.

Return type:

Optional[QgsAbstractProfileResults]