Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeotilefetcherohosmapkit.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qurlquery.h>
5#include <QtCore/qurl.h>
6#include <QtLocation/private/qgeotilespec_p.h>
7#include <QtNetwork/qnetworkaccessmanager.h>
8#include <QtNetwork/qnetworkrequest.h>
9#include <qgeomapreplyohosmapkit.h>
10#include <qgeotilefetcherohosmapkit.h>
11#include <qohosmapkitcommon.h>
12
14
15namespace {
16
17constexpr int minScaleFactor = 1;
18constexpr int maxScaleFactor = 2;
19
20const QString tilesApiPath = QLatin1String("https://mapapi.cloud.huawei.com/mapApi/v1/mapService/getTile");
21
23{
24public:
26 const QString &authenticationKey, const QString &userAgent, int scaleFactor,
27 QGeoTiledMappingManagerEngine *parent);
28
29private:
30 QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec) override;
31
32 QNetworkAccessManager m_networkManager;
33 QString m_userAgent;
34 QString m_authenticationKey;
35 int m_scaleFactor;
36};
37
39 const QString &authenticationKey, const QString &userAgent, int scaleFactor,
40 QGeoTiledMappingManagerEngine *parent)
44 , m_scaleFactor(qBound(minScaleFactor, scaleFactor, maxScaleFactor))
45{
46}
47
49{
50 QUrlQuery query;
51 query.addQueryItem(QLatin1String("x"), QString::number(spec.x()));
52 query.addQueryItem(QLatin1String("y"), QString::number(spec.y()));
53 query.addQueryItem(QLatin1String("z"), QString::number(spec.zoom()));
54 query.addQueryItem(QLatin1String("language"), OhosMapKit::getLanguageCode());
55 query.addQueryItem(QLatin1String("scale"), QString::number(m_scaleFactor));
56
57 QUrl url(tilesApiPath);
58 url.setQuery(query);
59
60 return makeGeoTiledMapReplyOhosMapKit(
61 m_networkManager.get(
62 OhosMapKit::createOhosMapKitNetworkRequest(url, m_userAgent, m_authenticationKey)),
63 spec, this);
64}
65
66}
67
69 const QString &authenticationKey, const QString &userAgent, int scaleFactor,
70 QGeoTiledMappingManagerEngine *parent)
71{
72 return new QGeoTileFetcherOhosMapKit(authenticationKey, userAgent, scaleFactor, parent);
73}
74
75QT_END_NAMESPACE
QGeoTileFetcherOhosMapKit(const QString &authenticationKey, const QString &userAgent, int scaleFactor, QGeoTiledMappingManagerEngine *parent)
QGeoTiledMapReply * getTileImage(const QGeoTileSpec &spec) override
Combined button and popup list for selecting options.
QGeoTileFetcher * makeGeoTileFetcherOhosMapKit(const QString &authenticationKey, const QString &userAgent, int scaleFactor, QGeoTiledMappingManagerEngine *parent)