Class: QgsNominatimGeocoder¶
- class qgis.core.QgsNominatimGeocoder¶
Bases:
QgsGeocoderInterface
A geocoder which uses the Nominatim geocoding API to retrieve results.
This geocoder utilizes the Nominatim geocoding API in order to geocode strings.
Warning
The user is responsible for respecting the usage policy when using the default OpenStreetMap-run server.
New in version 3.18.
QgsNominatimGeocoder(countryCodes: str = ‘’, endpoint: str = ‘’) Constructor for QgsNominatimGeocoder.
Optionally,
countryCodes
can be specified to restrict results to one or more countries. The codes must be in ISO 3166-1alpha2 code and comma-separated.The optional
endpoint
argument can be used to specify a non-default endpoint to use for request.QgsNominatimGeocoder(
QgsNominatimGeocoder
)Methods
- rtype:
QgsFields
Returns the optional region bias which will be used to prioritize results in a certain region.
Returns the API endpoint used for requests.
- rtype:
QgsGeocoderInterface.Flags
- param string:
Converts a JSON result returned from the Nominatim service to a geocoder result object.
Returns the URL generated for geocoding the specified
address
.Returns the number of requests per seconds to the endpoint.
Sets the optional
region
bias which will be used to prioritize results in a certain region.Sets a specific API
endpoint
to use for requests.Sets the
number
of request per seconds to the endpoint.- rtype:
QgsWkbTypes.Type
- countryCodes(self) str ¶
Returns the optional region bias which will be used to prioritize results in a certain region.
See also
- Return type:
str
- endpoint(self) str ¶
Returns the API endpoint used for requests.
See also
- Return type:
str
- flags(self) QgsGeocoderInterface.Flags ¶
- Return type:
- geocodeString(self, string: str, context: QgsGeocoderContext, feedback: QgsFeedback = None) List[QgsGeocoderResult] ¶
- Parameters:
string (str) –
context (QgsGeocoderContext) –
feedback (
QgsFeedback
= None) –
- Return type:
List[QgsGeocoderResult]
- jsonToResult(self, json: Dict[str, Any]) QgsGeocoderResult ¶
Converts a JSON result returned from the Nominatim service to a geocoder result object.
- Parameters:
json (Dict[str) –
- Return type:
- requestUrl(self, address: str, bounds: QgsRectangle = QgsRectangle()) QUrl ¶
Returns the URL generated for geocoding the specified
address
.- Parameters:
address (str) –
bounds (
QgsRectangle
= QgsRectangle()) –
- Return type:
QUrl
- requestsPerSecond(self) float ¶
Returns the number of requests per seconds to the endpoint.
See also
- Return type:
float
- setCountryCodes(self, countryCodes: str)¶
Sets the optional
region
bias which will be used to prioritize results in a certain region.The
region
argument must be set to a two letter country code top-level domain value, e.g. “gb” for Great Britain.See also
- Parameters:
countryCodes (str) –
- setEndpoint(self, endpoint: str)¶
Sets a specific API
endpoint
to use for requests. This is for internal testing purposes only.See also
- Parameters:
endpoint (str) –
- setRequestsPerSecond(self, number: float)¶
Sets the
number
of request per seconds to the endpoint.See also
Warning
Setting this to a value > 1 violates the nomatim terms of service. Only change this value if you are using a self-hosted nomatim service.
- Parameters:
number (float) –
- wkbType(self) QgsWkbTypes.Type ¶
- Return type: