diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/map/map_context.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/map/map_data.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/map/resource_loader.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/map/resource_loader.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/source.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/storage/default_file_source.cpp | 25 |
8 files changed, 30 insertions, 43 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 8514c6ecb2..1141cf83bd 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -195,17 +195,6 @@ void Map::resetNorth() { } -#pragma mark - Access Token - -void Map::setAccessToken(const std::string &token) { - data->setAccessToken(token); -} - -std::string Map::getAccessToken() const { - return data->getAccessToken(); -} - - #pragma mark - Projection void Map::getWorldBoundsMeters(ProjectedMeters& sw, ProjectedMeters& ne) const { diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 28bd8903ed..2a03adb158 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -24,7 +24,6 @@ #include <mbgl/util/uv_detail.hpp> #include <mbgl/util/worker.hpp> #include <mbgl/util/texture_pool.hpp> -#include <mbgl/util/mapbox.hpp> #include <mbgl/util/exception.hpp> namespace mbgl { @@ -90,7 +89,7 @@ void MapContext::triggerUpdate(const Update u) { } void MapContext::setStyleURL(const std::string& url) { - styleURL = mbgl::util::mapbox::normalizeStyleURL(url, data.getAccessToken()); + styleURL = url; styleJSON.clear(); const size_t pos = styleURL.rfind('/'); @@ -99,7 +98,7 @@ void MapContext::setStyleURL(const std::string& url) { base = styleURL.substr(0, pos + 1); } - env.request({ Resource::Kind::JSON, styleURL }, [this, base](const Response &res) { + env.request({ Resource::Kind::Style, styleURL }, [this, base](const Response &res) { if (res.status == Response::Successful) { loadStyleJSON(res.data, base); } else { @@ -127,11 +126,9 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base) style->cascade(data.getClasses()); style->setDefaultTransitionDuration(data.getDefaultTransitionDuration()); - const std::string glyphURL = util::mapbox::normalizeGlyphsURL(style->glyph_url, data.getAccessToken()); - glyphStore->setURL(glyphURL); + glyphStore->setURL(style->glyph_url); resourceLoader = util::make_unique<ResourceLoader>(); - resourceLoader->setAccessToken(data.getAccessToken()); resourceLoader->setObserver(this); resourceLoader->setStyle(style.get()); resourceLoader->setGlyphStore(glyphStore.get()); diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp index 54114b9d0c..02519a0d38 100644 --- a/src/mbgl/map/map_data.hpp +++ b/src/mbgl/map/map_data.hpp @@ -27,15 +27,6 @@ public: setDefaultTransitionDuration(Duration::zero()); } - inline std::string getAccessToken() const { - Lock lock(mtx); - return accessToken; - } - inline void setAccessToken(const std::string &token) { - Lock lock(mtx); - accessToken = token; - } - // Adds the class if it's not yet set. Returns true when it added the class, and false when it // was already present. bool addClass(const std::string& klass); @@ -95,7 +86,6 @@ public: private: mutable std::mutex mtx; - std::string accessToken; std::vector<std::string> classes; std::atomic<uint8_t> debug { false }; std::atomic<bool> loaded { false }; diff --git a/src/mbgl/map/resource_loader.cpp b/src/mbgl/map/resource_loader.cpp index 5aa714595d..49c169d201 100644 --- a/src/mbgl/map/resource_loader.cpp +++ b/src/mbgl/map/resource_loader.cpp @@ -45,7 +45,7 @@ void ResourceLoader::setStyle(Style* style) { for (const auto& source : style->sources) { source->setObserver(this); - source->load(accessToken_); + source->load(); } } @@ -60,11 +60,6 @@ void ResourceLoader::setGlyphStore(GlyphStore* glyphStore) { glyphStore_->setObserver(this); } - -void ResourceLoader::setAccessToken(const std::string& accessToken) { - accessToken_ = accessToken; -} - void ResourceLoader::update(MapData& data, const TransformState& transform, GlyphAtlas& glyphAtlas, diff --git a/src/mbgl/map/resource_loader.hpp b/src/mbgl/map/resource_loader.hpp index 33949aa487..525e4653a0 100644 --- a/src/mbgl/map/resource_loader.hpp +++ b/src/mbgl/map/resource_loader.hpp @@ -49,9 +49,6 @@ public: // style. void setGlyphStore(GlyphStore* glyphStore); - // Set the access token to be used for loading the tile data. - void setAccessToken(const std::string& accessToken); - // Fetch the tiles needed by the current viewport and emit a signal when // a tile is ready so observers can render the tile. void update(MapData&, const TransformState&, GlyphAtlas&, SpriteAtlas&, TexturePool&); @@ -81,7 +78,6 @@ private: bool shouldReparsePartialTiles_ = false; - std::string accessToken_; util::ptr<Sprite> sprite_; GlyphStore* glyphStore_ = nullptr; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index b0c4e22f55..b35bdac33c 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -140,14 +140,13 @@ bool Source::isLoaded() const { // Note: This is a separate function that must be called exactly once after creation // The reason this isn't part of the constructor is that calling shared_from_this() in // the constructor fails. -void Source::load(const std::string& accessToken) { +void Source::load() { if (info.url.empty()) { loaded = true; return; } - const std::string url = util::mapbox::normalizeSourceURL(info.url, accessToken); - req = Environment::Get().request({ Resource::Kind::JSON, url }, [this](const Response &res) { + req = Environment::Get().request({ Resource::Kind::Source, info.url }, [this](const Response &res) { req = nullptr; if (res.status != Response::Successful) { diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp index 303d4d0245..d4c29b3e75 100644 --- a/src/mbgl/map/source.hpp +++ b/src/mbgl/map/source.hpp @@ -67,7 +67,7 @@ public: Source(); ~Source(); - void load(const std::string& accessToken); + void load(); bool isLoaded() const; void load(MapData&, Environment&, std::function<void()> callback); diff --git a/src/mbgl/storage/default_file_source.cpp b/src/mbgl/storage/default_file_source.cpp index e8831f5465..78a1132f17 100644 --- a/src/mbgl/storage/default_file_source.cpp +++ b/src/mbgl/storage/default_file_source.cpp @@ -5,11 +5,12 @@ #include <mbgl/storage/response.hpp> #include <mbgl/platform/platform.hpp> +#include <mbgl/platform/log.hpp> #include <mbgl/util/uv_detail.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/thread.hpp> -#include <mbgl/platform/log.hpp> +#include <mbgl/util/mapbox.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -38,7 +39,27 @@ Request* DefaultFileSource::request(const Resource& resource, uv_loop_t* l, Callback callback) { assert(l); - auto req = new Request(resource, l, std::move(callback)); + + std::string url; + + switch (resource.kind) { + case Resource::Kind::Style: + url = mbgl::util::mapbox::normalizeStyleURL(resource.url, accessToken); + break; + + case Resource::Kind::Source: + url = util::mapbox::normalizeSourceURL(resource.url, accessToken); + break; + + case Resource::Kind::Glyphs: + url = util::mapbox::normalizeGlyphsURL(resource.url, accessToken); + break; + + default: + url = resource.url; + } + + auto req = new Request({ resource.kind, url }, l, std::move(callback)); thread->invoke(&Impl::add, req); return req; } |