Class: QgsBatchGeocodeAlgorithm

class qgis.analysis.QgsBatchGeocodeAlgorithm

Bases: QgsProcessingFeatureBasedAlgorithm

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

# create a class which implements the :py:class:`.QgsGeocoderInterface` interface:
class MyGeocoder(:py:class:`.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(:py:class:`.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'

New in version 3.18.

QgsBatchGeocodeAlgorithm(geocoder: QgsGeocoderInterface) 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.

Methods

group

rtype

str

groupId

rtype

str

initParameters

param configuration

inputLayerTypes

rtype

List[int]

outputCrs

param inputCrs

outputFields

param inputFields

outputName

rtype

str

outputWkbType

param inputWkbType

prepareAlgorithm

param parameters

processFeature

param feature

supportInPlaceEdit

param layer

tags

rtype

List[str]

group(self) str
Return type

str

groupId(self) str
Return type

str

initParameters(self, configuration: Dict[str, Any] = {})
Parameters

configuration (Dict[str) –

inputLayerTypes(self) List[int]
Return type

List[int]

outputCrs(self, inputCrs: QgsCoordinateReferenceSystem) QgsCoordinateReferenceSystem
Parameters

inputCrs (QgsCoordinateReferenceSystem) –

Return type

QgsCoordinateReferenceSystem

outputFields(self, inputFields: QgsFields) QgsFields
Parameters

inputFields (QgsFields) –

Return type

QgsFields

outputName(self) str
Return type

str

outputWkbType(self, inputWkbType: QgsWkbTypes.Type) QgsWkbTypes.Type
Parameters

inputWkbType (QgsWkbTypes.Type) –

Return type

QgsWkbTypes.Type

prepareAlgorithm(self, parameters: Dict[str, Any], context: QgsProcessingContext, feedback: QgsProcessingFeedback) bool
Parameters
Return type

bool

processFeature(self, feature: QgsFeature, a1: QgsProcessingContext, feedback: QgsProcessingFeedback) List[QgsFeature]
Parameters
Return type

List[QgsFeature]

supportInPlaceEdit(self, layer: QgsMapLayer) bool
Parameters

layer (QgsMapLayer) –

Return type

bool

tags(self) List[str]
Return type

List[str]