diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-20 19:25:38 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-21 14:25:12 -0800 |
commit | c3940cf08251f9fc9bfce4911e7b24f5985ae105 (patch) | |
tree | a9dcf038704f3b8f04667f9ba59b194b1c7eb151 /src | |
parent | 9e971095d3561f7af5b0016614035a8b4e479b81 (diff) | |
download | qtlocation-mapboxgl-c3940cf08251f9fc9bfce4911e7b24f5985ae105.tar.gz |
Eliminate Map::getFileSource
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.cpp | 4 | ||||
-rw-r--r-- | src/map/source.cpp | 16 | ||||
-rw-r--r-- | src/map/tile_data.cpp | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index 73867b2298..4ed1b6465d 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -607,7 +607,7 @@ void Map::updateSources() { if (style_source->enabled) { if (!style_source->source) { style_source->source = std::make_shared<Source>(style_source->info); - style_source->source->load(*this); + style_source->source->load(*this, *fileSource); } } else { style_source->source.reset(); @@ -642,7 +642,7 @@ void Map::updateSources(const util::ptr<StyleLayerGroup> &group) { void Map::updateTiles() { for (const util::ptr<StyleSource> &source : getActiveSources()) { - source->source->update(*this); + source->source->update(*this, *fileSource); } } diff --git a/src/map/source.cpp b/src/map/source.cpp index 9c0f7caf28..957afd6fd3 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -30,7 +30,7 @@ Source::Source(const util::ptr<SourceInfo>& info_) // 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(Map& map) { +void Source::load(Map& map, FileSource& fileSource) { if (info->url.empty()) { loaded = true; return; @@ -39,7 +39,7 @@ void Source::load(Map& map) { std::string url = util::mapbox::normalizeSourceURL(info->url, map.getAccessToken()); util::ptr<Source> source = shared_from_this(); - map.getFileSource()->request(ResourceType::JSON, url)->onload([source, &map](const Response &res) { + fileSource.request(ResourceType::JSON, url)->onload([source, &map](const Response &res) { if (res.code != 200) { Log::Warning(Event::General, "failed to load source TileJSON"); return; @@ -61,9 +61,9 @@ void Source::load(Map& map) { }); } -bool Source::update(Map &map) { +bool Source::update(Map& map, FileSource& fileSource) { if (loaded && map.getTime() > updated) { - return updateTiles(map); + return updateTiles(map, fileSource); } else { return false; } @@ -159,7 +159,7 @@ TileData::State Source::hasTile(const Tile::ID& id) { return TileData::State::invalid; } -TileData::State Source::addTile(Map &map, const Tile::ID& id) { +TileData::State Source::addTile(Map& map, FileSource& fileSource, const Tile::ID& id) { const TileData::State state = hasTile(id); if (state != TileData::State::invalid) { @@ -194,7 +194,7 @@ TileData::State Source::addTile(Map &map, const Tile::ID& id) { throw std::runtime_error("source type not implemented"); } - new_tile.data->request(); + new_tile.data->request(fileSource); tile_data.emplace(new_tile.data->id, new_tile.data); } @@ -281,7 +281,7 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std:: return false; } -bool Source::updateTiles(Map &map) { +bool Source::updateTiles(Map& map, FileSource& fileSource) { bool changed = false; int32_t zoom = std::floor(getZoom(map.getState())); @@ -298,7 +298,7 @@ bool Source::updateTiles(Map &map) { // Add existing child/parent tiles if the actual tile is not yet loaded for (const Tile::ID& id : required) { - const TileData::State state = addTile(map, id); + const TileData::State state = addTile(map, fileSource, id); if (state != TileData::State::parsed) { // The tile we require is not yet loaded. Try to find a parent or diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 44628e8b3e..9ff694bf3a 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -28,7 +28,7 @@ const std::string TileData::toString() const { return util::sprintf<32>("[tile %d/%d/%d]", id.z, id.x, id.y); } -void TileData::request() { +void TileData::request(FileSource& fileSource) { if (source->tiles.empty()) return; @@ -45,7 +45,7 @@ void TileData::request() { // Note: Somehow this feels slower than the change to request_http() std::weak_ptr<TileData> weak_tile = shared_from_this(); - req = map.getFileSource()->request(ResourceType::Tile, url); + req = fileSource.request(ResourceType::Tile, url); req->onload([weak_tile, url](const Response &res) { util::ptr<TileData> tile = weak_tile.lock(); if (!tile || tile->state == State::obsolete) { |