QGIS API Documentation 3.41.0-Master (3291e9ff48b)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsNominatimGeocoder Class Reference

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

#include <qgsnominatimgeocoder.h>

Inheritance diagram for QgsNominatimGeocoder:
Inheritance graph
[legend]

Public Member Functions

 QgsNominatimGeocoder (const QString &countryCodes=QString(), const QString &endpoint=QString())
 Constructor for QgsNominatimGeocoder.
 
QgsFields appendedFields () const override
 Returns a set of newly created fields which will be appended to existing features during the geocode operation.
 
QString countryCodes () const
 Returns the optional region bias which will be used to prioritize results in a certain region.
 
QString endpoint () const
 Returns the API endpoint used for requests.
 
Flags flags () const override
 Returns the geocoder's capability flags.
 
QList< QgsGeocoderResultgeocodeString (const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const override
 Geocodes a string.
 
QgsGeocoderResult jsonToResult (const QVariantMap &json) const
 Converts a JSON result returned from the Nominatim service to a geocoder result object.
 
double requestsPerSecond () const
 Returns the number of requests per seconds to the endpoint.
 
QUrl requestUrl (const QString &address, const QgsRectangle &bounds=QgsRectangle()) const
 Returns the URL generated for geocoding the specified address.
 
void setCountryCodes (const QString &countryCodes)
 Sets the optional region bias which will be used to prioritize results in a certain region.
 
void setEndpoint (const QString &endpoint)
 Sets a specific API endpoint to use for requests.
 
void setRequestsPerSecond (double number)
 Sets the number of request per seconds to the endpoint.
 
Qgis::WkbType wkbType () const override
 Returns the WKB type of geometries returned by the geocoder.
 
- Public Member Functions inherited from QgsGeocoderInterface
virtual ~QgsGeocoderInterface ()=default
 
virtual QList< QgsGeocoderResultgeocodeFeature (const QgsFeature &feature, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const
 Geocodes a feature.
 

Additional Inherited Members

- Public Types inherited from QgsGeocoderInterface
enum class  Flag { GeocodesStrings = 1 << 0 , GeocodesFeatures = 1 << 1 }
 Capability flags for the geocoder. More...
 
typedef QFlags< FlagFlags
 

Detailed Description

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.
Since
QGIS 3.18

Definition at line 36 of file qgsnominatimgeocoder.h.

Constructor & Destructor Documentation

◆ QgsNominatimGeocoder()

QgsNominatimGeocoder::QgsNominatimGeocoder ( const QString &  countryCodes = QString(),
const QString &  endpoint = QString() 
)

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.

Definition at line 36 of file qgsnominatimgeocoder.cpp.

Member Function Documentation

◆ appendedFields()

QgsFields QgsNominatimGeocoder::appendedFields ( ) const
overridevirtual

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.

Reimplemented from QgsGeocoderInterface.

Definition at line 50 of file qgsnominatimgeocoder.cpp.

◆ countryCodes()

QString QgsNominatimGeocoder::countryCodes ( ) const

Returns the optional region bias which will be used to prioritize results in a certain region.

See also
setCountryCodes()

Definition at line 240 of file qgsnominatimgeocoder.cpp.

◆ endpoint()

QString QgsNominatimGeocoder::endpoint ( ) const

Returns the API endpoint used for requests.

See also
setEndpoint()

Definition at line 230 of file qgsnominatimgeocoder.cpp.

◆ flags()

QgsGeocoderInterface::Flags QgsNominatimGeocoder::flags ( ) const
overridevirtual

Returns the geocoder's capability flags.

Implements QgsGeocoderInterface.

Definition at line 45 of file qgsnominatimgeocoder.cpp.

◆ geocodeString()

QList< QgsGeocoderResult > QgsNominatimGeocoder::geocodeString ( const QString &  string,
const QgsGeocoderContext context,
QgsFeedback feedback = nullptr 
) const
overridevirtual

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.

Reimplemented from QgsGeocoderInterface.

Definition at line 74 of file qgsnominatimgeocoder.cpp.

◆ jsonToResult()

QgsGeocoderResult QgsNominatimGeocoder::jsonToResult ( const QVariantMap &  json) const

Converts a JSON result returned from the Nominatim service to a geocoder result object.

Definition at line 168 of file qgsnominatimgeocoder.cpp.

◆ requestsPerSecond()

double QgsNominatimGeocoder::requestsPerSecond ( ) const
inline

Returns the number of requests per seconds to the endpoint.

See also
setRequestsPerSecond()

Definition at line 85 of file qgsnominatimgeocoder.h.

◆ requestUrl()

QUrl QgsNominatimGeocoder::requestUrl ( const QString &  address,
const QgsRectangle bounds = QgsRectangle() 
) const

Returns the URL generated for geocoding the specified address.

Definition at line 148 of file qgsnominatimgeocoder.cpp.

◆ setCountryCodes()

void QgsNominatimGeocoder::setCountryCodes ( const QString &  countryCodes)

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
countryCodes()

Definition at line 245 of file qgsnominatimgeocoder.cpp.

◆ setEndpoint()

void QgsNominatimGeocoder::setEndpoint ( const QString &  endpoint)

Sets a specific API endpoint to use for requests.

This is for internal testing purposes only.

See also
endpoint()

Definition at line 235 of file qgsnominatimgeocoder.cpp.

◆ setRequestsPerSecond()

void QgsNominatimGeocoder::setRequestsPerSecond ( double  number)
inline

Sets the number of request per seconds to the endpoint.

See also
requestsPerSecond()
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.

Definition at line 93 of file qgsnominatimgeocoder.h.

◆ wkbType()

Qgis::WkbType QgsNominatimGeocoder::wkbType ( ) const
overridevirtual

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).

Reimplemented from QgsGeocoderInterface.

Definition at line 69 of file qgsnominatimgeocoder.cpp.


The documentation for this class was generated from the following files: