[core] move TileData and dependents to new *TileID classes
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class TileID;
|
||||
class CanonicalTileID;
|
||||
class UnwrappedTileID;
|
||||
|
||||
using ScreenCoordinate = mapbox::geometry::point<double>;
|
||||
|
||||
@@ -49,7 +50,8 @@ public:
|
||||
}
|
||||
|
||||
// Constructs a LatLng object with the top left position of the specified tile.
|
||||
LatLng(const TileID& id);
|
||||
LatLng(const CanonicalTileID& id);
|
||||
LatLng(const UnwrappedTileID& id);
|
||||
};
|
||||
|
||||
inline bool operator==(const LatLng& a, const LatLng& b) {
|
||||
@@ -100,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
// Constructs a LatLngBounds object with the tile's exact boundaries.
|
||||
LatLngBounds(const TileID&);
|
||||
LatLngBounds(const CanonicalTileID&);
|
||||
|
||||
double south() const { return sw.latitude; }
|
||||
double west() const { return sw.longitude; }
|
||||
|
||||
@@ -81,7 +81,7 @@ AnnotationIDs AnnotationManager::getPointAnnotationsInBounds(const LatLngBounds&
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<AnnotationTile> AnnotationManager::getTile(const TileID& tileID) {
|
||||
std::unique_ptr<AnnotationTile> AnnotationManager::getTile(const CanonicalTileID& tileID) {
|
||||
if (pointAnnotations.empty() && shapeAnnotations.empty())
|
||||
return nullptr;
|
||||
|
||||
@@ -136,13 +136,13 @@ void AnnotationManager::updateStyle(Style& style) {
|
||||
obsoleteShapeAnnotationLayers.clear();
|
||||
|
||||
for (auto& monitor : monitors) {
|
||||
monitor->update(getTile(monitor->tileID));
|
||||
monitor->update(getTile(monitor->tileID.canonical));
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotationManager::addTileMonitor(AnnotationTileMonitor& monitor) {
|
||||
monitors.insert(&monitor);
|
||||
monitor.update(getTile(monitor.tileID));
|
||||
monitor.update(getTile(monitor.tileID.canonical));
|
||||
}
|
||||
|
||||
void AnnotationManager::removeTileMonitor(AnnotationTileMonitor& monitor) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
static const std::string PointLayerID;
|
||||
|
||||
private:
|
||||
std::unique_ptr<AnnotationTile> getTile(const TileID&);
|
||||
std::unique_ptr<AnnotationTile> getTile(const CanonicalTileID&);
|
||||
|
||||
AnnotationID nextID = 0;
|
||||
PointAnnotationImpl::Tree pointTree;
|
||||
|
||||
@@ -29,7 +29,7 @@ util::ptr<GeometryTileLayer> AnnotationTile::getLayer(const std::string& name) c
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AnnotationTileMonitor::AnnotationTileMonitor(const TileID& tileID_, AnnotationManager& annotationManager_)
|
||||
AnnotationTileMonitor::AnnotationTileMonitor(const OverscaledTileID& tileID_, AnnotationManager& annotationManager_)
|
||||
: tileID(tileID_),
|
||||
annotationManager(annotationManager_) {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define MBGL_ANNOTATION_TILE
|
||||
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
@@ -43,13 +43,13 @@ class AnnotationManager;
|
||||
|
||||
class AnnotationTileMonitor : public GeometryTileMonitor {
|
||||
public:
|
||||
AnnotationTileMonitor(const TileID&, AnnotationManager&);
|
||||
AnnotationTileMonitor(const OverscaledTileID&, AnnotationManager&);
|
||||
~AnnotationTileMonitor();
|
||||
|
||||
void update(std::unique_ptr<GeometryTile>);
|
||||
std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
|
||||
|
||||
TileID tileID;
|
||||
OverscaledTileID tileID;
|
||||
|
||||
private:
|
||||
AnnotationManager& annotationManager;
|
||||
|
||||
@@ -9,7 +9,7 @@ PointAnnotationImpl::PointAnnotationImpl(const AnnotationID id_, const PointAnno
|
||||
point(point_) {
|
||||
}
|
||||
|
||||
void PointAnnotationImpl::updateLayer(const TileID& tileID, AnnotationTileLayer& layer) const {
|
||||
void PointAnnotationImpl::updateLayer(const CanonicalTileID& tileID, AnnotationTileLayer& layer) const {
|
||||
std::unordered_map<std::string, std::string> featureProperties;
|
||||
featureProperties.emplace("sprite", point.icon.empty() ? std::string("default_marker") : point.icon);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ BOOST_GEOMETRY_REGISTER_BOX(mbgl::LatLngBounds, mbgl::LatLng, southwest(), north
|
||||
namespace mbgl {
|
||||
|
||||
class AnnotationTileLayer;
|
||||
class CanonicalTileID;
|
||||
|
||||
class PointAnnotationImpl {
|
||||
public:
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
|
||||
PointAnnotationImpl(const AnnotationID, const PointAnnotation&);
|
||||
|
||||
void updateLayer(const TileID&, AnnotationTileLayer&) const;
|
||||
void updateLayer(const CanonicalTileID&, AnnotationTileLayer&) const;
|
||||
|
||||
const AnnotationID id;
|
||||
const PointAnnotation point;
|
||||
|
||||
@@ -80,7 +80,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) {
|
||||
void ShapeAnnotationImpl::updateTile(const CanonicalTileID& tileID, AnnotationTile& tile) {
|
||||
static const double baseTolerance = 4;
|
||||
|
||||
if (!shapeTiler) {
|
||||
@@ -114,7 +114,7 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile)
|
||||
shapeTiler = std::make_unique<mapbox::geojsonvt::GeoJSONVT>(features, options);
|
||||
}
|
||||
|
||||
const auto& shapeTile = shapeTiler->getTile(tileID.sourceZ, tileID.x, tileID.y);
|
||||
const auto& shapeTile = shapeTiler->getTile(tileID.z, tileID.x, tileID.y);
|
||||
if (!shapeTile)
|
||||
return;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace mbgl {
|
||||
|
||||
class Style;
|
||||
class AnnotationTile;
|
||||
class CanonicalTileID;
|
||||
|
||||
class ShapeAnnotationImpl {
|
||||
public:
|
||||
@@ -23,7 +24,7 @@ public:
|
||||
ShapeAnnotationImpl(const AnnotationID, const ShapeAnnotation&, const uint8_t maxZoom);
|
||||
|
||||
void updateStyle(Style&);
|
||||
void updateTile(const TileID&, AnnotationTile&);
|
||||
void updateTile(const CanonicalTileID&, AnnotationTile&);
|
||||
|
||||
const AnnotationID id;
|
||||
const std::string layerID;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/layer/line_layer.hpp>
|
||||
#include <mbgl/style/style_bucket_parameters.hpp>
|
||||
#include <mbgl/renderer/line_bucket.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/util/get_geometries.hpp>
|
||||
#include <mbgl/geometry/feature_index.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
@@ -77,7 +76,7 @@ std::unique_ptr<Bucket> LineLayer::createBucket(StyleBucketParameters& parameter
|
||||
|
||||
bucket->layout = layout;
|
||||
|
||||
StyleCalculationParameters p(parameters.tileID.z);
|
||||
StyleCalculationParameters p(parameters.tileID.overscaledZ);
|
||||
bucket->layout.lineCap.calculate(p);
|
||||
bucket->layout.lineJoin.calculate(p);
|
||||
bucket->layout.lineMiterLimit.calculate(p);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/layer/symbol_layer.hpp>
|
||||
#include <mbgl/renderer/symbol_bucket.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/style/style_bucket_parameters.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -115,14 +114,14 @@ bool SymbolLayer::recalculate(const StyleCalculationParameters& parameters) {
|
||||
|
||||
std::unique_ptr<Bucket> SymbolLayer::createBucket(StyleBucketParameters& parameters) const {
|
||||
auto bucket = std::make_unique<SymbolBucket>(parameters.tileID.overscaleFactor(),
|
||||
parameters.tileID.z,
|
||||
parameters.tileID.overscaledZ,
|
||||
parameters.mode,
|
||||
id,
|
||||
parameters.layer.getName());
|
||||
|
||||
bucket->layout = layout;
|
||||
|
||||
StyleCalculationParameters p(parameters.tileID.z);
|
||||
StyleCalculationParameters p(parameters.tileID.overscaledZ);
|
||||
bucket->layout.symbolPlacement.calculate(p);
|
||||
if (bucket->layout.symbolPlacement.value == SymbolPlacementType::Line) {
|
||||
bucket->layout.iconRotationAlignment.value = RotationAlignmentType::Map;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <mbgl/renderer/debug_bucket.hpp>
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/shader/plain_shader.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
|
||||
@@ -9,14 +10,14 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
DebugBucket::DebugBucket(const TileID id, const TileData::State state_, optional<SystemTimePoint> modified_, optional<SystemTimePoint> expires_, MapDebugOptions debugMode_)
|
||||
DebugBucket::DebugBucket(const OverscaledTileID& id, const TileData::State state_, optional<SystemTimePoint> modified_, optional<SystemTimePoint> expires_, MapDebugOptions debugMode_)
|
||||
: state(state_),
|
||||
modified(std::move(modified_)),
|
||||
expires(std::move(expires_)),
|
||||
debugMode(debugMode_) {
|
||||
double baseline = 200;
|
||||
if (debugMode & MapDebugOptions::ParseStatus) {
|
||||
const std::string text = std::string(id) + " - " + TileData::StateToString(state);
|
||||
const std::string text = util::toString(id) + " - " + TileData::StateToString(state);
|
||||
fontBuffer.addText(text.c_str(), 50, baseline, 5);
|
||||
baseline += 200;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class GLObjectStore;
|
||||
|
||||
class DebugBucket : private util::noncopyable {
|
||||
public:
|
||||
DebugBucket(TileID id, TileData::State,
|
||||
DebugBucket(const OverscaledTileID& id, TileData::State,
|
||||
optional<SystemTimePoint> modified,
|
||||
optional<SystemTimePoint> expires,
|
||||
MapDebugOptions);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
|
||||
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/mat3.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
#if defined(DEBUG)
|
||||
#include <mbgl/util/stopwatch.hpp>
|
||||
@@ -252,7 +254,7 @@ void Painter::renderPass(RenderPass pass_,
|
||||
config.setDirty();
|
||||
} else {
|
||||
assert(item.tile->data);
|
||||
MBGL_DEBUG_GROUP(layer.id + " - " + std::string(item.tile->data->id));
|
||||
MBGL_DEBUG_GROUP(layer.id + " - " + util::toString(item.tile->id));
|
||||
if (item.bucket->needsClipping()) {
|
||||
setClipping(item.tile->clip);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <mbgl/layer/circle_layer.hpp>
|
||||
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
|
||||
#include <mbgl/shader/circle_shader.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/renderer/fill_bucket.hpp>
|
||||
#include <mbgl/layer/fill_layer.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/sprite/sprite_atlas.hpp>
|
||||
#include <mbgl/shader/outline_shader.hpp>
|
||||
#include <mbgl/shader/outlinepattern_shader.hpp>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
#include <mbgl/renderer/line_bucket.hpp>
|
||||
#include <mbgl/layer/line_layer.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/shader/line_shader.hpp>
|
||||
#include <mbgl/shader/linesdf_shader.hpp>
|
||||
#include <mbgl/shader/linepattern_shader.hpp>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <mbgl/shader/sdf_shader.hpp>
|
||||
#include <mbgl/shader/icon_shader.hpp>
|
||||
#include <mbgl/shader/box_shader.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -203,7 +203,11 @@ TileData::State Source::hasTile(const TileID& tileID) {
|
||||
}
|
||||
|
||||
bool Source::handlePartialTile(const TileID& tileID) {
|
||||
auto it = tileDataMap.find(tileID.normalized());
|
||||
const OverscaledTileID overscaledTileID{
|
||||
tileID.z, UnwrappedTileID{ tileID.sourceZ, tileID.x, tileID.y }.canonical
|
||||
};
|
||||
|
||||
auto it = tileDataMap.find(overscaledTileID);
|
||||
if (it == tileDataMap.end()) {
|
||||
return true;
|
||||
}
|
||||
@@ -213,7 +217,7 @@ bool Source::handlePartialTile(const TileID& tileID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto callback = std::bind(&Source::tileLoadingCallback, this, tileID,
|
||||
auto callback = std::bind(&Source::tileLoadingCallback, this, overscaledTileID,
|
||||
std::placeholders::_1, false);
|
||||
|
||||
return tileData->parsePending(callback);
|
||||
@@ -230,9 +234,9 @@ TileData::State Source::addTile(const TileID& tileID, const StyleUpdateParameter
|
||||
|
||||
// We couldn't find the tile in the list. Create a new one.
|
||||
// Try to find the associated TileData object.
|
||||
const TileID normalizedID = tileID.normalized();
|
||||
const OverscaledTileID overscaledTileID{ tileID.z, newTile->id.canonical };
|
||||
|
||||
auto it = tileDataMap.find(normalizedID);
|
||||
auto it = tileDataMap.find(overscaledTileID);
|
||||
if (it != tileDataMap.end()) {
|
||||
// Create a shared_ptr handle. Note that this might be empty!
|
||||
newTile->data = it->second.lock();
|
||||
@@ -244,16 +248,16 @@ TileData::State Source::addTile(const TileID& tileID, const StyleUpdateParameter
|
||||
}
|
||||
|
||||
if (!newTile->data) {
|
||||
newTile->data = cache.get(normalizedID.to_uint64());
|
||||
newTile->data = cache.get(overscaledTileID);
|
||||
}
|
||||
|
||||
if (!newTile->data) {
|
||||
auto callback = std::bind(&Source::tileLoadingCallback, this, normalizedID,
|
||||
auto callback = std::bind(&Source::tileLoadingCallback, this, overscaledTileID,
|
||||
std::placeholders::_1, true);
|
||||
|
||||
// If we don't find working tile data, we're just going to load it.
|
||||
if (type == SourceType::Raster) {
|
||||
newTile->data = std::make_shared<RasterTileData>(normalizedID,
|
||||
newTile->data = std::make_shared<RasterTileData>(overscaledTileID,
|
||||
parameters.pixelRatio,
|
||||
info->tiles.at(0),
|
||||
parameters.texturePool,
|
||||
@@ -264,17 +268,17 @@ TileData::State Source::addTile(const TileID& tileID, const StyleUpdateParameter
|
||||
std::unique_ptr<GeometryTileMonitor> monitor;
|
||||
|
||||
if (type == SourceType::Vector) {
|
||||
monitor = std::make_unique<VectorTileMonitor>(normalizedID, parameters.pixelRatio, info->tiles.at(0), parameters.fileSource);
|
||||
monitor = std::make_unique<VectorTileMonitor>(overscaledTileID, parameters.pixelRatio, info->tiles.at(0), parameters.fileSource);
|
||||
} else if (type == SourceType::Annotations) {
|
||||
monitor = std::make_unique<AnnotationTileMonitor>(normalizedID, parameters.annotationManager);
|
||||
monitor = std::make_unique<AnnotationTileMonitor>(overscaledTileID, parameters.annotationManager);
|
||||
} else if (type == SourceType::GeoJSON) {
|
||||
monitor = std::make_unique<GeoJSONTileMonitor>(geojsonvt.get(), normalizedID);
|
||||
monitor = std::make_unique<GeoJSONTileMonitor>(geojsonvt.get(), overscaledTileID);
|
||||
} else {
|
||||
Log::Warning(Event::Style, "Source type '%s' is not implemented", SourceTypeClass(type).c_str());
|
||||
return TileData::State::invalid;
|
||||
}
|
||||
|
||||
newTile->data = std::make_shared<VectorTileData>(normalizedID,
|
||||
newTile->data = std::make_shared<VectorTileData>(overscaledTileID,
|
||||
std::move(monitor),
|
||||
id,
|
||||
parameters.style,
|
||||
@@ -339,7 +343,10 @@ void Source::findLoadedParent(const TileID& tileID, int32_t minCoveringZoom, std
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.has(parent_id.normalized().to_uint64())) {
|
||||
const UnwrappedTileID unwrappedTileID(tileID.sourceZ, static_cast<uint32_t>(tileID.x),
|
||||
static_cast<uint32_t>(tileID.y));
|
||||
|
||||
if (cache.has(OverscaledTileID{ tileID.z, unwrappedTileID.canonical })) {
|
||||
addTile(parent_id, parameters);
|
||||
retain.emplace_back(parent_id);
|
||||
return;
|
||||
@@ -423,8 +430,8 @@ bool Source::update(const StyleUpdateParameters& parameters) {
|
||||
|
||||
// Remove tiles that we definitely don't need, i.e. tiles that are not on
|
||||
// the required list.
|
||||
std::set<TileID> retain_data;
|
||||
util::erase_if(tiles, [this, &retain, &retain_data, &tileCache](std::pair<const TileID, std::unique_ptr<Tile>> &pair) {
|
||||
std::set<OverscaledTileID> retain_data;
|
||||
util::erase_if(tiles, [this, &retain, &retain_data, &tileCache](auto &pair) {
|
||||
const auto& tileID = pair.first;
|
||||
Tile &tile = *pair.second;
|
||||
bool obsolete = std::find(retain.begin(), retain.end(), tileID) == retain.end();
|
||||
@@ -434,22 +441,22 @@ bool Source::update(const StyleUpdateParameters& parameters) {
|
||||
// Partially parsed tiles are never added to the cache because otherwise
|
||||
// they never get updated if the go out from the viewport and the pending
|
||||
// resources arrive.
|
||||
tileCache.add(tileID.normalized().to_uint64(), tile.data);
|
||||
tileCache.add(tile.data->id, tile.data);
|
||||
}
|
||||
return obsolete;
|
||||
});
|
||||
|
||||
// Remove all the expired pointers from the set.
|
||||
util::erase_if(tileDataMap, [&retain_data, &tileCache](std::pair<const TileID, std::weak_ptr<TileData>> &pair) {
|
||||
const util::ptr<TileData> tile = pair.second.lock();
|
||||
if (!tile) {
|
||||
util::erase_if(tileDataMap, [&retain_data, &tileCache](auto &pair) {
|
||||
const auto tileData = pair.second.lock();
|
||||
if (!tileData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool obsolete = retain_data.find(tile->id) == retain_data.end();
|
||||
bool obsolete = retain_data.find(tileData->id) == retain_data.end();
|
||||
if (obsolete) {
|
||||
if (!tileCache.has(tile->id.normalized().to_uint64())) {
|
||||
tile->cancel();
|
||||
if (!tileCache.has(tileData->id)) {
|
||||
tileData->cancel();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@@ -479,10 +486,10 @@ void Source::updateTilePtrs() {
|
||||
}
|
||||
}
|
||||
|
||||
static Point<int16_t> coordinateToTilePoint(const TileID& tileID, const TileCoordinate& coord) {
|
||||
auto zoomedCoord = coord.zoomTo(tileID.sourceZ);
|
||||
static Point<int16_t> coordinateToTilePoint(const CanonicalTileID& tileID, const TileCoordinate& coord) {
|
||||
auto zoomedCoord = coord.zoomTo(tileID.z);
|
||||
return {
|
||||
int16_t(util::clamp<int64_t>((zoomedCoord.x - (tileID.x + tileID.w * std::pow(2, tileID.sourceZ))) * util::EXTENT,
|
||||
int16_t(util::clamp<int64_t>((zoomedCoord.x - tileID.x) * util::EXTENT,
|
||||
std::numeric_limits<int16_t>::min(),
|
||||
std::numeric_limits<int16_t>::max())),
|
||||
int16_t(util::clamp<int64_t>((zoomedCoord.y - tileID.y) * util::EXTENT,
|
||||
@@ -519,15 +526,13 @@ std::unordered_map<std::string, std::vector<Feature>> Source::queryRenderedFeatu
|
||||
maxY = util::max(maxY, c.y);
|
||||
}
|
||||
|
||||
std::unordered_map<uint64_t, TileQuery> tileQueries;
|
||||
std::map<CanonicalTileID, TileQuery> tileQueries;
|
||||
|
||||
for (auto& tilePtr : tilePtrs) {
|
||||
auto& tile = *tilePtr;
|
||||
const TileID& tileID = tile.data->id;
|
||||
const auto integerID = tileID.to_uint64();
|
||||
|
||||
auto tileSpaceBoundsMin = coordinateToTilePoint(tileID, { minX, minY, z });
|
||||
auto tileSpaceBoundsMax = coordinateToTilePoint(tileID, { maxX, maxY, z });
|
||||
auto tileSpaceBoundsMin = coordinateToTilePoint(tile.id.canonical, { minX, minY, z });
|
||||
auto tileSpaceBoundsMax = coordinateToTilePoint(tile.id.canonical, { maxX, maxY, z });
|
||||
|
||||
if (tileSpaceBoundsMin.x >= util::EXTENT || tileSpaceBoundsMin.y >= util::EXTENT ||
|
||||
tileSpaceBoundsMax.x < 0 || tileSpaceBoundsMax.y < 0) continue;
|
||||
@@ -535,18 +540,19 @@ std::unordered_map<std::string, std::vector<Feature>> Source::queryRenderedFeatu
|
||||
GeometryCoordinates tileSpaceQueryGeometry;
|
||||
|
||||
for (auto& c : queryGeometry) {
|
||||
tileSpaceQueryGeometry.push_back(coordinateToTilePoint(tileID, c));
|
||||
tileSpaceQueryGeometry.push_back(coordinateToTilePoint(tile.id.canonical, c));
|
||||
}
|
||||
|
||||
auto it = tileQueries.find(integerID);
|
||||
auto it = tileQueries.find(tile.id.canonical);
|
||||
if (it != tileQueries.end()) {
|
||||
it->second.queryGeometry.push_back(std::move(tileSpaceQueryGeometry));
|
||||
} else {
|
||||
tileQueries.emplace(integerID, TileQuery{
|
||||
(void)zoom;
|
||||
tileQueries.emplace(tile.id.canonical, TileQuery{
|
||||
tilePtr,
|
||||
{ tileSpaceQueryGeometry },
|
||||
util::tileSize * std::pow(2, tileID.z - tileID.sourceZ),
|
||||
std::pow(2, zoom - tileID.z)
|
||||
util::tileSize * tile.data->id.overscaleFactor(),
|
||||
std::pow(2, zoom - tile.data->id.overscaledZ)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -572,9 +578,9 @@ void Source::setObserver(Observer* observer_) {
|
||||
observer = observer_;
|
||||
}
|
||||
|
||||
void Source::tileLoadingCallback(const TileID& tileID,
|
||||
std::exception_ptr error,
|
||||
bool isNewTile) {
|
||||
void Source::tileLoadingCallback(const OverscaledTileID& tileID,
|
||||
std::exception_ptr error,
|
||||
bool isNewTile) {
|
||||
auto it = tileDataMap.find(tileID);
|
||||
if (it == tileDataMap.end()) {
|
||||
return;
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
virtual void onSourceLoaded(Source&) {};
|
||||
virtual void onSourceError(Source&, std::exception_ptr) {};
|
||||
|
||||
virtual void onTileLoaded(Source&, const TileID&, bool /* isNewTile */) {};
|
||||
virtual void onTileError(Source&, const TileID&, std::exception_ptr) {};
|
||||
virtual void onTileLoaded(Source&, const OverscaledTileID&, bool /* isNewTile */) {};
|
||||
virtual void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) {};
|
||||
virtual void onPlacementRedone() {};
|
||||
};
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
bool enabled = false;
|
||||
|
||||
private:
|
||||
void tileLoadingCallback(const TileID&,
|
||||
void tileLoadingCallback(const OverscaledTileID&,
|
||||
std::exception_ptr,
|
||||
bool isNewTile);
|
||||
bool handlePartialTile(const TileID&);
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
|
||||
std::map<TileID, std::unique_ptr<Tile>> tiles;
|
||||
std::vector<Tile*> tilePtrs;
|
||||
std::map<TileID, std::weak_ptr<TileData>> tileDataMap;
|
||||
std::map<OverscaledTileID, std::weak_ptr<TileData>> tileDataMap;
|
||||
TileCache cache;
|
||||
|
||||
std::unique_ptr<AsyncRequest> req;
|
||||
|
||||
@@ -395,7 +395,7 @@ void Style::onSourceError(Source& source, std::exception_ptr error) {
|
||||
observer->onResourceError(error);
|
||||
}
|
||||
|
||||
void Style::onTileLoaded(Source& source, const TileID& tileID, bool isNewTile) {
|
||||
void Style::onTileLoaded(Source& source, const OverscaledTileID& tileID, bool isNewTile) {
|
||||
if (isNewTile) {
|
||||
shouldReparsePartialTiles = true;
|
||||
}
|
||||
@@ -404,10 +404,10 @@ void Style::onTileLoaded(Source& source, const TileID& tileID, bool isNewTile) {
|
||||
observer->onResourceLoaded();
|
||||
}
|
||||
|
||||
void Style::onTileError(Source& source, const TileID& tileID, std::exception_ptr error) {
|
||||
void Style::onTileError(Source& source, const OverscaledTileID& tileID, std::exception_ptr error) {
|
||||
lastError = error;
|
||||
Log::Error(Event::Style, "Failed to load tile %s for source %s: %s",
|
||||
std::string(tileID).c_str(), source.id.c_str(), util::toString(error).c_str());
|
||||
util::toString(tileID).c_str(), source.id.c_str(), util::toString(error).c_str());
|
||||
observer->onTileError(source, tileID, error);
|
||||
observer->onResourceError(error);
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ private:
|
||||
// Source::Observer implementation.
|
||||
void onSourceLoaded(Source&) override;
|
||||
void onSourceError(Source&, std::exception_ptr) override;
|
||||
void onTileLoaded(Source&, const TileID&, bool isNewTile) override;
|
||||
void onTileError(Source&, const TileID&, std::exception_ptr) override;
|
||||
void onTileLoaded(Source&, const OverscaledTileID&, bool isNewTile) override;
|
||||
void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) override;
|
||||
void onPlacementRedone() override;
|
||||
|
||||
Observer nullObserver;
|
||||
|
||||
@@ -20,7 +20,7 @@ class FeatureIndex;
|
||||
|
||||
class StyleBucketParameters {
|
||||
public:
|
||||
StyleBucketParameters(const TileID& tileID_,
|
||||
StyleBucketParameters(const OverscaledTileID& tileID_,
|
||||
const GeometryTileLayer& layer_,
|
||||
const std::atomic<TileData::State>& state_,
|
||||
uintptr_t tileUID_,
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
void eachFilteredFeature(const Filter&, std::function<void (const GeometryTileFeature&, std::size_t index, const std::string& layerName)>);
|
||||
|
||||
const TileID& tileID;
|
||||
const OverscaledTileID& tileID;
|
||||
const GeometryTileLayer& layer;
|
||||
const std::atomic<TileData::State>& state;
|
||||
uintptr_t tileUID;
|
||||
|
||||
@@ -101,7 +101,8 @@ std::unique_ptr<GeoJSONTile> convertTile(const mapbox::geojsonvt::Tile& tile) {
|
||||
return std::make_unique<GeoJSONTile>(layer);
|
||||
}
|
||||
|
||||
GeoJSONTileMonitor::GeoJSONTileMonitor(mapbox::geojsonvt::GeoJSONVT* geojsonvt_, const TileID& id)
|
||||
GeoJSONTileMonitor::GeoJSONTileMonitor(mapbox::geojsonvt::GeoJSONVT* geojsonvt_,
|
||||
const OverscaledTileID& id)
|
||||
: tileID(id), geojsonvt(geojsonvt_) {
|
||||
}
|
||||
|
||||
@@ -119,7 +120,8 @@ void GeoJSONTileMonitor::setGeoJSONVT(mapbox::geojsonvt::GeoJSONVT* vt) {
|
||||
|
||||
void GeoJSONTileMonitor::update() {
|
||||
if (geojsonvt) {
|
||||
auto tile = convertTile(geojsonvt->getTile(tileID.sourceZ, tileID.x, tileID.y));
|
||||
auto tile = convertTile(
|
||||
geojsonvt->getTile(tileID.canonical.z, tileID.canonical.x, tileID.canonical.y));
|
||||
callback(nullptr, std::move(tile), {}, {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define MBGL_ANNOTATION_GEOJSON_VT_TILE
|
||||
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
|
||||
class GeoJSONTileMonitor : public GeometryTileMonitor {
|
||||
public:
|
||||
GeoJSONTileMonitor(mapbox::geojsonvt::GeoJSONVT*, const TileID&);
|
||||
GeoJSONTileMonitor(mapbox::geojsonvt::GeoJSONVT*, const OverscaledTileID&);
|
||||
virtual ~GeoJSONTileMonitor();
|
||||
|
||||
std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
void update();
|
||||
|
||||
public:
|
||||
const TileID tileID;
|
||||
const OverscaledTileID tileID;
|
||||
|
||||
private:
|
||||
mapbox::geojsonvt::GeoJSONVT* geojsonvt = nullptr;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
RasterTileData::RasterTileData(const TileID& id_,
|
||||
RasterTileData::RasterTileData(const OverscaledTileID& id_,
|
||||
float pixelRatio,
|
||||
const std::string& urlTemplate,
|
||||
gl::TexturePool &texturePool_,
|
||||
@@ -20,7 +20,8 @@ RasterTileData::RasterTileData(const TileID& id_,
|
||||
worker(worker_) {
|
||||
state = State::loading;
|
||||
|
||||
const Resource resource = Resource::tile(urlTemplate, pixelRatio, id.x, id.y, id.sourceZ);
|
||||
const Resource resource =
|
||||
Resource::tile(urlTemplate, pixelRatio, id.canonical.x, id.canonical.y, id.canonical.z);
|
||||
req = fileSource.request(resource, [callback, this](Response res) {
|
||||
if (res.error) {
|
||||
callback(std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace gl { class TexturePool; }
|
||||
|
||||
class RasterTileData : public TileData {
|
||||
public:
|
||||
RasterTileData(const TileID&,
|
||||
RasterTileData(const OverscaledTileID&,
|
||||
float pixelRatio,
|
||||
const std::string& urlTemplate,
|
||||
gl::TexturePool&,
|
||||
|
||||
@@ -15,11 +15,9 @@ void TileCache::setSize(size_t size_) {
|
||||
}
|
||||
|
||||
assert(orderedKeys.size() <= size);
|
||||
|
||||
tiles.reserve(size);
|
||||
}
|
||||
|
||||
void TileCache::add(uint64_t key, std::shared_ptr<TileData> data) {
|
||||
void TileCache::add(const OverscaledTileID& key, std::shared_ptr<TileData> data) {
|
||||
|
||||
// insert new or query existing data
|
||||
if (tiles.emplace(key, data).second) {
|
||||
@@ -38,7 +36,7 @@ void TileCache::add(uint64_t key, std::shared_ptr<TileData> data) {
|
||||
assert(orderedKeys.size() <= size);
|
||||
};
|
||||
|
||||
std::shared_ptr<TileData> TileCache::get(uint64_t key) {
|
||||
std::shared_ptr<TileData> TileCache::get(const OverscaledTileID& key) {
|
||||
|
||||
std::shared_ptr<TileData> data;
|
||||
|
||||
@@ -53,7 +51,7 @@ std::shared_ptr<TileData> TileCache::get(uint64_t key) {
|
||||
return data;
|
||||
};
|
||||
|
||||
bool TileCache::has(uint64_t key) {
|
||||
bool TileCache::has(const OverscaledTileID& key) {
|
||||
return tiles.find(key) != tiles.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#ifndef MBGL_MAP_TILE_CACHE
|
||||
#define MBGL_MAP_TILE_CACHE
|
||||
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -15,14 +17,14 @@ public:
|
||||
|
||||
void setSize(size_t);
|
||||
size_t getSize() const { return size; };
|
||||
void add(uint64_t key, std::shared_ptr<TileData> data);
|
||||
std::shared_ptr<TileData> get(uint64_t key);
|
||||
bool has(uint64_t key);
|
||||
void add(const OverscaledTileID& key, std::shared_ptr<TileData> data);
|
||||
std::shared_ptr<TileData> get(const OverscaledTileID& key);
|
||||
bool has(const OverscaledTileID& key);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::unordered_map<uint64_t, std::shared_ptr<TileData>> tiles;
|
||||
std::list<uint64_t> orderedKeys;
|
||||
std::map<OverscaledTileID, std::shared_ptr<TileData>> tiles;
|
||||
std::list<OverscaledTileID> orderedKeys;
|
||||
|
||||
size_t size;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
TileData::TileData(const TileID& id_)
|
||||
TileData::TileData(const OverscaledTileID& id_)
|
||||
: id(id_),
|
||||
state(State::initial) {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ const char* TileData::StateToString(const State state) {
|
||||
}
|
||||
|
||||
void TileData::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "TileData::id: %s", std::string(id).c_str());
|
||||
Log::Info(Event::General, "TileData::id: %s", util::toString(id).c_str());
|
||||
Log::Info(Event::General, "TileData::state: %s", TileData::StateToString(state));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/feature.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/text/placement_config.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
return state == State::partial || state == State::parsed;
|
||||
}
|
||||
|
||||
TileData(const TileID&);
|
||||
TileData(const OverscaledTileID&);
|
||||
virtual ~TileData();
|
||||
|
||||
// Mark this tile as no longer needed and cancel any pending work.
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
const TileID id;
|
||||
const OverscaledTileID id;
|
||||
optional<SystemTimePoint> modified;
|
||||
optional<SystemTimePoint> expires;
|
||||
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include <mbgl/renderer/symbol_bucket.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <utility>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TileWorker::TileWorker(TileID id_,
|
||||
TileWorker::TileWorker(const OverscaledTileID& id_,
|
||||
std::string sourceID_,
|
||||
SpriteStore& spriteStore_,
|
||||
GlyphAtlas& glyphAtlas_,
|
||||
@@ -139,8 +140,8 @@ void TileWorker::parseLayer(const StyleLayer* layer) {
|
||||
|
||||
// Skip this bucket if we are to not render this
|
||||
if ((layer->source != sourceID) ||
|
||||
(id.z < std::floor(layer->minZoom)) ||
|
||||
(id.z >= std::ceil(layer->maxZoom)) ||
|
||||
(id.overscaledZ < std::floor(layer->minZoom)) ||
|
||||
(id.overscaledZ >= std::ceil(layer->maxZoom)) ||
|
||||
(layer->visibility == VisibilityType::None)) {
|
||||
return;
|
||||
}
|
||||
@@ -149,8 +150,8 @@ void TileWorker::parseLayer(const StyleLayer* layer) {
|
||||
if (!geometryLayer) {
|
||||
// The layer specified in the bucket does not exist. Do nothing.
|
||||
if (debug::tileParseWarnings) {
|
||||
Log::Warning(Event::ParseTile, "layer '%s' does not exist in tile %d/%d/%d",
|
||||
layer->sourceLayer.c_str(), id.z, id.x, id.y);
|
||||
Log::Warning(Event::ParseTile, "layer '%s' does not exist in tile %s",
|
||||
layer->sourceLayer.c_str(), util::toString(id).c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ using TileParseResult = variant<
|
||||
|
||||
class TileWorker : public util::noncopyable {
|
||||
public:
|
||||
TileWorker(TileID,
|
||||
TileWorker(const OverscaledTileID&,
|
||||
std::string sourceID,
|
||||
SpriteStore&,
|
||||
GlyphAtlas&,
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
void insertBucket(const std::string& name, std::unique_ptr<Bucket>);
|
||||
std::unique_ptr<CollisionTile> placeLayers(PlacementConfig);
|
||||
|
||||
const TileID id;
|
||||
const OverscaledTileID id;
|
||||
const std::string sourceID;
|
||||
|
||||
SpriteStore& spriteStore;
|
||||
|
||||
@@ -217,7 +217,8 @@ std::string VectorTileLayer::getName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
VectorTileMonitor::VectorTileMonitor(const TileID& tileID_, float pixelRatio_, const std::string& urlTemplate_, FileSource& fileSource_)
|
||||
VectorTileMonitor::VectorTileMonitor(const OverscaledTileID& tileID_, float pixelRatio_,
|
||||
const std::string& urlTemplate_, FileSource& fileSource_)
|
||||
: tileID(tileID_),
|
||||
pixelRatio(pixelRatio_),
|
||||
urlTemplate(urlTemplate_),
|
||||
@@ -225,7 +226,8 @@ VectorTileMonitor::VectorTileMonitor(const TileID& tileID_, float pixelRatio_, c
|
||||
}
|
||||
|
||||
std::unique_ptr<AsyncRequest> VectorTileMonitor::monitorTile(const GeometryTileMonitor::Callback& callback) {
|
||||
const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.x, tileID.y, tileID.sourceZ);
|
||||
const Resource resource = Resource::tile(urlTemplate, pixelRatio, tileID.canonical.x,
|
||||
tileID.canonical.y, tileID.canonical.z);
|
||||
return fileSource.request(resource, [callback, this](Response res) {
|
||||
if (res.error) {
|
||||
callback(std::make_exception_ptr(std::runtime_error(res.error->message)), nullptr, res.modified, res.expires);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define MBGL_MAP_VECTOR_TILE
|
||||
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <protozero/pbf_reader.hpp>
|
||||
|
||||
#include <map>
|
||||
@@ -72,12 +72,12 @@ class FileSource;
|
||||
|
||||
class VectorTileMonitor : public GeometryTileMonitor {
|
||||
public:
|
||||
VectorTileMonitor(const TileID&, float pixelRatio, const std::string& urlTemplate, FileSource&);
|
||||
VectorTileMonitor(const OverscaledTileID&, float pixelRatio, const std::string& urlTemplate, FileSource&);
|
||||
|
||||
std::unique_ptr<AsyncRequest> monitorTile(const GeometryTileMonitor::Callback&) override;
|
||||
|
||||
private:
|
||||
TileID tileID;
|
||||
OverscaledTileID tileID;
|
||||
float pixelRatio;
|
||||
std::string urlTemplate;
|
||||
FileSource& fileSource;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
VectorTileData::VectorTileData(const TileID& id_,
|
||||
VectorTileData::VectorTileData(const OverscaledTileID& id_,
|
||||
std::unique_ptr<GeometryTileMonitor> monitor_,
|
||||
std::string sourceID,
|
||||
Style& style_,
|
||||
|
||||
@@ -19,7 +19,7 @@ class FeatureIndex;
|
||||
|
||||
class VectorTileData : public TileData {
|
||||
public:
|
||||
VectorTileData(const TileID&,
|
||||
VectorTileData(const OverscaledTileID&,
|
||||
std::unique_ptr<GeometryTileMonitor> monitor,
|
||||
std::string sourceID,
|
||||
Style&,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef MBGL_UTIL_CLIP_IDS
|
||||
#define MBGL_UTIL_CLIP_IDS
|
||||
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
LatLng::LatLng(const TileID& id) {
|
||||
longitude = id.x / std::pow(2.0, id.z) * util::DEGREES_MAX - util::LONGITUDE_MAX;
|
||||
const double n = M_PI - 2.0 * M_PI * id.y / std::pow(2.0, id.z);
|
||||
latitude = util::RAD2DEG * std::atan(0.5 * (std::exp(n) - std::exp(-n)));
|
||||
namespace {
|
||||
|
||||
inline double lat(const uint8_t z, const int64_t y) {
|
||||
const double n = M_PI - 2.0 * M_PI * y / std::pow(2.0, z);
|
||||
return util::RAD2DEG * std::atan(0.5 * (std::exp(n) - std::exp(-n)));
|
||||
}
|
||||
|
||||
LatLngBounds::LatLngBounds(const TileID& id)
|
||||
: sw(TileID{ id.z, id.x, id.y + 1, id.sourceZ }),
|
||||
ne(TileID{ id.z, id.x + 1, id.y, id.sourceZ }) {
|
||||
inline double lon(const uint8_t z, const int64_t x) {
|
||||
return x / std::pow(2.0, z) * util::DEGREES_MAX - util::LONGITUDE_MAX;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
LatLng::LatLng(const CanonicalTileID& id) : latitude(lat(id.z, id.y)), longitude(lon(id.z, id.x)) {
|
||||
}
|
||||
|
||||
LatLng::LatLng(const UnwrappedTileID& id)
|
||||
: latitude(lat(id.canonical.z, id.canonical.y)),
|
||||
longitude(lon(id.canonical.z, id.canonical.x) + id.wrap * util::DEGREES_MAX) {
|
||||
}
|
||||
|
||||
LatLngBounds::LatLngBounds(const CanonicalTileID& id)
|
||||
: sw({ lat(id.z, id.y + 1), lon(id.z, id.x) }),
|
||||
ne({ lat(id.z, id.y), lon(id.z, id.x + 1) }) {
|
||||
}
|
||||
|
||||
ScreenCoordinate EdgeInsets::getCenter(uint16_t width, uint16_t height) const {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user