Skip to content

Commit a45da6c

Browse files
committed
RAG-4829: Change default basemap(mapbox) url
1 parent 216eb44 commit a45da6c

File tree

3 files changed

+18
-120
lines changed

3 files changed

+18
-120
lines changed

src/GeoTileFetcher.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ namespace
1515
QString quad;
1616
const int x = spec.x();
1717
const int y = spec.y();
18-
for (int i = spec.zoom(); i > 0; i--)
18+
for (int i = spec.zoom(); i > 0; i--)
1919
{
2020
int digit = 0;
2121
int mask = 1 << (i - 1);
22-
if ((x & mask) != 0)
22+
if ((x & mask) != 0)
2323
{
24-
digit += 1;
24+
digit += 1;
2525
}
26-
if ((y & mask) != 0)
26+
if ((y & mask) != 0)
2727
{
28-
digit += 2;
28+
digit += 2;
2929
}
3030
quad = quad + QString::number(digit);
3131
}
@@ -80,7 +80,7 @@ namespace
8080
// Easting and northing in meters
8181
a * lng * M_PI / 180.0,
8282
a * std::log(std::tan(M_PI / 4.0 + (lat / 2.0) * M_PI / 180.0))
83-
);
83+
);
8484
};
8585

8686
BboxCoordinates coords(spec);
@@ -110,7 +110,6 @@ GeoTileFetcher::GeoTileFetcher(int scaleFactor, bool enableLogging, const QStrin
110110
: QGeoTileFetcher(parent)
111111
, m_networkManager(new QNetworkAccessManager(this))
112112
, m_userAgent("Qt Location based application")
113-
, m_format("png")
114113
, m_replyFormat("png")
115114
, m_accessToken("")
116115
, m_enableLogging(enableLogging)
@@ -126,19 +125,17 @@ void GeoTileFetcher::setMapIds(const QVector<QString>& mapIds)
126125

127126
void GeoTileFetcher::setFormat(const QString& format)
128127
{
129-
m_format = format;
130-
131-
if (m_format == "png" || m_format == "png32" || m_format == "png64" || m_format == "png128" || m_format == "png256")
128+
if (format == "png" || format == "png32" || format == "png64" || format == "png128" || format == "png256")
132129
{
133130
m_replyFormat = "png";
134131
}
135-
else if (m_format == "jpg70" || m_format == "jpg80" || m_format == "jpg90")
132+
else if (format == "jpg70" || format == "jpg80" || format == "jpg90")
136133
{
137134
m_replyFormat = "jpg";
138135
}
139136
else if (m_enableLogging)
140137
{
141-
qWarning() << "GeoTileFetcher: Unknown map format " << m_format;
138+
qWarning() << "GeoTileFetcher: Unknown map format " << format;
142139
}
143140
}
144141

@@ -156,17 +153,15 @@ QGeoTiledMapReply* GeoTileFetcher::getTileImage(const QGeoTileSpec& spec)
156153
if (m_customBasemapUrl.isEmpty())
157154
{
158155
request.setUrl(
159-
QUrl(QStringLiteral("https://api.tiles.mapbox.com/v4/")
160-
+ ((spec.mapId() >= m_mapIds.size()) ? QStringLiteral("mapbox.streets") : m_mapIds[spec.mapId() - 1])
161-
+ QLatin1Char('/')
156+
QUrl(QStringLiteral("https://api.mapbox.com/styles/v1/cloudpix4d/")
157+
+ ((spec.mapId() - 1 >= m_mapIds.size()) ? QStringLiteral("ck8zz9gpq0vty1ip30bji3b5a") : m_mapIds[spec.mapId() - 1])
158+
+ QLatin1String("/tiles/256/")
162159
+ QString::number(spec.zoom())
163160
+ QLatin1Char('/')
164161
+ QString::number(spec.x())
165162
+ QLatin1Char('/')
166163
+ QString::number(spec.y())
167-
+ ((m_scaleFactor > 1) ? (QLatin1Char('@') + QString::number(m_scaleFactor) + QLatin1String("x."))
168-
: QLatin1String("."))
169-
+ m_format
164+
+ ((m_scaleFactor > 1) ? (QLatin1Char('@') + QString::number(m_scaleFactor) + QLatin1Char('x')) : QString())
170165
+ QLatin1Char('?')
171166
+ QStringLiteral("access_token=")
172167
+ m_accessToken));
@@ -269,4 +264,4 @@ QGeoTiledMapReply* GeoTileFetcher::getTileImage(const QGeoTileSpec& spec)
269264
}
270265

271266
return new GeoMapReply(m_networkManager->get(request), spec, m_replyFormat, m_enableLogging);
272-
}
267+
}

src/GeoTileFetcher.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ class GeoTileFetcher : public QGeoTileFetcher
2323
private:
2424
QNetworkAccessManager* m_networkManager{nullptr};
2525
QByteArray m_userAgent;
26-
QString m_format;
2726
QString m_replyFormat;
2827
QString m_accessToken;
2928
QVector<QString> m_mapIds;
3029
int m_scaleFactor{0};
3130
bool m_enableLogging{false};
3231
QString m_customBasemapUrl;
33-
};
32+
};

src/GeoTiledMappingManagerEngine.cpp

Lines changed: 3 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -75,117 +75,21 @@ GeoTiledMappingManagerEngine::GeoTiledMappingManagerEngine(const QVariantMap& pa
7575
if (usingMapBox)
7676
{
7777
mapTypes << QGeoMapType(QGeoMapType::StreetMap,
78-
QStringLiteral("mapbox.streets"),
78+
QStringLiteral("ck8zz9gpq0vty1ip30bji3b5a"),
7979
QStringLiteral("Street"),
8080
false,
8181
false,
8282
mapTypes.size() + 1,
8383
pluginName,
8484
cameraCaps);
85-
mapTypes << QGeoMapType(QGeoMapType::StreetMap,
86-
QStringLiteral("mapbox.light"),
87-
QStringLiteral("Light"),
88-
false,
89-
false,
90-
mapTypes.size() + 1,
91-
pluginName,
92-
cameraCaps);
93-
mapTypes << QGeoMapType(QGeoMapType::StreetMap,
94-
QStringLiteral("mapbox.dark"),
95-
QStringLiteral("Dark"),
96-
false,
97-
true,
98-
mapTypes.size() + 1,
99-
pluginName,
100-
cameraCaps);
101-
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay,
102-
QStringLiteral("mapbox.satellite"),
103-
QStringLiteral("Satellite"),
104-
false,
105-
false,
106-
mapTypes.size() + 1,
107-
pluginName,
108-
cameraCaps);
10985
mapTypes << QGeoMapType(QGeoMapType::HybridMap,
110-
QStringLiteral("mapbox.streets-satellite"),
86+
QStringLiteral("ck8zzfxb30vwp1jo04yktjtbg"),
11187
QStringLiteral("Streets Satellite"),
11288
false,
11389
false,
11490
mapTypes.size() + 1,
11591
pluginName,
11692
cameraCaps);
117-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
118-
QStringLiteral("mapbox.wheatpaste"),
119-
QStringLiteral("Wheatpaste"),
120-
false,
121-
false,
122-
mapTypes.size() + 1,
123-
pluginName,
124-
cameraCaps);
125-
mapTypes << QGeoMapType(QGeoMapType::StreetMap,
126-
QStringLiteral("mapbox.streets-basic"),
127-
QStringLiteral("Streets Basic"),
128-
false,
129-
false,
130-
mapTypes.size() + 1,
131-
pluginName,
132-
cameraCaps);
133-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
134-
QStringLiteral("mapbox.comic"),
135-
QStringLiteral("Comic"),
136-
false,
137-
false,
138-
mapTypes.size() + 1,
139-
pluginName,
140-
cameraCaps);
141-
mapTypes << QGeoMapType(QGeoMapType::PedestrianMap,
142-
QStringLiteral("mapbox.outdoors"),
143-
QStringLiteral("Outdoors"),
144-
false,
145-
false,
146-
mapTypes.size() + 1,
147-
pluginName,
148-
cameraCaps);
149-
mapTypes << QGeoMapType(QGeoMapType::CycleMap,
150-
QStringLiteral("mapbox.run-bike-hike"),
151-
QStringLiteral("Run Bike Hike"),
152-
false,
153-
false,
154-
mapTypes.size() + 1,
155-
pluginName,
156-
cameraCaps);
157-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
158-
QStringLiteral("mapbox.pencil"),
159-
QStringLiteral("Pencil"),
160-
false,
161-
false,
162-
mapTypes.size() + 1,
163-
pluginName,
164-
cameraCaps);
165-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
166-
QStringLiteral("mapbox.pirates"),
167-
QStringLiteral("Pirates"),
168-
false,
169-
false,
170-
mapTypes.size() + 1,
171-
pluginName,
172-
cameraCaps);
173-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
174-
QStringLiteral("mapbox.emerald"),
175-
QStringLiteral("Emerald"),
176-
false,
177-
false,
178-
mapTypes.size() + 1,
179-
pluginName,
180-
cameraCaps);
181-
mapTypes << QGeoMapType(QGeoMapType::CustomMap,
182-
QStringLiteral("mapbox.high-contrast"),
183-
QStringLiteral("High Contrast"),
184-
false,
185-
false,
186-
mapTypes.size() + 1,
187-
pluginName,
188-
cameraCaps);
18993

19094
for (const auto& type : mapTypes)
19195
{
@@ -256,4 +160,4 @@ QGeoMap* GeoTiledMappingManagerEngine::createMap()
256160
QSGNode* NoGeoTiledMap::updateSceneGraph(QSGNode*, QQuickWindow* window)
257161
{
258162
return nullptr;
259-
}
163+
}

0 commit comments

Comments
 (0)