From 43c44eccdc56c50e41e8efbe5f7a34b57eed756f Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Tue, 2 Feb 2016 04:29:27 -0500 Subject: Allow using tileSize: 512 as a switch to trade retina support for 512px raster tiles --- src/mbgl/util/mapbox.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mbgl/util/mapbox.cpp') diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp index 93b2b8521c..7ee0f279b6 100644 --- a/src/mbgl/util/mapbox.cpp +++ b/src/mbgl/util/mapbox.cpp @@ -119,7 +119,7 @@ std::string normalizeTileURL(const std::string& url, const std::string& accessTo return baseURL + "v4/" + url.substr(sizeof("mapbox://tiles/") - 1) + "?access_token=" + accessToken; } -std::string canonicalizeTileURL(const std::string& url, SourceType type) { +std::string canonicalizeTileURL(const std::string& url, SourceType type, uint16_t tileSize) { auto tilesetStartIdx = url.find("/v4/"); if (tilesetStartIdx == std::string::npos) { return url; @@ -159,8 +159,14 @@ std::string canonicalizeTileURL(const std::string& url, SourceType type) { } #endif // !defined(__ANDROID__) && !defined(__APPLE__) - return "mapbox://tiles/" + tileset + "/{z}/{x}/{y}" + - (type == SourceType::Raster ? "{ratio}" : "") + "." + extension; + std::string result = "mapbox://tiles/" + tileset + "/{z}/{x}/{y}"; + + if (type == SourceType::Raster) { + result += tileSize == 512 ? "@2x" : "{ratio}"; + } + + result += "." + extension; + return result; } } // end namespace mapbox -- cgit v1.2.1