Reparse tiles when zoom level > source maxzoom

so that layout property functions are applied correctly
and so that label placement is redone

js:
https://github.com/mapbox/mapbox-gl-js/pull/1005
and
440bc02505
This commit is contained in:
Ansis Brammanis
2015-05-28 16:44:28 -04:00
parent 8962442b1b
commit 1e044a175c
23 changed files with 188 additions and 201 deletions

View File

@@ -125,7 +125,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
uint32_t y = p.y * z2;
for (int8_t z = maxZoom; z >= 0; z--) {
affectedTiles.emplace_back(z, x, y);
affectedTiles.emplace_back(z, x, y, z);
TileID tileID = affectedTiles.back();
// calculate tile coordinate
@@ -214,7 +214,7 @@ std::vector<TileID> AnnotationManager::removeAnnotations(const AnnotationIDs& id
p = projectPoint(latLng);
x = z2s[z] * p.x;
y = z2s[z] * p.y;
TileID tid(z, x, y);
TileID tid(z, x, y, z);
// erase annotation from tile's list
auto& tileAnnotations = tiles[tid].first;
tileAnnotations.erase(annotationID);
@@ -245,8 +245,8 @@ std::vector<uint32_t> AnnotationManager::getAnnotationsInBounds(const LatLngBoun
const vec2<double> nePoint = projectPoint(queryBounds.ne);
// tiles number y from top down
const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2);
const TileID seTile(z, nePoint.x * z2, swPoint.y * z2);
const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2, z);
const TileID seTile(z, nePoint.x * z2, swPoint.y * z2, z);
std::vector<uint32_t> matchingAnnotations;

View File

@@ -10,17 +10,17 @@ using namespace mbgl;
LiveTileData::LiveTileData(const TileID& id_,
AnnotationManager& annotationManager_,
float mapMaxZoom,
Style& style_,
GlyphAtlas& glyphAtlas_,
GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
util::ptr<Sprite> sprite_,
const SourceInfo& source_,
float overscaling_,
float angle_,
bool collisionDebug_)
: VectorTileData::VectorTileData(id_, mapMaxZoom, style_, glyphAtlas_, glyphStore_,
spriteAtlas_, sprite_, source_, angle_, collisionDebug_),
: VectorTileData::VectorTileData(id_, style_, glyphAtlas_, glyphStore_,
spriteAtlas_, sprite_, source_, overscaling_, angle_, collisionDebug_),
annotationManager(annotationManager_) {
// live features are always ready
setState(State::loaded);

View File

@@ -11,7 +11,6 @@ class LiveTileData : public VectorTileData {
public:
LiveTileData(const TileID&,
AnnotationManager&,
float mapMaxZoom,
Style&,
GlyphAtlas&,
GlyphStore&,
@@ -19,6 +18,7 @@ public:
util::ptr<Sprite>,
const SourceInfo&,
float,
float,
bool);
~LiveTileData();

View File

@@ -99,7 +99,7 @@ std::string SourceInfo::tileURL(const TileID& id, float pixelRatio) const {
std::string result = tiles.at((id.x + id.y) % tiles.size());
result = util::mapbox::normalizeTileURL(result, url, type);
result = util::replaceTokens(result, [&](const std::string &token) -> std::string {
if (token == "z") return util::toString(id.z);
if (token == "z") return util::toString(std::min(id.z, static_cast<int8_t>(max_zoom)));
if (token == "x") return util::toString(id.x);
if (token == "y") return util::toString(id.y);
if (token == "prefix") {
@@ -172,7 +172,7 @@ void Source::load(const std::string& accessToken) {
void Source::updateMatrices(const mat4 &projMatrix, const TransformState &transform) {
for (const auto& pair : tiles) {
Tile &tile = *pair.second;
transform.matrixFor(tile.matrix, tile.id);
transform.matrixFor(tile.matrix, tile.id, std::min(static_cast<int8_t>(info.max_zoom), tile.id.z));
matrix::multiply(tile.matrix, projMatrix, tile.matrix);
}
}
@@ -260,7 +260,8 @@ TileData::State Source::addTile(MapData& data,
return state;
}
auto pos = tiles.emplace(id, util::make_unique<Tile>(id));
const float overscaling = id.z > info.max_zoom ? std::pow(2.0f, id.z - info.max_zoom) : 1.0f;
auto pos = tiles.emplace(id, util::make_unique<Tile>(id));//, util::tileSize * overscaling));
Tile& new_tile = *pos.first->second;
// We couldn't find the tile in the list. Create a new one.
@@ -287,16 +288,18 @@ TileData::State Source::addTile(MapData& data,
// If we don't find working tile data, we're just going to load it.
if (info.type == SourceType::Vector) {
new_tile.data =
std::make_shared<VectorTileData>(normalized_id, data.transform.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info, transformState.getAngle(), data.getCollisionDebug());
std::make_shared<VectorTileData>(normalized_id, style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info,
overscaling, transformState.getAngle(), data.getCollisionDebug());
new_tile.data->request(style.workers, transformState.getPixelRatio(), callback);
} else if (info.type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info);
new_tile.data->request(style.workers, transformState.getPixelRatio(), callback);
} else if (info.type == SourceType::Annotations) {
new_tile.data = std::make_shared<LiveTileData>(normalized_id, data.annotationManager,
data.transform.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info, transformState.getAngle(), data.getCollisionDebug());
style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info,
overscaling, transformState.getAngle(), data.getCollisionDebug());
new_tile.data->reparse(style.workers, callback);
} else {
throw std::runtime_error("source type not implemented");
@@ -319,6 +322,11 @@ int32_t Source::coveringZoomLevel(const TransformState& state) const {
std::forward_list<TileID> Source::coveringTiles(const TransformState& state) const {
int32_t z = coveringZoomLevel(state);
auto actualZ = z;
const bool reparseOverscaled =
info.type == SourceType::Vector ||
info.type == SourceType::Annotations;
if (z < info.min_zoom) return {{}};
if (z > info.max_zoom) z = info.max_zoom;
@@ -326,7 +334,7 @@ std::forward_list<TileID> Source::coveringTiles(const TransformState& state) con
box points = state.cornersToBox(z);
const vec2<double>& center = points.center;
std::forward_list<TileID> covering_tiles = tileCover(z, points);
std::forward_list<TileID> covering_tiles = tileCover(z, points, reparseOverscaled ? actualZ : z);
covering_tiles.sort([&center](const TileID& a, const TileID& b) {
// Sorts by distance from the box center
@@ -349,7 +357,7 @@ std::forward_list<TileID> Source::coveringTiles(const TransformState& state) con
bool Source::findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std::forward_list<TileID>& retain) {
bool complete = true;
int32_t z = id.z;
auto ids = id.children(z + 1);
auto ids = id.children(info.max_zoom);
for (const auto& child_id : ids) {
const TileData::State state = hasTile(child_id);
if (TileData::isReadyState(state)) {
@@ -376,7 +384,7 @@ bool Source::findLoadedChildren(const TileID& id, int32_t maxCoveringZoom, std::
*/
bool Source::findLoadedParent(const TileID& id, int32_t minCoveringZoom, std::forward_list<TileID>& retain) {
for (int32_t z = id.z - 1; z >= minCoveringZoom; --z) {
const TileID parent_id = id.parent(z);
const TileID parent_id = id.parent(z, info.max_zoom);
const TileData::State state = hasTile(parent_id);
if (TileData::isReadyState(state)) {
retain.emplace_front(parent_id);

View File

@@ -5,35 +5,49 @@
namespace mbgl {
TileID TileID::parent(int8_t parent_z) const {
TileID TileID::parent(int8_t parent_z, int8_t sourceMaxZoom) const {
assert(parent_z < z);
int32_t dim = std::pow(2, z - parent_z);
return TileID{
parent_z,
(x >= 0 ? x : x - dim + 1) / dim,
y / dim
};
}
std::forward_list<TileID> TileID::children(int32_t child_z) const {
assert(child_z > z);
int32_t factor = std::pow(2, child_z - z);
std::forward_list<TileID> child_ids;
for (int32_t ty = y * factor, y_max = (y + 1) * factor; ty < y_max; ++ty) {
for (int32_t tx = x * factor, x_max = (x + 1) * factor; tx < x_max; ++tx) {
child_ids.emplace_front(child_z, tx, ty);
auto newX = x;
auto newY = y;
for (auto newZ = z; newZ > parent_z; newZ--) {
if (newZ > sourceMaxZoom) {
// the id represents an overscaled tile, return the same coordinates with a lower z
// do nothing
} else {
newX = newX / 2;
newY = newY / 2;
}
}
return TileID{parent_z, newX, newY, parent_z > sourceMaxZoom ? sourceMaxZoom : parent_z};
}
std::forward_list<TileID> TileID::children(int8_t sourceMaxZoom) const {
auto childZ = z + 1;
std::forward_list<TileID> child_ids;
if (z >= sourceMaxZoom) {
// return a single tile id representing a an overscaled tile
child_ids.emplace_front(childZ, x, y, sourceMaxZoom);
} else {
auto childX = x * 2;
auto childY = y * 2;
child_ids.emplace_front(childZ, childX, childY, childZ);
child_ids.emplace_front(childZ, childX + 1, childY, childZ);
child_ids.emplace_front(childZ, childX, childY + 1, childZ);
child_ids.emplace_front(childZ, childX + 1, childY + 1, childZ);
}
return child_ids;
}
TileID TileID::normalized() const {
int32_t dim = std::pow(2, z);
int32_t dim = std::pow(2, sourceZ);
int32_t nx = x, ny = y;
while (nx < 0) nx += dim;
while (nx >= dim) nx -= dim;
return TileID { z, nx, ny };
return TileID { z, nx, ny, sourceZ};
}
bool TileID::isChildOf(const TileID &parent_id) const {

View File

@@ -14,9 +14,12 @@ public:
const int16_t w = 0;
const int8_t z = 0;
const int32_t x = 0, y = 0;
const int8_t sourceZ;
const float overscaling;
inline explicit TileID(int8_t z_, int32_t x_, int32_t y_)
: w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_) {}
inline explicit TileID(int8_t z_, int32_t x_, int32_t y_, int8_t sourceZ_)
: w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_),
sourceZ(sourceZ_), overscaling(std::pow(2, z_ - sourceZ_)) {}
inline uint64_t to_uint64() const {
return ((std::pow(2, z) * y + x) * 32) + z;
@@ -43,11 +46,12 @@ public:
return y < rhs.y;
}
TileID parent(int8_t z) const;
TileID parent(int8_t z, int8_t sourceMaxZoom) const;
TileID normalized() const;
std::forward_list<TileID> children(int32_t z) const;
std::forward_list<TileID> children(int8_t sourceMaxZoom) const;
bool isChildOf(const TileID&) const;
operator std::string() const;
};
}

View File

@@ -180,7 +180,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const GeometryTileLayer& la
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const GeometryTileLayer& layer,
const StyleBucket& bucket_desc) {
auto bucket = util::make_unique<SymbolBucket>(*tile.getCollision());
auto bucket = util::make_unique<SymbolBucket>(*tile.getCollision(), tile.id.overscaling);
const float z = tile.id.z;
auto& layout = bucket->layout;

View File

@@ -8,8 +8,8 @@ using namespace mbgl;
#pragma mark - Matrix
void TransformState::matrixFor(mat4& matrix, const TileID& id) const {
const double tile_scale = std::pow(2, id.z);
void TransformState::matrixFor(mat4& matrix, const TileID& id, const int8_t z) const {
const double tile_scale = std::pow(2, z);
const double tile_size = scale * util::tileSize / tile_scale;
matrix::identity(matrix);

View File

@@ -20,7 +20,7 @@ class TransformState {
public:
// Matrix
void matrixFor(mat4& matrix, const TileID& id) const;
void matrixFor(mat4& matrix, const TileID& id, const int8_t z) const;
box cornersToBox(uint32_t z) const;
// Dimensions

View File

@@ -15,23 +15,23 @@
using namespace mbgl;
VectorTileData::VectorTileData(const TileID& id_,
float mapMaxZoom,
Style& style_,
GlyphAtlas& glyphAtlas_,
GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
util::ptr<Sprite> sprite_,
const SourceInfo& source_,
float overscaling_,
float angle,
bool collisionDebug)
: TileData(id_, source_),
depth(id_.z >= source_.max_zoom ? mapMaxZoom - id_.z : 1),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
style(style_),
collision(util::make_unique<CollisionTile>(id_.z, 4096, source_.tile_size, angle, collisionDebug)),
overscaling(overscaling_),
collision(util::make_unique<CollisionTile>(id_.z, 4096, source_.tile_size * id.overscaling, angle, collisionDebug)),
lastAngle(angle),
currentAngle(angle) {
}

View File

@@ -33,7 +33,6 @@ class VectorTileData : public TileData {
public:
VectorTileData(const TileID&,
float mapMaxZoom,
Style&,
GlyphAtlas&,
GlyphStore&,
@@ -41,6 +40,7 @@ public:
util::ptr<Sprite>,
const SourceInfo&,
float,
float,
bool);
~VectorTileData();
@@ -57,8 +57,6 @@ public:
return collision.get();
}
const float depth;
protected:
void redoPlacement();
@@ -85,6 +83,7 @@ private:
std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;
mutable std::mutex bucketsMutex;
const float overscaling;
std::unique_ptr<CollisionTile> collision;
float lastAngle = 0;

View File

@@ -470,7 +470,7 @@ mat4 Painter::translatedMatrix(const mat4& matrix, const std::array<float, 2> &t
return matrix;
} else {
// TODO: Get rid of the 8 (scaling from 4096 to tile size)
const double factor = ((double)(1 << id.z)) / state.getScale() * (4096.0 / util::tileSize);
const double factor = ((double)(1 << id.z)) / state.getScale() * (4096.0 / util::tileSize / id.overscaling);
mat4 vtxMatrix;
if (anchor == TranslateAnchorType::Viewport) {

View File

@@ -102,7 +102,6 @@ public:
void renderDebugFrame(const mat4 &matrix);
void renderDebugText(DebugBucket& bucket, const mat4 &matrix);
void renderDebugText(const std::vector<std::string> &strings);
void renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix);
void renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix);
void renderSymbol(SymbolBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix);

View File

@@ -67,41 +67,3 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
lineWidth(4.0f * state.getPixelRatio());
MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index()));
}
void Painter::renderDebugText(const std::vector<std::string> &strings) {
if (strings.empty()) {
return;
}
gl::debugging::group group("debug text");
config.depthTest = false;
config.stencilTest = true;
config.stencilFunc = { GL_ALWAYS, 0xFF, 0xFF };
useProgram(plainShader->program);
plainShader->u_matrix = nativeMatrix;
DebugFontBuffer debugFontBuffer;
int line = 25;
for (const auto& str : strings) {
debugFontBuffer.addText(str.c_str(), 10, line, 0.75);
line += 20;
}
if (!debugFontBuffer.empty()) {
// draw debug info
VertexArrayObject debugFontArray;
debugFontArray.bind(*plainShader, debugFontBuffer, BUFFER_OFFSET(0));
plainShader->u_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
lineWidth(4.0f * state.getPixelRatio());
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)debugFontBuffer.index()));
#ifndef GL_ES_VERSION_2_0
MBGL_CHECK_ERROR(glPointSize(2));
MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)debugFontBuffer.index()));
#endif
plainShader->u_color = {{ 0.0f, 0.0f, 0.0f, 1.0f }};
lineWidth(2.0f * state.getPixelRatio());
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)debugFontBuffer.index()));
}
}

View File

@@ -66,7 +66,7 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
const SpriteAtlasPosition posA = spriteAtlas.getPosition(properties.image.from, true);
const SpriteAtlasPosition posB = spriteAtlas.getPosition(properties.image.to, true);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) / id.overscaling;
mat3 patternMatrixA;
matrix::identity(patternMatrixA);

View File

@@ -70,7 +70,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
LinePatternPos posB = lineAtlas.getDashPosition(properties.dash_array.to, layout.cap == CapType::Round);
lineAtlas.bind();
float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0;
float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0 * id.overscaling;
float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.fromScale;
float scaleYA = -posA.height / 2.0;
float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.toScale;
@@ -90,7 +90,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
SpriteAtlasPosition imagePosA = spriteAtlas.getPosition(properties.image.from, true);
SpriteAtlasPosition imagePosB = spriteAtlas.getPosition(properties.image.to, true);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) * id.overscaling;
useProgram(linepatternShader->program);

View File

@@ -53,8 +53,8 @@ SymbolInstance::SymbolInstance(Anchor &anchor, const std::vector<Coordinate> &li
iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconAlongLine) {};
SymbolBucket::SymbolBucket(CollisionTile &collision_)
: collision(collision_) {
SymbolBucket::SymbolBucket(CollisionTile &collision_, float overscaling_)
: collision(collision_), overscaling(overscaling_) {
}
SymbolBucket::~SymbolBucket() {
@@ -297,7 +297,7 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
// Calculate the anchor points around which you want to place labels
Anchors anchors = layout.placement == PlacementType::Line ?
getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, glyphSize, textBoxScale, 1.0f) :
getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, glyphSize, textBoxScale, overscaling) :
Anchors({ Anchor(float(line[0].x), float(line[0].y), 0, minScale) });

View File

@@ -62,7 +62,7 @@ class SymbolBucket : public Bucket {
typedef ElementGroup<1> CollisionBoxElementGroup;
public:
SymbolBucket(CollisionTile &collision);
SymbolBucket(CollisionTile &collision, float overscaling);
~SymbolBucket() override;
void upload() override;
@@ -109,6 +109,7 @@ public:
private:
CollisionTile &collision;
const float overscaling;
std::vector<SymbolInstance> symbolInstances;
std::vector<SymbolFeature> features;

View File

@@ -65,7 +65,7 @@ static void scanTriangle(const mbgl::vec2<double> a, const mbgl::vec2<double> b,
if (bc.dy) scanSpans(ca, bc, ymin, ymax, scanLine);
}
std::forward_list<TileID> tileCover(int8_t z, const mbgl::box &bounds) {
std::forward_list<TileID> tileCover(int8_t z, const mbgl::box &bounds, int8_t actualZ) {
int32_t tiles = 1 << z;
std::forward_list<mbgl::TileID> t;
@@ -73,7 +73,7 @@ std::forward_list<TileID> tileCover(int8_t z, const mbgl::box &bounds) {
int32_t x;
if (y >= 0 && y <= tiles) {
for (x = x0; x < x1; x++) {
t.emplace_front(z, x, y);
t.emplace_front(actualZ, x, y, z);
}
}
};

View File

@@ -8,7 +8,7 @@
namespace mbgl {
std::forward_list<TileID> tileCover(int8_t z, const box& bounds);
std::forward_list<TileID> tileCover(int8_t z, const box& bounds, int8_t actualZ);
}

View File

@@ -30,11 +30,11 @@ template <typename T> void print(const T &sources) {
TEST(ClipIDs, ParentAndFourChildren) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 1, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1 }),
std::make_shared<Tile>(TileID { 0, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 0, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 0, 1, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 1, 1 }),
std::make_shared<Tile>(TileID { 0, 0, 0, 0 }),
},
};
@@ -51,11 +51,11 @@ TEST(ClipIDs, ParentAndFourChildren) {
TEST(ClipIDs, ParentAndFourChildrenNegative) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 1, -2, 0 }),
std::make_shared<Tile>(TileID { 1, -2, 1 }),
std::make_shared<Tile>(TileID { 1, -1, 0 }),
std::make_shared<Tile>(TileID { 1, -1, 1 }),
std::make_shared<Tile>(TileID { 0, -1, 0 }),
std::make_shared<Tile>(TileID { 1, -2, 0, 1 }),
std::make_shared<Tile>(TileID { 1, -2, 1, 1 }),
std::make_shared<Tile>(TileID { 1, -1, 0, 1 }),
std::make_shared<Tile>(TileID { 1, -1, 1, 1 }),
std::make_shared<Tile>(TileID { 0, -1, 0, 0 }),
},
};
@@ -72,11 +72,11 @@ TEST(ClipIDs, ParentAndFourChildrenNegative) {
TEST(ClipIDs, NegativeParentAndMissingLevel) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 1, -1, 0 }),
std::make_shared<Tile>(TileID { 2, -1, 0 }),
std::make_shared<Tile>(TileID { 2, -2, 1 }),
std::make_shared<Tile>(TileID { 2, -1, 1 }),
std::make_shared<Tile>(TileID { 2, -2, 0 }),
std::make_shared<Tile>(TileID { 1, -1, 0, 1 }),
std::make_shared<Tile>(TileID { 2, -1, 0, 2 }),
std::make_shared<Tile>(TileID { 2, -2, 1, 2 }),
std::make_shared<Tile>(TileID { 2, -1, 1, 2 }),
std::make_shared<Tile>(TileID { 2, -2, 0, 2 }),
},
};
@@ -94,13 +94,13 @@ TEST(ClipIDs, NegativeParentAndMissingLevel) {
TEST(ClipIDs, SevenOnSameLevel) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 2, 0, 0 }),
std::make_shared<Tile>(TileID { 2, 0, 1 }),
std::make_shared<Tile>(TileID { 2, 0, 2 }),
std::make_shared<Tile>(TileID { 2, 1, 0 }),
std::make_shared<Tile>(TileID { 2, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 2, 0 }),
std::make_shared<Tile>(TileID { 2, 0, 0, 2 }),
std::make_shared<Tile>(TileID { 2, 0, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 0, 2, 2 }),
std::make_shared<Tile>(TileID { 2, 1, 0, 2 }),
std::make_shared<Tile>(TileID { 2, 1, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 1, 2, 2 }),
std::make_shared<Tile>(TileID { 2, 2, 0, 2 }),
},
};
@@ -119,18 +119,18 @@ TEST(ClipIDs, SevenOnSameLevel) {
TEST(ClipIDs, MultipleLevels) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 2, 0, 0 }),
std::make_shared<Tile>(TileID { 3, 0, 0 }),
std::make_shared<Tile>(TileID { 3, 0, 1 }),
std::make_shared<Tile>(TileID { 4, 0, 2 }),
std::make_shared<Tile>(TileID { 4, 1, 2 }),
std::make_shared<Tile>(TileID { 4, 0, 3 }),
std::make_shared<Tile>(TileID { 4, 1, 3 }),
std::make_shared<Tile>(TileID { 3, 1, 0 }),
std::make_shared<Tile>(TileID { 3, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 0 }),
std::make_shared<Tile>(TileID { 3, 2, 0 }),
std::make_shared<Tile>(TileID { 3, 2, 1 }),
std::make_shared<Tile>(TileID { 2, 0, 0, 2 }),
std::make_shared<Tile>(TileID { 3, 0, 0, 3 }),
std::make_shared<Tile>(TileID { 3, 0, 1, 3 }),
std::make_shared<Tile>(TileID { 4, 0, 2, 4 }),
std::make_shared<Tile>(TileID { 4, 1, 2, 4 }),
std::make_shared<Tile>(TileID { 4, 0, 3, 4 }),
std::make_shared<Tile>(TileID { 4, 1, 3, 4 }),
std::make_shared<Tile>(TileID { 3, 1, 0, 3 }),
std::make_shared<Tile>(TileID { 3, 1, 1, 3 }),
std::make_shared<Tile>(TileID { 2, 1, 0, 2 }),
std::make_shared<Tile>(TileID { 3, 2, 0, 3 }),
std::make_shared<Tile>(TileID { 3, 2, 1, 3 }),
},
};
@@ -155,17 +155,17 @@ TEST(ClipIDs, MultipleLevels) {
TEST(ClipIDs, Bug206) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 10, 162, 395 }),
std::make_shared<Tile>(TileID { 10, 162, 396 }),
std::make_shared<Tile>(TileID { 10, 163, 395 }),
std::make_shared<Tile>(TileID { 11, 326, 791 }),
std::make_shared<Tile>(TileID { 12, 654, 1582 }),
std::make_shared<Tile>(TileID { 12, 654, 1583 }),
std::make_shared<Tile>(TileID { 12, 655, 1582 }),
std::make_shared<Tile>(TileID { 12, 655, 1583 }),
std::make_shared<Tile>(TileID { 10, 163, 396 }),
std::make_shared<Tile>(TileID { 10, 164, 395 }),
std::make_shared<Tile>(TileID { 10, 164, 396 }),
std::make_shared<Tile>(TileID { 10, 162, 395, 10 }),
std::make_shared<Tile>(TileID { 10, 162, 396, 10 }),
std::make_shared<Tile>(TileID { 10, 163, 395, 10 }),
std::make_shared<Tile>(TileID { 11, 326, 791, 10 }),
std::make_shared<Tile>(TileID { 12, 654, 1582, 10 }),
std::make_shared<Tile>(TileID { 12, 654, 1583, 10 }),
std::make_shared<Tile>(TileID { 12, 655, 1582, 10 }),
std::make_shared<Tile>(TileID { 12, 655, 1583, 10 }),
std::make_shared<Tile>(TileID { 10, 163, 396, 10 }),
std::make_shared<Tile>(TileID { 10, 164, 395, 10 }),
std::make_shared<Tile>(TileID { 10, 164, 396, 10 }),
},
};
@@ -189,23 +189,23 @@ TEST(ClipIDs, Bug206) {
TEST(ClipIDs, MultipleSources) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 0, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 2, 1 }),
std::make_shared<Tile>(TileID { 2, 2, 2 }),
std::make_shared<Tile>(TileID { 0, 0, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 2, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 2, 2, 2 }),
},
{
std::make_shared<Tile>(TileID { 0, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 2, 2 }),
std::make_shared<Tile>(TileID { 0, 0, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 2, 2, 2 }),
},
{
std::make_shared<Tile>(TileID { 1, 0, 0 }),
std::make_shared<Tile>(TileID { 1, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 0 }),
std::make_shared<Tile>(TileID { 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 1 }),
std::make_shared<Tile>(TileID { 1, 0, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 0, 1, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 0, 1 }),
std::make_shared<Tile>(TileID { 1, 1, 1, 1 }),
std::make_shared<Tile>(TileID { 2, 1, 1, 2 }),
},
};
@@ -231,13 +231,13 @@ TEST(ClipIDs, MultipleSources) {
TEST(ClipIDs, DuplicateIDs) {
const std::vector<std::vector<std::shared_ptr<Tile>>> sources = {
{
std::make_shared<Tile>(TileID { 2, 0, 0 }),
std::make_shared<Tile>(TileID { 2, 0, 1 }),
std::make_shared<Tile>(TileID { 2, 0, 0, 2 }),
std::make_shared<Tile>(TileID { 2, 0, 1, 2 }),
},
{
std::make_shared<Tile>(TileID { 2, 0, 0 }),
std::make_shared<Tile>(TileID { 2, 0, 1 }),
std::make_shared<Tile>(TileID { 2, 0, 1 }),
std::make_shared<Tile>(TileID { 2, 0, 0, 2 }),
std::make_shared<Tile>(TileID { 2, 0, 1, 2 }),
std::make_shared<Tile>(TileID { 2, 0, 1, 2 }),
}
};

View File

@@ -7,44 +7,44 @@ using namespace mbgl;
TEST(Variant, isChild) {
ASSERT_TRUE(TileID(1, 0, 0).isChildOf(TileID(0, 0, 0)));
ASSERT_TRUE(TileID(1, 1, 0).isChildOf(TileID(0, 0, 0)));
ASSERT_TRUE(TileID(1, 2, 0).isChildOf(TileID(0, 1, 0)));
ASSERT_TRUE(TileID(1, 3, 0).isChildOf(TileID(0, 1, 0)));
ASSERT_TRUE(TileID(1, 4, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(1, 5, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(2, 0, 0).isChildOf(TileID(0, 0, 0)));
ASSERT_TRUE(TileID(1, 0, 0, 1).isChildOf(TileID(0, 0, 0, 0)));
ASSERT_TRUE(TileID(1, 1, 0, 1).isChildOf(TileID(0, 0, 0, 0)));
ASSERT_TRUE(TileID(1, 2, 0, 1).isChildOf(TileID(0, 1, 0, 0)));
ASSERT_TRUE(TileID(1, 3, 0, 1).isChildOf(TileID(0, 1, 0, 0)));
ASSERT_TRUE(TileID(1, 4, 0, 1).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(1, 5, 0, 1).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(2, 0, 0, 2).isChildOf(TileID(0, 0, 0, 0)));
ASSERT_TRUE(TileID(2, 8, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(2, 9, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(2, 10, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(2, 11, 0).isChildOf(TileID(0, 2, 0)));
ASSERT_TRUE(TileID(2, 12, 0).isChildOf(TileID(0, 3, 0)));
ASSERT_TRUE(TileID(2, 13, 0).isChildOf(TileID(0, 3, 0)));
ASSERT_TRUE(TileID(2, 8, 0, 2).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(2, 9, 0, 2).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(2, 10, 0, 2).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(2, 11, 0, 2).isChildOf(TileID(0, 2, 0, 0)));
ASSERT_TRUE(TileID(2, 12, 0, 2).isChildOf(TileID(0, 3, 0, 0)));
ASSERT_TRUE(TileID(2, 13, 0, 2).isChildOf(TileID(0, 3, 0, 0)));
ASSERT_TRUE(TileID(1, -1, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(1, -2, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(1, -3, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(1, -4, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(2, -1, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(2, -2, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(2, -3, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(2, -4, 0).isChildOf(TileID(0, -1, 0)));
ASSERT_TRUE(TileID(2, -5, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(2, -6, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(2, -7, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(2, -8, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(1, -1, 0, 1).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(1, -2, 0, 1).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(1, -3, 0, 1).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(1, -4, 0, 1).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(2, -1, 0, 2).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(2, -2, 0, 2).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(2, -3, 0, 2).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(2, -4, 0, 2).isChildOf(TileID(0, -1, 0, 0)));
ASSERT_TRUE(TileID(2, -5, 0, 2).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(2, -6, 0, 2).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(2, -7, 0, 2).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(2, -8, 0, 2).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_FALSE(TileID(4, -16, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_TRUE(TileID(4, -17, 0).isChildOf(TileID(0, -2, 0)));
ASSERT_FALSE(TileID(4, -16, 0, 4).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(4, -17, 0, 4).isChildOf(TileID(0, -2, 0, 0)));
ASSERT_TRUE(TileID(2, -1, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(2, -2, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(2, -3, 0).isChildOf(TileID(1, -2, 0)));
ASSERT_TRUE(TileID(2, -4, 0).isChildOf(TileID(1, -2, 0)));
ASSERT_TRUE(TileID(3, -1, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(3, -2, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(3, -3, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(3, -4, 0).isChildOf(TileID(1, -1, 0)));
ASSERT_TRUE(TileID(3, -5, 0).isChildOf(TileID(1, -2, 0)));
ASSERT_TRUE(TileID(2, -1, 0, 2).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(2, -2, 0, 2).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(2, -3, 0, 2).isChildOf(TileID(1, -2, 0, 1)));
ASSERT_TRUE(TileID(2, -4, 0, 2).isChildOf(TileID(1, -2, 0, 1)));
ASSERT_TRUE(TileID(3, -1, 0, 3).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(3, -2, 0, 3).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(3, -3, 0, 3).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(3, -4, 0, 3).isChildOf(TileID(1, -1, 0, 1)));
ASSERT_TRUE(TileID(3, -5, 0, 3).isChildOf(TileID(1, -2, 0, 1)));
}

Submodule test/suite deleted from d4fb344525

1
test/suite Symbolic link
View File

@@ -0,0 +1 @@
../../test-suite/