summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-07-17 15:52:39 -0700
committerKonstantin Käfer <mail@kkaefer.com>2014-07-17 15:52:39 -0700
commit9ed0ca59832ed59ea8f391a8e1db1c6b9406b453 (patch)
treef9360ef8da3fc9c015eaf6e773be13e64f8b10ac /src/map
parent3141b8b1f744f414da28d73a1a695e113a3d06f2 (diff)
downloadqtlocation-mapboxgl-9ed0ca59832ed59ea8f391a8e1db1c6b9406b453.tar.gz
pass SourceInfo object to TileData so that we can not skip buckets that appear later than the source maxzoom
Diffstat (limited to 'src/map')
-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
5 files changed, 19 insertions, 21 deletions
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;