QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsnominatimgeocoder.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnominatimgeocoder.h
3  ---------------
4  Date : December 2020
5  Copyright : (C) 2020 by Mathieu Pellerin
6  Email : nirvn dot asia at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSNOMINATIMGEOCODER_H
17 #define QGSNOMINATIMGEOCODER_H
18 
19 #include "qgis_core.h"
20 #include "qgsgeocoder.h"
21 
22 #include <QMutex>
23 
36 class CORE_EXPORT QgsNominatimGeocoder : public QgsGeocoderInterface
37 {
38 
39  public:
40 
49  QgsNominatimGeocoder( const QString &countryCodes = QString(), const QString &endpoint = QString() );
50 
51  Flags flags() const override;
52  QgsFields appendedFields() const override;
53  QgsWkbTypes::Type wkbType() const override;
54  QList< QgsGeocoderResult > geocodeString( const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback = nullptr ) const override;
55 
59  QUrl requestUrl( const QString &address, const QgsRectangle &bounds = QgsRectangle() ) const;
60 
64  QgsGeocoderResult jsonToResult( const QVariantMap &json ) const;
65 
71  QString endpoint() const;
72 
78  void setEndpoint( const QString &endpoint );
79 
85  double requestsPerSecond() const { return mRequestsPerSecond; }
86 
93  void setRequestsPerSecond( double number ) { mRequestsPerSecond = number; }
94 
100  QString countryCodes() const;
101 
110  void setCountryCodes( const QString &countryCodes );
111 
112  private:
113 
114  QString mCountryCodes;
115  QString mEndpoint;
116  double mRequestsPerSecond = 1;
117 
118  static QMutex sMutex;
119 
120  static qint64 sLastRequestTimestamp;
121 
122 };
123 
124 #endif // QGSNOMINATIMGEOCODER_H
qgsgeocoder.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsGeocoderInterface::flags
virtual Flags flags() const =0
Returns the geocoder's capability flags.
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:69
QgsGeocoderInterface::wkbType
virtual QgsWkbTypes::Type wkbType() const
Returns the WKB type of geometries returned by the geocoder.
Definition: qgsgeocoder.cpp:27
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsGeocoderInterface::appendedFields
virtual QgsFields appendedFields() const
Returns a set of newly created fields which will be appended to existing features during the geocode ...
Definition: qgsgeocoder.cpp:25
QgsGeocoderInterface::geocodeString
virtual QList< QgsGeocoderResult > geocodeString(const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const
Geocodes a string.
Definition: qgsgeocoder.cpp:29
QgsGeocoderContext
Encapsulates the context of a geocoding operation.
Definition: qgsgeocodercontext.h:31
QgsGeocoderResult
Represents a matching result from a geocoder search.
Definition: qgsgeocoderresult.h:40
QgsNominatimGeocoder
A geocoder which uses the Nominatim geocoding API to retrieve results.
Definition: qgsnominatimgeocoder.h:36
QgsGeocoderInterface
Interface for geocoders.
Definition: qgsgeocoder.h:36