4#include <QtCore/QLocale>
12 const QString &mapName,
13 const QString &referrer,
14 const QString &imageFormat,
16 QGeoMapType::MapStyle mapStyle)
19 , _imageFormat(imageFormat)
20 , _averageSize(averageSize)
22 , _language(!QLocale::system().uiLanguages().isEmpty() ? QLocale::system().uiLanguages().constFirst() : "en")
23 , _mapId(_mapIdIndex++)
35 return QUrl(
_getURL(x, y, zoom));
40 if (image.size() < 3) {
44 static constexpr QByteArrayView pngSignature(
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A");
45 if (image.startsWith(pngSignature)) {
46 return QStringLiteral(
"png");
49 static constexpr QByteArrayView jpegSignature(
"\xFF\xD8\xFF");
50 if (image.startsWith(jpegSignature)) {
51 return QStringLiteral(
"jpg");
54 static constexpr QByteArrayView gifSignature(
"\x47\x49\x46\x38");
55 if (image.startsWith(gifSignature)) {
56 return QStringLiteral(
"gif");
65 for (
int i = levelOfDetail; i > 0; i--) {
67 const int mask = 1 << (i - 1);
69 if ((tileX & mask) != 0) {
72 if ((tileY & mask) != 0) {
76 (void) quadKey.append(digit);
84 return (x + 2 * y) % max;
89 return static_cast<int>(floor((lon + 180.0) / 360.0 * pow(2.0, z)));
94 return static_cast<int>(floor((1.0 - log(tan(lat * M_PI / 180.0) + 1.0 / cos(lat * M_PI / 180.0)) / M_PI) / 2.0 * pow(2.0, z)));
99 return x / std::pow(2.0, z) * 360.0 - 180.0;
104 const double n = M_PI - 2.0 * M_PI * y / std::pow(2.0, z);
105 return qRadiansToDegrees(std::atan(std::sinh(n)));
109 double topleftLat,
double bottomRightLon,
110 double bottomRightLat)
const
119 static_cast<quint64
>(set.
tileX0) + 1) *
120 (
static_cast<quint64
>(set.
tileY1) -
121 static_cast<quint64
>(set.
tileY0) + 1);
#define QGC_LOGGING_CATEGORY(name, categoryStr)
int _getServerNum(int x, int y, int max) const
QString _tileXYToQuadKey(int tileX, int tileY, int levelOfDetail) const
const QString _imageFormat
virtual double tileY2lat(int y, int z) const
virtual QGCTileSet getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat) const
quint32 getAverageSize() const
virtual int long2tileX(double lon, int z) const
QString getImageFormat(QByteArrayView image) const
virtual double tileX2long(int x, int z) const
QUrl getTileURL(int x, int y, int zoom) const
virtual int lat2tileY(double lat, int z) const
virtual QString _getURL(int x, int y, int zoom) const =0