6#include <QtPositioning/QGeoShape>
7#include <QtPositioning/QGeoRectangle>
8#include <QtPositioning/QGeoAddress>
9#include <QtPositioning/QGeoCoordinate>
11#include <QtCore/QThreadPool>
12#include <QtCore/QJsonObject>
13#include <QtCore/QJsonArray>
14#include <QtCore/QJsonParseError>
15#include <QtCore/QVariantMap>
81 *errorString =
QLatin1String(
"Expected Address element within Location object");
84 *errorString =
QLatin1String(
"Expected Address object within Location object");
90 *errorString =
QLatin1String(
"Expected DisplayPosition element within Location object");
93 *errorString =
QLatin1String(
"Expected DisplayPosition object within Location object");
98 if (latit == displayPosition.
constEnd()) {
99 *errorString =
QLatin1String(
"Expected Latitude element within Location.DisplayPosition object");
102 *errorString =
QLatin1String(
"Expected Latitude double within Location.DisplayPosition object");
106 if (lonit == displayPosition.
constEnd()) {
107 *errorString =
QLatin1String(
"Expected Longitude element within Location.DisplayPosition object");
110 *errorString =
QLatin1String(
"Expected Longitude double within Location.DisplayPosition object");
116 *errorString =
QLatin1String(
"Expected MapView element within Location object");
119 *errorString =
QLatin1String(
"Expected MapView object within Location object");
125 *errorString =
QLatin1String(
"Expected BottomRight element within Location.MapView object");
128 *errorString =
QLatin1String(
"Expected BottomRight object within Location.MapView object");
133 if (brlatit == bottomRight.
constEnd()) {
134 *errorString =
QLatin1String(
"Expected Latitude element within Location.MapView.BottomRight object");
137 *errorString =
QLatin1String(
"Expected Latitude double within Location.MapView.BottomRight object");
141 if (brlonit == bottomRight.
constEnd()) {
142 *errorString =
QLatin1String(
"Expected Longitude element within Location.MapView.BottomRight object");
145 *errorString =
QLatin1String(
"Expected Longitude double within Location.MapView.BottomRight object");
150 *errorString =
QLatin1String(
"Expected TopLeft element within Location.MapView object");
153 *errorString =
QLatin1String(
"Expected TopLeft object within Location.MapView object");
158 if (tllatit == topLeft.
constEnd()) {
159 *errorString =
QLatin1String(
"Expected Latitude element within Location.MapView.TopLeft object");
162 *errorString =
QLatin1String(
"Expected Latitude double within Location.MapView.TopLeft object");
166 if (tllonit == bottomRight.
constEnd()) {
167 *errorString =
QLatin1String(
"Expected Longitude element within Location.MapView.TopLeft object");
170 *errorString =
QLatin1String(
"Expected Longitude double within Location.MapView.TopLeft object");
217 *errorString =
QLatin1String(
"Expected JSON document containing object");
224 *errorString =
QLatin1String(
"Expected Response element within root object");
226 }
else if (!
it.value().isObject()) {
227 *errorString =
QLatin1String(
"Expected Response object within root object");
234 *errorString =
QLatin1String(
"Expected View element within Response object");
237 *errorString =
QLatin1String(
"Expected View array within Response object");
243 if (!viewElement.isObject()) {
244 *errorString =
QLatin1String(
"Expected View array element to be object");
250 if (voit == viewObject.
constEnd()) {
251 *errorString =
QLatin1String(
"Expected Result element within View array object element");
254 *errorString =
QLatin1String(
"Expected Result array within View array object element");
260 if (!resultElement.isObject()) {
261 *errorString =
QLatin1String(
"Expected Result array element to be object");
265 QJsonObject resultObject = resultElement.toObject();
267 if (roit == resultObject.
constEnd()) {
268 *errorString =
QLatin1String(
"Expected Location element in Result array element object");
271 *errorString =
QLatin1String(
"Expected Location object in Result array element object");
296 address.setCountryCode(
addr.value(
"Country").toString());
298 address.setCounty(
addr.value(
"County").toString());
300 address.setDistrict(
addr.value(
"District").toString());
301 QString houseNumber =
addr.value(
"HouseNumber").toString();
304 address.setPostalCode(
addr.value(
"PostalCode").toString());
306 if (!
label.isEmpty()) {
309 const QJsonArray additionalData =
addr.value(
"AdditionalData").toArray();
311 if (adv.isObject()) {
369 if (checkDocument(m_document, &m_errorString)) {
371 parseDocument(m_document, m_bounds, &m_results);
void setBounds(const QGeoShape &bounds)
void run() override
Implement this pure virtual function in your subclass.
void errorOccurred(const QString &errorString)
void parse(const QByteArray &data)
void results(const QList< QGeoLocation > &locations)
void setCoordinate(const QGeoCoordinate &position)
Sets the coordinate of the location.
void setAddress(const QGeoAddress &address)
Sets the address of the location.
void setBoundingShape(const QGeoShape &shape)
void setTopLeft(const QGeoCoordinate &topLeft)
Sets the top left coordinate of this geo rectangle to topLeft.
void setBottomRight(const QGeoCoordinate &bottomRight)
Sets the bottom right coordinate of this geo rectangle to bottomRight.
bool isValid
This property holds the validity of the geo shape.
Q_INVOKABLE bool contains(const QGeoCoordinate &coordinate) const
Returns whether the coordinate coordinate is contained within this geo shape.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QJsonObject object() const
Returns the QJsonObject contained in the document.
bool isObject() const
Returns true if the document contains an object.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
QJsonValueConstRef value() const
Returns the current item's value.
\inmodule QtCore\reentrant
const_iterator constFind(const QString &key) const
Returns a const iterator pointing to the item with key key in the map.
const_iterator constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
QJsonValue value(const QString &key) const
Returns a QJsonValue representing the value for the key key.
Q_CORE_EXPORT QJsonArray toArray() const
Q_CORE_EXPORT QJsonObject toObject() const
\inmodule QtCore \reentrant
QJsonObject toObject() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QJsonArray toArray() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double toDouble(double defaultValue=0) const
Converts the value to a double and returns it.
QString toString() const
Converts the value to a QString and returns it.
void append(parameter_type t)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString trimmed() const &
void start(QRunnable *runnable, int priority=0)
Reserves a thread and uses it to run runnable, unless this thread will make the current thread count ...
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
bool parseLocation(const QJsonObject &obj, const QGeoShape &bounds, QGeoLocation *loc)
void parseDocument(const QJsonDocument &doc, const QGeoShape &bounds, QList< QGeoLocation > *locs)
bool checkDocument(const QJsonDocument &doc, QString *errorString)
bool checkLocation(const QJsonObject &loc, QString *errorString)
GLuint GLsizei const GLchar * label
[43]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
QLatin1StringView QLatin1String
\inmodule QtCore\reentrant
QString errorString() const
\variable QJsonParseError::error