37 const QUrl &requestUrl,
const QString &userAgent,
const QString &authenticationKey)
39 QNetworkRequest networkRequest(requestUrl);
40 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, userAgent.toLatin1());
41 networkRequest.setRawHeader(
42 "Authorization", QStringLiteral(
"Bearer %1").arg(authenticationKey).toLatin1());
44 return networkRequest;
89 auto northeastCoordObj = CoordinateJson::tryConvertFromQGeoCoordinate(boundingGeoRect.topRight());
90 auto southwestCoordObj = CoordinateJson::tryConvertFromQGeoCoordinate(boundingGeoRect.bottomLeft());
92 return !northeastCoordObj.isEmpty() && !southwestCoordObj.isEmpty()
95 {northeastKey, northeastCoordObj},
96 {southwestKey, southwestCoordObj},
103 if (!coordinateBounds.contains(northeastKey) || !coordinateBounds.contains(southwestKey))
106 const auto northeast =
107 CoordinateJson::tryConvertToQGeoCoordinate(coordinateBounds.value(northeastKey).toObject());
108 const auto southwest =
109 CoordinateJson::tryConvertToQGeoCoordinate(coordinateBounds.value(southwestKey).toObject());
111 return northeast.isValid() && southwest.isValid()
112 ? QGeoRectangle(QList<QGeoCoordinate>({northeast, southwest}))
124 const auto addressJsonObj = siteJsonObj.value(QStringLiteral(
"address")).toObject();
125 if (!addressJsonObj.isEmpty()) {
126 address.setCountry(addressJsonObj.value(QStringLiteral(
"country")).toVariant().toString());
127 address.setCountryCode(addressJsonObj.value(QStringLiteral(
"countryCode")).toVariant().toString());
128 address.setState(addressJsonObj.value(QStringLiteral(
"adminArea")).toVariant().toString());
130 auto city = addressJsonObj.value(QStringLiteral(
"city")).toVariant().toString();
134 : addressJsonObj.value(QStringLiteral(
"locality")).toVariant().toString());
135 address.setPostalCode(addressJsonObj.value(QStringLiteral(
"postalCode")).toVariant().toString());
137 auto streetName = addressJsonObj.value(QStringLiteral(
"thoroughfare")).toVariant().toString();
138 auto streetNumber = addressJsonObj.value(QStringLiteral(
"streetNumber")).toVariant().toString();
139 address.setStreet(QString(
"%1 %2").arg(streetName).arg(streetNumber).trimmed());
142 address.setText(siteJsonObj.value(QStringLiteral(
"formatAddress")).toVariant().toString());
149 QGeoLocation location;
151 location.setAddress(tryConvertToGeoAddress(siteJsonObj));
152 location.setCoordinate(
153 OhosMapKit::CoordinateJson::tryConvertToQGeoCoordinate(
154 siteJsonObj.value(QStringLiteral(
"location")).toObject()));
155 location.setBoundingShape(
156 OhosMapKit::CoordinateBoundsJson::tryConvertToQGeoRectangle(
157 siteJsonObj.value(QStringLiteral(
"viewport")).toObject()));