11#include <QtPositioning/QGeoAddress>
12#include <QtPositioning/QGeoCoordinate>
13#include <QtPositioning/QGeoCircle>
14#include <QtPositioning/QGeoRectangle>
15#include <QtPositioning/QGeoShape>
29 , m_networkManager(networkManager)
48QString QGeoCodingManagerEngineNokia::getAuthenticationString()
const
53 authenticationString +=
"?apiKey=";
54 authenticationString += m_apiKey;
57 return authenticationString;
64 QString requestString =
"https://";
66 requestString +=
"/6.2/geocode.json";
68 requestString += getAuthenticationString();
69 requestString +=
"&gen=9";
71 requestString +=
"&language=";
74 bool manualBoundsRequired =
false;
76 manualBoundsRequired =
true;
80 requestString +=
"?prox=";
81 requestString += trimDouble(circ.center().latitude());
83 requestString += trimDouble(circ.center().longitude());
85 requestString += trimDouble(circ.radius());
90 requestString +=
"&bbox=";
91 requestString += trimDouble(
rect.topLeft().latitude());
93 requestString += trimDouble(
rect.topLeft().longitude());
95 requestString += trimDouble(
rect.bottomRight().latitude());
97 requestString += trimDouble(
rect.bottomRight().longitude());
101 if (
address.country().isEmpty()) {
104 if (!
address.state().isEmpty())
110 if (!
address.postalCode().isEmpty())
113 if (!
address.street().isEmpty())
116 requestString +=
"&searchtext=";
117 requestString += parts.join(
"+").replace(
' ',
'+');
119 requestString +=
"&country=";
120 requestString +=
address.country();
122 if (!
address.state().isEmpty()) {
123 requestString +=
"&state=";
124 requestString +=
address.state();
127 if (!
address.city().isEmpty()) {
128 requestString +=
"&city=";
129 requestString +=
address.city();
132 if (!
address.postalCode().isEmpty()) {
133 requestString +=
"&postalcode=";
134 requestString +=
address.postalCode();
137 if (!
address.street().isEmpty()) {
138 requestString +=
"&street=";
139 requestString +=
address.street();
143 return geocode(requestString, bounds, manualBoundsRequired);
151 QString requestString =
"https://";
153 requestString +=
"/6.2/geocode.json";
155 requestString += getAuthenticationString();
156 requestString +=
"&gen=9";
158 requestString +=
"&language=";
161 requestString +=
"&searchtext=";
165 requestString +=
"&maxresults=";
175 requestString +=
"&pageinformation=";
179 bool manualBoundsRequired =
false;
182 if (
rect.isValid()) {
183 requestString +=
"&bbox=";
184 requestString += trimDouble(
rect.topLeft().latitude());
185 requestString +=
",";
186 requestString += trimDouble(
rect.topLeft().longitude());
187 requestString +=
";";
188 requestString += trimDouble(
rect.bottomRight().latitude());
189 requestString +=
",";
190 requestString += trimDouble(
rect.bottomRight().longitude());
194 if (circ.isValid()) {
195 requestString +=
"?prox=";
196 requestString += trimDouble(circ.center().latitude());
197 requestString +=
",";
198 requestString += trimDouble(circ.center().longitude());
199 requestString +=
",";
200 requestString += trimDouble(circ.radius());
203 manualBoundsRequired =
true;
211 bool manualBoundsRequired,
217 limit,
offset, bounds, manualBoundsRequired,
this);
220 this, &QGeoCodingManagerEngineNokia::placesFinished);
223 this, &QGeoCodingManagerEngineNokia::placesError);
231 QString requestString =
"https://";
233 requestString +=
"/6.2/reversegeocode.json";
235 requestString += getAuthenticationString();
236 requestString +=
"&gen=9";
238 requestString +=
"&mode=retrieveAddresses";
240 requestString +=
"&prox=";
241 requestString += trimDouble(coordinate.
latitude());
242 requestString +=
",";
243 requestString += trimDouble(coordinate.
longitude());
245 bool manualBoundsRequired =
false;
248 if (circ.isValid() && circ.center() == coordinate) {
249 requestString +=
",";
250 requestString += trimDouble(circ.radius());
252 manualBoundsRequired =
true;
255 manualBoundsRequired =
true;
258 requestString +=
"&language=";
261 return geocode(requestString, bounds, manualBoundsRequired);
264QString QGeoCodingManagerEngineNokia::trimDouble(
double degree,
int decimalDigits)
268 int index = sDegree.indexOf(
'.');
276void QGeoCodingManagerEngineNokia::placesFinished()
void finished()
This signal is emitted when this reply has finished processing.
void errorOccurred(QGeoCodeReply::Error error, const QString &errorString=QString())
This signal is emitted when an error has been detected in the processing of this reply.
Error
Describes an error which prevented the completion of the operation.
QGeoCodeReply * reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) override
Begins the reverse geocoding of coordinate.
QGeoCodingManagerEngineNokia(QGeoNetworkAccessManager *networkManager, const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString)
~QGeoCodingManagerEngineNokia()
QGeoCodeReply * geocode(const QGeoAddress &address, const QGeoShape &bounds) override
Begins the geocoding of address.
void errorOccurred(QGeoCodeReply *reply, QGeoCodeReply::Error error, const QString &errorString=QString())
void finished(QGeoCodeReply *reply)
QLocale locale() const
Returns the locale used to hint to this geocoding manager about what language to use for the results.
double longitude
This property holds the longitude in decimal degrees.
double latitude
This property holds the latitude in decimal degrees.
virtual QNetworkReply * get(const QNetworkRequest &request)=0
Error
Describes an error related to the loading and setup of a service provider plugin.
ShapeType type
This property holds the type of this geo shape.
Q_INVOKABLE QGeoRectangle boundingGeoRectangle() const
Returns a QGeoRectangle representing the geographical bounding rectangle of the geo shape,...
QString getCurrentHost() const
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
void setParent(QObject *parent)
Makes the object a child of parent.
int receivers(const char *signal) const
Returns the number of receivers connected to the signal.
void deleteLater()
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
static QT_BEGIN_NAMESPACE const unsigned char marc_language_code_list[]
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
DBusConnection const char DBusError * error
GLenum GLuint GLintptr offset
GLuint GLuint64EXT address
QLatin1StringView QLatin1String
#define QStringLiteral(str)
const QString REVERSE_GEOCODING_HOST
const QString GEOCODING_HOST