Class: QgsGeocoderInterface

Interface for geocoders.

QgsGeocoderInterface implementations are able to take either a QgsFeature or a free-form string and calculate the corresponding geometry of the feature.

Added in version 3.18.

Class Hierarchy

Inheritance diagram of qgis.core.QgsGeocoderInterface

Subclasses

QgsGoogleMapsGeocoder

A geocoder which uses the Google Map geocoding API to retrieve results.

QgsNominatimGeocoder

A geocoder which uses the Nominatim geocoding API to retrieve results.

Enums

Flag

Capability flags for the geocoder.

Methods

appendedFields

Returns a set of newly created fields which will be appended to existing features during the geocode operation.

flags

Returns the geocoder's capability flags.

geocodeFeature

Geocodes a feature.

geocodeString

Geocodes a string.

wkbType

Returns the WKB type of geometries returned by the geocoder.

class qgis.core.QgsGeocoderInterface[source]

Bases: object

class Flag(*values)

Bases: IntEnum

Capability flags for the geocoder.

  • GeocodesStrings: Can geocode string input values

  • GeocodesFeatures: Can geocode QgsFeature input values

GeocodesFeatures = 2
GeocodesStrings = 1
class Flags
class Flags(f: QgsGeocoderInterface.Flags | QgsGeocoderInterface.Flag)
class Flags(a0: QgsGeocoderInterface.Flags)

Bases: object

appendedFields(self) QgsFields[source]

Returns a set of newly created fields which will be appended to existing features during the geocode operation.

These fields will include any extra content returned by the geocoder, such as fields for accuracy of the match or correct attribute values.

Return type:

QgsFields

flags(self) QgsGeocoderInterface.Flags[source]

Returns the geocoder’s capability flags.

Return type:

QgsGeocoderInterface.Flags

geocodeFeature(self, feature: QgsFeature, context: QgsGeocoderContext, feedback: QgsFeedback | None = None) List[QgsGeocoderResult]

Geocodes a feature.

If implemented by the geocoder (i.e. flags() returns the QgsGeocoderInterface.Flag.GeocodesFeatures flag), a list of matching results will be returned.

The optional feedback argument can be used to provider cancellation support.

Parameters:
Return type:

List[QgsGeocoderResult]

geocodeString(self, string: str | None, context: QgsGeocoderContext, feedback: QgsFeedback | None = None) List[QgsGeocoderResult]

Geocodes a string.

If implemented by the geocoder (i.e. flags() returns the QgsGeocoderInterface.Flag.GeocodesStrings flag), a list of matching results will be returned.

The optional feedback argument can be used to provider cancellation support.

Parameters:
Return type:

List[QgsGeocoderResult]

wkbType(self) Qgis.WkbType[source]

Returns the WKB type of geometries returned by the geocoder.

If this is not known in advance then QgsWkbTypes.Unknown should be returned (e.g. in the case that a geocoder may return different geometry types depending on the quality of the match).

Return type:

Qgis.WkbType