diff options
author | Lucas Wojciechowski <lucas@mapbox.com> | 2015-08-12 16:57:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-08-20 11:59:07 -0700 |
commit | a85fd681fc574df553934b0f30682b1ed856c3c9 (patch) | |
tree | 7d1c46f1b7c6c80dfdf2a1438c44fb425bd70f86 /src/mbgl/util/mapbox.cpp | |
parent | 3598b166bd1c4523b486fa8ea3ddc31e5a1ced6a (diff) | |
download | qtlocation-mapboxgl-a85fd681fc574df553934b0f30682b1ed856c3c9.tar.gz |
Support new glyph URL syntax
Diffstat (limited to 'src/mbgl/util/mapbox.cpp')
-rw-r--r-- | src/mbgl/util/mapbox.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp index 54e6868095..05e778dfb3 100644 --- a/src/mbgl/util/mapbox.cpp +++ b/src/mbgl/util/mapbox.cpp @@ -44,15 +44,11 @@ std::string normalizeStyleURL(const std::string& url, const std::string& accessT std::string normalizeGlyphsURL(const std::string& url, const std::string& accessToken) { if (url.compare(0, mapbox.length(), mapbox) != 0) { return url; + } else { + const std::string prefix = "mapbox://fonts/"; + const std::string user = url.substr(prefix.length(), url.find("/", prefix.length()) - prefix.length()); + return normalizeURL("mapbox://" + user + "/{fontstack}/{range}.pbf", "/fonts/v1/", accessToken); } - - const std::string fontstack = "mapbox://fontstack/"; - - if (url.compare(0, fontstack.length(), fontstack) == 0) { - return normalizeURL(url, "/v4/", accessToken); - } - - return normalizeURL(url, "/", accessToken); } std::string normalizeTileURL(const std::string& url, const std::string& sourceURL, SourceType sourceType) { @@ -60,15 +56,15 @@ std::string normalizeTileURL(const std::string& url, const std::string& sourceUR sourceType != SourceType::Raster) { return 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)); - + while (!urlSansParams.empty() && isdigit(urlSansParams.back())) { urlSansParams.pop_back(); } - + std::string::size_type basenameIdx = url.rfind("/", queryIdx); std::string::size_type extensionIdx = url.rfind(".", queryIdx); if (basenameIdx == std::string::npos || extensionIdx == std::string::npos || @@ -76,7 +72,7 @@ std::string normalizeTileURL(const std::string& url, const std::string& sourceUR // No file extension: probably not a file name we can tack a ratio onto. return url; } - + std::string normalizedURL(url); normalizedURL.insert(extensionIdx, "{ratio}"); return normalizedURL; |