Class: QgsBatchGeocodeAlgorithm

A base class for batch geocoder algorithms, which takes a QgsGeocoderInterface object and exposes it as a Processing algorithm for batch geocoding operations.

Example

# create a class which implements the QgsGeocoderInterface interface:
class MyGeocoder(QgsGeocoderInterface):

   def geocodeString(self, string, context, feedback):
      # calculate and return results...

my_geocoder = MyGeocoder()

# create an algorithm which allows for batch geocoding operations using the custom geocoder interface
# and implement the few required pure virtual methods
class MyGeocoderAlgorithm(QgsBatchGeocodeAlgorithm):

    def __init__(self):
        super().__init__(my_geocoder)

    def displayName(self):
        return "My Geocoder"

    def name(self):
        return "my_geocoder_alg"

    def createInstance(self):
        return MyGeocoderAlgorithm()

    # optionally, the group(), groupId(), tags(), shortHelpString() and other metadata style methods can be overridden and customized:
    def tags(self):
        return 'geocode,my service,batch'

Added in version 3.18.

Class Hierarchy

Inheritance diagram of qgis.analysis.QgsBatchGeocodeAlgorithm

Base classes

QgsProcessingFeatureBasedAlgorithm

An abstract QgsProcessingAlgorithm base class for processing algorithms which operate “feature-by-feature”.

QgsProcessingAlgorithm

Abstract base class for processing algorithms.

class qgis.analysis.QgsBatchGeocodeAlgorithm[source]

Bases: QgsProcessingFeatureBasedAlgorithm

__init__(geocoder: QgsGeocoderInterface | None)

Constructor for QgsBatchGeocodeAlgorithm.

The geocoder must specify an instance of a class which implements the QgsGeocoderInterface interface. Ownership of geocoder is not transferred, and the caller must ensure that geocoder exists for the lifetime of this algorithm.

Parameters:

geocoder (Optional[QgsGeocoderInterface])