QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsgooglemapsgeocoder.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgooglemapsgeocoder.h
3  ---------------
4  Date : November 2020
5  Copyright : (C) 2020 by Nyall Dawson
6  Email : nyall dot dawson 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 QGSGOOGLEMAPSGEOCODER_H
17 #define QGSGOOGLEMAPSGEOCODER_H
18 
19 #include "qgis_core.h"
20 #include "qgsgeocoder.h"
21 
22 #include <QMutex>
23 
40 class CORE_EXPORT QgsGoogleMapsGeocoder : public QgsGeocoderInterface
41 {
42 
43  public:
44 
55  QgsGoogleMapsGeocoder( const QString &apiKey, const QString &regionBias = QString() );
56 
57  Flags flags() const override;
58  QgsFields appendedFields() const override;
59  QgsWkbTypes::Type wkbType() const override;
60  QList< QgsGeocoderResult > geocodeString( const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback = nullptr ) const override;
61 
65  QUrl requestUrl( const QString &address, const QgsRectangle &bounds = QgsRectangle() ) const;
66 
70  QgsGeocoderResult jsonToResult( const QVariantMap &json ) const;
71 
75  void setEndpoint( const QString &endpoint );
76 
82  QString apiKey() const;
83 
91  void setApiKey( const QString &key );
92 
98  QString region() const;
99 
108  void setRegion( const QString &region );
109 
110  private:
111 
112  QString mApiKey;
113  QString mRegion;
114  QString mEndpoint;
115 
116  static QReadWriteLock sMutex;
117 
118 };
119 
120 #endif // QGSGOOGLEMAPSGEOCODER_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Container of fields for a vector layer.
Definition: qgsfields.h:45
Encapsulates the context of a geocoding operation.
Interface for geocoders.
Definition: qgsgeocoder.h:37
virtual QgsWkbTypes::Type wkbType() const
Returns the WKB type of geometries returned by the geocoder.
Definition: qgsgeocoder.cpp:27
virtual Flags flags() const =0
Returns the geocoder's capability flags.
virtual QList< QgsGeocoderResult > geocodeString(const QString &string, const QgsGeocoderContext &context, QgsFeedback *feedback=nullptr) const
Geocodes a string.
Definition: qgsgeocoder.cpp:29
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
Represents a matching result from a geocoder search.
A geocoder which uses the Google Map geocoding API to retrieve results.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70