[core] move TileData and dependents to new *TileID classes

This commit is contained in:
Konstantin Käfer
2016-05-10 11:47:54 +02:00
parent bdcbceff80
commit ec70125e41
43 changed files with 181 additions and 155 deletions

View File

@@ -58,7 +58,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
EXPECT_EQ(1, flo->count(FixtureLog::Message(
EventSeverity::Error, Event::Style, -1,
std::string("Failed to load tile 0/0/0 for source mapbox: " + message))));
std::string("Failed to load tile 0/0/0=>0 for source mapbox: " + message))));
auto unchecked = flo->unchecked();
EXPECT_TRUE(unchecked.empty()) << unchecked;
}

View File

@@ -34,11 +34,12 @@ public:
if (sourceError) sourceError(source, error);
}
void onTileLoaded(Source& source, const TileID& tileID, bool isNewTile) override {
void onTileLoaded(Source& source, const OverscaledTileID& tileID, bool isNewTile) override {
if (tileLoaded) tileLoaded(source, tileID, isNewTile);
}
void onTileError(Source& source, const TileID& tileID, std::exception_ptr error) override {
void
onTileError(Source& source, const OverscaledTileID& tileID, std::exception_ptr error) override {
if (tileError) tileError(source, tileID, error);
}
@@ -56,8 +57,8 @@ public:
std::function<void (std::exception_ptr)> spriteError;
std::function<void (Source&)> sourceLoaded;
std::function<void (Source&, std::exception_ptr)> sourceError;
std::function<void (Source&, const TileID&, bool isNewTile)> tileLoaded;
std::function<void (Source&, const TileID&, std::exception_ptr)> tileError;
std::function<void (Source&, const OverscaledTileID&, bool isNewTile)> tileLoaded;
std::function<void (Source&, const OverscaledTileID&, std::exception_ptr)> tileError;
std::function<void ()> resourceLoaded;
std::function<void (std::exception_ptr)> resourceError;
};

View File

@@ -122,12 +122,12 @@ TEST(Source, RasterTileEmpty) {
return response;
};
test.observer.tileLoaded = [&] (Source& source, const TileID&, bool) {
test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, bool) {
EXPECT_EQ("source", source.id);
test.end();
};
test.observer.tileError = [&] (Source&, const TileID&, std::exception_ptr) {
test.observer.tileError = [&] (Source&, const OverscaledTileID&, std::exception_ptr) {
FAIL() << "Should never be called";
};
@@ -151,12 +151,12 @@ TEST(Source, VectorTileEmpty) {
return response;
};
test.observer.tileLoaded = [&] (Source& source, const TileID&, bool) {
test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, bool) {
EXPECT_EQ("source", source.id);
test.end();
};
test.observer.tileError = [&] (Source&, const TileID&, std::exception_ptr) {
test.observer.tileError = [&] (Source&, const OverscaledTileID&, std::exception_ptr) {
FAIL() << "Should never be called";
};
@@ -182,9 +182,9 @@ TEST(Source, RasterTileFail) {
return response;
};
test.observer.tileError = [&] (Source& source, const TileID& tileID, std::exception_ptr error) {
test.observer.tileError = [&] (Source& source, const OverscaledTileID& tileID, std::exception_ptr error) {
EXPECT_EQ(SourceType::Raster, source.type);
EXPECT_EQ("0/0/0", std::string(tileID));
EXPECT_EQ(OverscaledTileID(0, 0, 0), tileID);
EXPECT_EQ("Failed by the test case", util::toString(error));
test.end();
};
@@ -211,9 +211,9 @@ TEST(Source, VectorTileFail) {
return response;
};
test.observer.tileError = [&] (Source& source, const TileID& tileID, std::exception_ptr error) {
test.observer.tileError = [&] (Source& source, const OverscaledTileID& tileID, std::exception_ptr error) {
EXPECT_EQ(SourceType::Vector, source.type);
EXPECT_EQ("0/0/0", std::string(tileID));
EXPECT_EQ(OverscaledTileID(0, 0, 0), tileID);
EXPECT_EQ("Failed by the test case", util::toString(error));
test.end();
};
@@ -238,9 +238,9 @@ TEST(Source, RasterTileCorrupt) {
return response;
};
test.observer.tileError = [&] (Source& source, const TileID& tileID, std::exception_ptr error) {
test.observer.tileError = [&] (Source& source, const OverscaledTileID& tileID, std::exception_ptr error) {
EXPECT_EQ(source.type, SourceType::Raster);
EXPECT_EQ(std::string(tileID), "0/0/0");
EXPECT_EQ(OverscaledTileID(0, 0, 0), tileID);
EXPECT_TRUE(bool(error));
// Not asserting on platform-specific error text.
test.end();
@@ -266,9 +266,9 @@ TEST(Source, VectorTileCorrupt) {
return response;
};
test.observer.tileError = [&] (Source& source, const TileID& tileID, std::exception_ptr error) {
test.observer.tileError = [&] (Source& source, const OverscaledTileID& tileID, std::exception_ptr error) {
EXPECT_EQ(source.type, SourceType::Vector);
EXPECT_EQ(std::string(tileID), "0/0/0");
EXPECT_EQ(OverscaledTileID(0, 0, 0), tileID);
EXPECT_EQ(util::toString(error), "unknown pbf field type exception");
test.end();
};
@@ -298,11 +298,11 @@ TEST(Source, RasterTileCancel) {
return optional<Response>();
};
test.observer.tileLoaded = [&] (Source&, const TileID&, bool) {
test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, bool) {
FAIL() << "Should never be called";
};
test.observer.tileError = [&] (Source&, const TileID&, std::exception_ptr) {
test.observer.tileError = [&] (Source&, const OverscaledTileID&, std::exception_ptr) {
FAIL() << "Should never be called";
};
@@ -325,11 +325,11 @@ TEST(Source, VectorTileCancel) {
return optional<Response>();
};
test.observer.tileLoaded = [&] (Source&, const TileID&, bool) {
test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, bool) {
FAIL() << "Should never be called";
};
test.observer.tileError = [&] (Source&, const TileID&, std::exception_ptr) {
test.observer.tileError = [&] (Source&, const OverscaledTileID&, std::exception_ptr) {
FAIL() << "Should never be called";
};

View File

@@ -2,7 +2,7 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/map/tile_id.hpp>
#include <mbgl/tile/tile_id.hpp>
using namespace mbgl;
@@ -87,19 +87,19 @@ TEST(LatLngBounds, Northwest) {
TEST(LatLng, FromTileID) {
for (int i = 0; i < 20; i++) {
const LatLng ll{ TileID(i, 0, 0, 0) };
const LatLng ll{ CanonicalTileID(i, 0, 0) };
ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, ll.longitude);
ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude);
}
{
const LatLng ll{ TileID(0, 1, 0, 0) };
const LatLng ll{ UnwrappedTileID(0, 1, 0) };
ASSERT_DOUBLE_EQ(util::LONGITUDE_MAX, ll.longitude);
ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude);
}
{
const LatLng ll{ TileID(0, -1, 0, 0) };
const LatLng ll{ UnwrappedTileID(0, -1, 0) };
ASSERT_DOUBLE_EQ(-540, ll.longitude);
ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude);
}
@@ -135,7 +135,7 @@ TEST(LatLng, Boundaries) {
TEST(LatLngBounds, FromTileID) {
{
const LatLngBounds bounds{ TileID(0, 0, 0, 0) };
const LatLngBounds bounds{ CanonicalTileID(0, 0, 0) };
ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, bounds.west());
ASSERT_DOUBLE_EQ(-util::LATITUDE_MAX, bounds.south());
ASSERT_DOUBLE_EQ(util::LONGITUDE_MAX, bounds.east());
@@ -143,7 +143,7 @@ TEST(LatLngBounds, FromTileID) {
}
{
const LatLngBounds bounds{ TileID(1, 0, 1, 0) };
const LatLngBounds bounds{ CanonicalTileID(1, 0, 1) };
ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, bounds.west());
ASSERT_DOUBLE_EQ(-util::LATITUDE_MAX, bounds.south());
ASSERT_DOUBLE_EQ(0, bounds.east());
@@ -151,7 +151,7 @@ TEST(LatLngBounds, FromTileID) {
}
{
const LatLngBounds bounds{ TileID(1, 1, 1, 0) };
const LatLngBounds bounds{ CanonicalTileID(1, 1, 1) };
ASSERT_DOUBLE_EQ(0, bounds.west());
ASSERT_DOUBLE_EQ(-util::LATITUDE_MAX, bounds.south());
ASSERT_DOUBLE_EQ(util::LONGITUDE_MAX, bounds.east());
@@ -159,7 +159,7 @@ TEST(LatLngBounds, FromTileID) {
}
{
const LatLngBounds bounds{ TileID(1, 0, 0, 0) };
const LatLngBounds bounds{ CanonicalTileID(1, 0, 0) };
ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, bounds.west());
ASSERT_DOUBLE_EQ(0, bounds.south());
ASSERT_DOUBLE_EQ(0, bounds.east());