Implement distance-based tile LOD (#4057)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/util/compression.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/enum.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/rapidjson.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
@@ -612,6 +613,10 @@ TestMetadata parseTestMetadata(const TestPaths& paths) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
namespace mbgl {
|
||||
MBGL_DEFINE_ENUM(TileLodMode, {{TileLodMode::Default, "default"}, {TileLodMode::Distance, "distance"}});
|
||||
}
|
||||
|
||||
namespace TestOperationNames {
|
||||
const std::string waitOp("wait");
|
||||
const std::string sleepOp("sleep");
|
||||
@@ -648,6 +653,11 @@ const std::string panGestureOp("panGesture");
|
||||
const std::string gfxProbeOp("probeGFX");
|
||||
const std::string gfxProbeStartOp("probeGFXStart");
|
||||
const std::string gfxProbeEndOp("probeGFXEnd");
|
||||
const std::string setTileLodMinRadiusOp("setTileLodMinRadius");
|
||||
const std::string setTileLodScaleOp("setTileLodScale");
|
||||
const std::string setTileLodPitchThresholdOp("setTileLodPitchThreshold");
|
||||
const std::string setTileLodZoomShiftOp("setTileLodZoomShift");
|
||||
const std::string setTileLodModeOp("setTileLodMode");
|
||||
} // namespace TestOperationNames
|
||||
|
||||
using namespace TestOperationNames;
|
||||
@@ -1321,6 +1331,53 @@ TestOperations parseTestOperations(TestMetadata& metadata) {
|
||||
ctx.getMetadata().metrics.gfx.insert({mark, metricProbe});
|
||||
return true;
|
||||
});
|
||||
|
||||
} else if (operationArray[0].GetString() == setTileLodMinRadiusOp) {
|
||||
// setTileLodMinRadius
|
||||
assert(operationArray.Size() == 2u);
|
||||
assert(operationArray[1].IsNumber());
|
||||
double minRadius = operationArray[1].GetDouble();
|
||||
result.emplace_back([minRadius](TestContext& ctx) {
|
||||
ctx.getMap().setTileLodMinRadius(minRadius);
|
||||
return true;
|
||||
});
|
||||
|
||||
} else if (operationArray[0].GetString() == setTileLodScaleOp) {
|
||||
// setTileLodScale
|
||||
assert(operationArray.Size() == 2u);
|
||||
assert(operationArray[1].IsNumber());
|
||||
double scale = operationArray[1].GetDouble();
|
||||
result.emplace_back([scale](TestContext& ctx) {
|
||||
ctx.getMap().setTileLodScale(scale);
|
||||
return true;
|
||||
});
|
||||
} else if (operationArray[0].GetString() == setTileLodPitchThresholdOp) {
|
||||
// setTileLodPitchThreshold
|
||||
assert(operationArray.Size() == 2u);
|
||||
assert(operationArray[1].IsNumber());
|
||||
double pitchThreshold = operationArray[1].GetDouble();
|
||||
result.emplace_back([pitchThreshold](TestContext& ctx) {
|
||||
ctx.getMap().setTileLodPitchThreshold(pitchThreshold);
|
||||
return true;
|
||||
});
|
||||
} else if (operationArray[0].GetString() == setTileLodZoomShiftOp) {
|
||||
// setTileLodZoomShift
|
||||
assert(operationArray.Size() == 2u);
|
||||
assert(operationArray[1].IsNumber());
|
||||
double zoomShift = operationArray[1].GetDouble();
|
||||
result.emplace_back([zoomShift](TestContext& ctx) {
|
||||
ctx.getMap().setTileLodZoomShift(zoomShift);
|
||||
return true;
|
||||
});
|
||||
} else if (operationArray[0].GetString() == setTileLodModeOp) {
|
||||
// setTileLodMode
|
||||
assert(operationArray.Size() == 2u);
|
||||
assert(operationArray[1].IsString());
|
||||
mbgl::TileLodMode mode = mbgl::Enum<mbgl::TileLodMode>::toEnum(operationArray[1].GetString()).value();
|
||||
result.emplace_back([mode](TestContext& ctx) {
|
||||
ctx.getMap().setTileLodMode(mode);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
metadata.errorMessage = std::string("Unsupported operation: ") + operationArray[0].GetString();
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user