14#include <QtCore/QJsonArray>
15#include <QtCore/QJsonObject>
16#include <QtCore/QJsonDocument>
17#include <QtCore/qmath.h>
18#include <QtCore/qstandardpaths.h>
20#include <QtPositioning/private/qwebmercator_p.h>
21#include <QtPositioning/private/qdoublevector2d_p.h>
172 populateMapSchemes();
182void QGeoTiledMappingManagerEngineNokia::populateMapSchemes()
210 return m_mapSchemes[mapId];
215 const QString fullScheme(m_mapSchemes[mapId]);
229 qDebug() <<
"QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson() Invalid JSon document";
235 m_copyrights.
clear();
240 for (
int descIndex = 0; descIndex < descs.
count(); descIndex++) {
241 CopyrightDesc copyrightDesc;
244 copyrightDesc.minLevel =
desc[
"minLevel"].toDouble();
245 copyrightDesc.maxLevel =
desc[
"maxLevel"].toDouble();
246 copyrightDesc.label =
desc[
"label"].toString();
247 copyrightDesc.alt =
desc[
"alt"].toString();
250 for (
int boxIndex = 0; boxIndex < coordBoxes.
count(); boxIndex++) {
260 copyrightDesc.boxes << boundingBox;
262 copyrightDescList << copyrightDesc;
264 m_copyrights[
it.key()] = copyrightDescList;
276 if (versionInfo.size() > 1) {
277 const QString versionKey = versionInfo[0].trimmed();
278 const QString versionValue = versionInfo[1].trimmed();
280 newVersionData[versionKey] = versionValue;
285 updateVersion(newVersionData);
288void QGeoTiledMappingManagerEngineNokia::updateVersion(
const QJsonObject &newVersionData) {
300void QGeoTiledMappingManagerEngineNokia::saveMapVersion()
302 QDir saveDir(m_cacheDirectory);
306 qWarning(
"Failed to write here/nokia map version.");
314void QGeoTiledMappingManagerEngineNokia::loadMapVersion()
316 QDir saveDir(m_cacheDirectory);
320 qWarning(
"Failed to read here/nokia map version.");
340 static const QChar copyrightSymbol(0x00a9);
343 double viewX0, viewY0, viewX1, viewY1;
346 tile_iter lastTile = tiles.
constEnd();
349 double divFactor =
qPow(2.0, tile->zoom());
350 viewX0 = viewX1 = tile->x();
351 viewY0 = viewY1 = tile->y();
356 for (; tile != lastTile; ++tile) {
357 if (tile->x() < viewX0)
359 if (tile->x() > viewX1)
361 if (tile->y() < viewY0)
363 if (tile->y() > viewY1)
373 pt.
setX(viewX0 / divFactor);
374 pt.
setY(viewY0 / divFactor);
376 pt.
setX(viewX1 / divFactor);
377 pt.
setY(viewY1 / divFactor);
383 CopyrightDesc *descriptor;
384 int descIndex, boxIndex;
388 for (descIndex = 0; descIndex < descriptorList.
count(); descIndex++) {
389 if (descriptorList[descIndex].minLevel <= zoomLevel && zoomLevel <= descriptorList[descIndex].maxLevel) {
390 descriptor = &descriptorList[descIndex];
392 for (boxIndex = 0; boxIndex < descriptor->boxes.count(); boxIndex++) {
396 copyrightStrings.
insert(descriptor->label);
400 if (!descriptor->boxes.count())
401 copyrightStrings.
insert(descriptor->label);
405 for (
const QString ©rightString : copyrightStrings) {
406 if (copyrightsText.
length())
408 copyrightsText += copyrightSymbol;
409 copyrightsText += copyrightString;
412 return copyrightsText;
virtual void setMaxDiskUsage(int diskUsage)
static QString baseLocationCacheDirectory()
virtual void setMaxMemoryUsage(int memoryUsage)
virtual void setCostStrategyDisk(CostStrategy costStrategy)=0
virtual void setCostStrategyMemory(CostStrategy costStrategy)=0
virtual void setCostStrategyTexture(CostStrategy costStrategy)=0
virtual void setExtraTextureUsage(int textureUsage)=0
void setSupportsBearing(bool supportsBearing)
Sets whether the associated plugin can render a map when the camera has an arbitrary bearing to suppo...
void setMaximumZoomLevel(double maximumZoomLevel)
void setMaximumTilt(double maximumTilt)
void setMaximumFieldOfView(double maximumFieldOfView)
void setMinimumFieldOfView(double minimumFieldOfView)
void setOverzoomEnabled(bool overzoomEnabled)
Sets whether overzooming is supported by the associated plugin.
void setMinimumTilt(double minimumTilt)
void setMinimumZoomLevel(double minimumZoomLevel)
void setSupportsTilting(bool supportsTilting)
Sets whether the associated plugin can render a map when the camera is tilted to supportsTilting.
void setVersion(const int)
void setVersionData(const QJsonObject &versionData)
bool isNewVersion(const QJsonObject &newVersionData) const
QByteArray toJson() const
void setCameraCapabilities(const QGeoCameraCapabilities &capabilities)
void setSupportedMapTypes(const QList< QGeoMapType > &supportedMapTypes)
Sets the list of map types supported by this engine to mapTypes.
QVariantMap parameters() const
Error
Describes an error related to the loading and setup of a service provider plugin.
@ PrefetchTwoNeighbourLayers
void parseNewVersionInfo(const QByteArray &versionData)
QString getScheme(int mapId) const
QString evaluateCopyrightsText(const QGeoMapType &mapType, qreal zoomLevel, const QSet< QGeoTileSpec > &tiles)
QGeoTiledMappingManagerEngineNokia(QGeoNetworkAccessManager *networkManager, const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString)
QString getBaseScheme(int mapId) const
QGeoMap * createMap() override
void loadCopyrightsDescriptorsFromJson(const QByteArray &jsonData)
~QGeoTiledMappingManagerEngineNokia()
QGeoTiledMap::PrefetchStyle m_prefetchStyle
void setTileSize(const QSize &tileSize)
void setTileFetcher(QGeoTileFetcher *fetcher)
Sets the tile fetcher.
QAbstractGeoTileCache * tileCache()
void setTileCache(QAbstractGeoTileCache *cache)
Sets the tile cache.
void setTileVersion(int version)
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
\inmodule QtCore\reentrant
qsizetype count() const
Same as size().
QJsonValue at(qsizetype i) const
Returns a QJsonValue representing the value for index i.
\inmodule QtCore\reentrant
bool isNull() const
returns true if this document is null.
QJsonObject object() const
Returns the QJsonObject contained in the document.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
const_iterator constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the object.
const_iterator constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
QJsonObject toObject() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype count() const noexcept
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toLower() const &
qsizetype length() const
Returns the number of characters in this string.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator)
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
void saveFile(const QByteArray &data, const std::string &fileNameHint)
DBusConnection const char DBusError * error
GLsizei GLenum GLenum * types
GLdouble GLdouble GLdouble GLdouble top
GLenum const GLint * param
GLsizei const GLint * box
static quint64 cacheSize()
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static int toInt(const QChar &qc, int R)
view viewport() -> scroll(dx, dy, deviceRect)
\inmodule QtCore \reentrant