summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/map/raster_tile_data.hpp2
-rw-r--r--include/mbgl/map/tile_data.hpp8
-rw-r--r--include/mbgl/map/vector_tile_data.hpp2
-rw-r--r--src/map/raster_tile_data.cpp4
-rw-r--r--src/map/source.cpp13
-rw-r--r--src/map/tile_data.cpp12
-rw-r--r--src/map/tile_parser.cpp5
-rw-r--r--src/map/vector_tile_data.cpp6
8 files changed, 28 insertions, 24 deletions
diff --git a/include/mbgl/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp
index 976faa91bc..23f0979727 100644
--- a/include/mbgl/map/raster_tile_data.hpp
+++ b/include/mbgl/map/raster_tile_data.hpp
@@ -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();
diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp
index a4b73c339f..416a29d2a5 100644
--- a/include/mbgl/map/tile_data.hpp
+++ b/include/mbgl/map/tile_data.hpp
@@ -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 &map;
+public:
+ const SourceInfo &source;
+
// Request-related information.
const std::string url;
+
+protected:
std::weak_ptr<platform::Request> req;
std::string data;
diff --git a/include/mbgl/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp
index dd55e8dae1..dc67b92512 100644
--- a/include/mbgl/map/vector_tile_data.hpp
+++ b/include/mbgl/map/vector_tile_data.hpp
@@ -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();
diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp
index ef6bea7e62..26c122da6c 100644
--- a/src/map/raster_tile_data.cpp
+++ b/src/map/raster_tile_data.cpp
@@ -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()) {
}
diff --git a/src/map/source.cpp b/src/map/source.cpp
index b885ee7645..f9e34d926d 100644
--- a/src/map/source.cpp
+++ b/src/map/source.cpp
@@ -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");
}
diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp
index 82f8fdedfc..556a2e6079 100644
--- a/src/map/tile_data.cpp
+++ b/src/map/tile_data.cpp
@@ -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);
diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp
index a580e0a787..03a884e436 100644
--- a/src/map/tile_parser.cpp
+++ b/src/map/tile_parser.cpp
@@ -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()) {
diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp
index 7d0e0fb5a8..f1f065d580 100644
--- a/src/map/vector_tile_data.cpp
+++ b/src/map/vector_tile_data.cpp
@@ -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;