pass SourceInfo object to TileData so that we can not skip buckets that appear later than the source maxzoom
This commit is contained in:
@@ -12,7 +12,7 @@ class RasterTileData : public TileData {
|
||||
friend class TileParser;
|
||||
|
||||
public:
|
||||
RasterTileData(Tile::ID id, Map &map, const std::string url);
|
||||
RasterTileData(Tile::ID id, Map &map, const SourceInfo &source);
|
||||
~RasterTileData();
|
||||
|
||||
virtual void parse();
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace mbgl {
|
||||
class Map;
|
||||
class Painter;
|
||||
class StyleLayer;
|
||||
class SourceInfo;
|
||||
|
||||
class TileData : public std::enable_shared_from_this<TileData>,
|
||||
private util::noncopyable {
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
TileData(Tile::ID id, Map &map, const std::string url);
|
||||
TileData(Tile::ID id, Map &map, const SourceInfo &source);
|
||||
~TileData();
|
||||
|
||||
void request();
|
||||
@@ -60,8 +61,13 @@ public:
|
||||
protected:
|
||||
Map ↦
|
||||
|
||||
public:
|
||||
const SourceInfo &source;
|
||||
|
||||
// Request-related information.
|
||||
const std::string url;
|
||||
|
||||
protected:
|
||||
std::weak_ptr<platform::Request> req;
|
||||
std::string data;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class VectorTileData : public TileData {
|
||||
friend class TileParser;
|
||||
|
||||
public:
|
||||
VectorTileData(Tile::ID id, Map &map, const std::string url);
|
||||
VectorTileData(Tile::ID id, Map &map, const SourceInfo &source);
|
||||
~VectorTileData();
|
||||
|
||||
virtual void beforeParse();
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
RasterTileData::RasterTileData(Tile::ID id, Map &map, const std::string url)
|
||||
: TileData(id, map, url),
|
||||
RasterTileData::RasterTileData(Tile::ID id, Map &map, const SourceInfo &source)
|
||||
: TileData(id, map, source),
|
||||
bucket(map.getTexturepool()) {
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/util/token.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/geometry/glyph_atlas.hpp>
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
@@ -146,18 +145,10 @@ TileData::State Source::addTile(Map &map, const Tile::ID& id) {
|
||||
|
||||
if (!new_tile.data) {
|
||||
// If we don't find working tile data, we're just going to load it.
|
||||
const std::string formed_url = util::replaceTokens(info.url, [&](const std::string &token) -> std::string {
|
||||
if (token == "z") return std::to_string(normalized_id.z);
|
||||
if (token == "x") return std::to_string(normalized_id.x);
|
||||
if (token == "y") return std::to_string(normalized_id.y);
|
||||
if (token == "ratio") return (map.getState().getPixelRatio() > 1.0 ? "@2x" : "");
|
||||
return "";
|
||||
});
|
||||
|
||||
if (info.type == SourceType::Vector) {
|
||||
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, formed_url);
|
||||
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, info);
|
||||
} else if (info.type == SourceType::Raster) {
|
||||
new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, formed_url);
|
||||
new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, info);
|
||||
} else {
|
||||
throw std::runtime_error("source type not implemented");
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
#include <mbgl/map/tile_data.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
|
||||
#include <mbgl/util/token.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TileData::TileData(Tile::ID id, Map &map, const std::string url)
|
||||
TileData::TileData(Tile::ID id, Map &map, const SourceInfo &source)
|
||||
: id(id),
|
||||
state(State::initial),
|
||||
map(map),
|
||||
url(url),
|
||||
source(source),
|
||||
url(util::replaceTokens(source.url, [&](const std::string &token) -> std::string {
|
||||
if (token == "z") return std::to_string(id.z);
|
||||
if (token == "x") return std::to_string(id.x);
|
||||
if (token == "y") return std::to_string(id.y);
|
||||
if (token == "ratio") return (map.getState().getPixelRatio() > 1.0 ? "@2x" : "");
|
||||
return "";
|
||||
})),
|
||||
debugBucket(debugFontBuffer) {
|
||||
// Initialize tile debug coordinates
|
||||
const std::string str = util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y);
|
||||
|
||||
@@ -109,9 +109,8 @@ std::unique_ptr<Bucket> TileParser::createBucket(std::shared_ptr<StyleBucket> bu
|
||||
}
|
||||
|
||||
// Skip this bucket if we are to not render this
|
||||
if (tile.id.z < bucket_desc->min_zoom || tile.id.z > bucket_desc->max_zoom) {
|
||||
return nullptr;
|
||||
}
|
||||
if (tile.id.z < bucket_desc->min_zoom && bucket_desc->min_zoom < tile.source.max_zoom) return nullptr;
|
||||
if (tile.id.z >= bucket_desc->max_zoom) return nullptr;
|
||||
|
||||
auto layer_it = vector_data.layers.find(bucket_desc->source_layer);
|
||||
if (layer_it != vector_data.layers.end()) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
VectorTileData::VectorTileData(Tile::ID id, Map &map, const std::string url)
|
||||
: TileData(id, map, url) {
|
||||
VectorTileData::VectorTileData(Tile::ID id, Map &map, const SourceInfo &source)
|
||||
: TileData(id, map, source) {
|
||||
}
|
||||
|
||||
VectorTileData::~VectorTileData() {
|
||||
@@ -63,7 +63,7 @@ bool VectorTileData::hasData(std::shared_ptr<StyleLayer> layer_desc) const {
|
||||
auto databucket_it = buckets.find(layer_desc->bucket->name);
|
||||
if (databucket_it != buckets.end()) {
|
||||
assert(databucket_it->second);
|
||||
return databucket_it->second->hasData();
|
||||
return databucket_it->second->hasData();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user