summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-01-13 11:50:48 +0100
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-13 13:04:59 -0800
commit62973f9e5a2be037f582e111248e06f623f2374e (patch)
tree6c8e439031aa8353288b5d948eca84bb2e50ff1a /src
parent1ff317c1cdebc2bb34bb759dea957f8dd9660eb1 (diff)
downloadqtlocation-mapboxgl-62973f9e5a2be037f582e111248e06f623f2374e.tar.gz
[core] move raster tile URL normalization to source parsing
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/source.cpp8
-rw-r--r--src/mbgl/util/mapbox.cpp6
-rw-r--r--src/mbgl/util/mapbox.hpp2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp
index a14e0badd0..e8dc704923 100644
--- a/src/mbgl/map/source.cpp
+++ b/src/mbgl/map/source.cpp
@@ -174,6 +174,14 @@ void Source::load() {
if (info.type == SourceType::Vector || info.type == SourceType::Raster) {
parseTileJSON(d);
+
+ // TODO: Remove this hack by delivering proper URLs in the TileJSON to begin with.
+ if (info.type == SourceType::Raster && util::mapbox::isMapboxURL(info.url)) {
+ // We need to insert {ratio} into raster source URLs that are loaded from mapbox://
+ // TileJSONs.
+ std::transform(info.tiles.begin(), info.tiles.end(), info.tiles.begin(),
+ util::mapbox::normalizeRasterTileURL);
+ }
} else if (info.type == SourceType::GeoJSON) {
parseGeoJSON(d);
}
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 7bcfa7322c..067c9918cc 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -111,11 +111,7 @@ std::string normalizeGlyphsURL(const std::string& url, const std::string& access
return baseURL + "fonts/v1/" + user + "/" + fontstack + "/" + range + "?access_token=" + accessToken;
}
-std::string normalizeTileURL(const std::string& url, const std::string& sourceURL, SourceType sourceType) {
- if (sourceURL.empty() || !isMapboxURL(sourceURL) || sourceType != SourceType::Raster) {
- return url;
- }
-
+std::string normalizeRasterTileURL(const std::string& url) {
std::string::size_type queryIdx = url.rfind("?");
// Trim off the right end but never touch anything before the extension dot.
std::string urlSansParams((queryIdx == std::string::npos) ? url : url.substr(0, queryIdx));
diff --git a/src/mbgl/util/mapbox.hpp b/src/mbgl/util/mapbox.hpp
index 64f34d72a7..3c44d704c7 100644
--- a/src/mbgl/util/mapbox.hpp
+++ b/src/mbgl/util/mapbox.hpp
@@ -14,7 +14,7 @@ std::string normalizeSourceURL(const std::string& url, const std::string& access
std::string normalizeStyleURL(const std::string& url, const std::string& accessToken);
std::string normalizeSpriteURL(const std::string& url, const std::string& accessToken);
std::string normalizeGlyphsURL(const std::string& url, const std::string& accessToken);
-std::string normalizeTileURL(const std::string& url, const std::string& sourceURL, SourceType sourceType);
+std::string normalizeRasterTileURL(const std::string& url);
// Canonicalizes Mapbox URLs by removing [a-d] subdomain prefixes, access tokens, and protocol.
// Note that this is close, but not exactly the reverse operation as above, as this retains certain