Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -40,16 +40,16 @@ TEST(Transform, InvalidZoom) {
// Executing flyTo with an empty size causes frameZoom to be NaN.
transform.flyTo(CameraOptions()
.withCenter(LatLng{ util::LATITUDE_MAX, util::LONGITUDE_MAX })
.withCenter(LatLng{util::LATITUDE_MAX, util::LONGITUDE_MAX})
.withZoom(transform.getState().getMaxZoom()));
transform.updateTransitions(transform.getTransitionStart() + transform.getTransitionDuration());
ASSERT_DOUBLE_EQ(transform.getZoom(), transform.getState().getMaxZoom());
// Executing flyTo with maximum zoom level to the same zoom level causes
// frameZoom to be bigger than maximum zoom.
transform.resize(Size { 100, 100 });
transform.resize(Size{100, 100});
transform.flyTo(CameraOptions()
.withCenter(LatLng{ util::LATITUDE_MAX, util::LONGITUDE_MAX })
.withCenter(LatLng{util::LATITUDE_MAX, util::LONGITUDE_MAX})
.withZoom(transform.getState().getMaxZoom()));
transform.updateTransitions(transform.getTransitionStart() + transform.getTransitionDuration());
@@ -106,10 +106,10 @@ TEST(Transform, PerspectiveProjection) {
LatLng loc;
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
// 0.9 rad ~ 51.56620156 deg
transform.jumpTo(CameraOptions().withCenter(LatLng { 38.0, -77.0 }).withZoom(10.0).withPitch(51.56620156));
transform.jumpTo(CameraOptions().withCenter(LatLng{38.0, -77.0}).withZoom(10.0).withPitch(51.56620156));
// expected values are from maplibre-gl-js
@@ -117,11 +117,11 @@ TEST(Transform, PerspectiveProjection) {
ASSERT_DOUBLE_EQ(-77, loc.longitude());
ASSERT_DOUBLE_EQ(38, loc.latitude());
loc = transform.getState().screenCoordinateToLatLng({ 0, 1000 });
loc = transform.getState().screenCoordinateToLatLng({0, 1000});
ASSERT_NEAR(-77.59198961199148, loc.longitude(), 1e-6);
ASSERT_NEAR(38.74661326302018, loc.latitude(), 1e-6);
loc = transform.getState().screenCoordinateToLatLng({ 1000, 0 });
loc = transform.getState().screenCoordinateToLatLng({1000, 0});
ASSERT_NEAR(-76.75823239205641, loc.longitude(), 1e-6);
ASSERT_NEAR(37.692872969426375, loc.latitude(), 1e-6);
@@ -146,10 +146,10 @@ TEST(Transform, PerspectiveProjection) {
TEST(Transform, UnwrappedLatLng) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
// 0.9 rad ~ 51.56620156 deg
transform.jumpTo(CameraOptions().withCenter(LatLng { 38.0, -77.0 }).withZoom(10.0).withPitch(51.56620156));
transform.jumpTo(CameraOptions().withCenter(LatLng{38.0, -77.0}).withZoom(10.0).withPitch(51.56620156));
const TransformState& state = transform.getState();
@@ -157,17 +157,17 @@ TEST(Transform, UnwrappedLatLng) {
ASSERT_DOUBLE_EQ(fromGetLatLng.latitude(), 38.0);
ASSERT_DOUBLE_EQ(fromGetLatLng.longitude(), -77.0);
LatLng fromScreenCoordinate = state.screenCoordinateToLatLng({ 500, 500 });
LatLng fromScreenCoordinate = state.screenCoordinateToLatLng({500, 500});
ASSERT_NEAR(fromScreenCoordinate.latitude(), 38.0, 1e-8);
ASSERT_NEAR(fromScreenCoordinate.longitude(), -77.0, 1e-8);
LatLng wrappedRightwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({ 38, 283 }));
LatLng wrappedRightwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({38, 283}));
ASSERT_NEAR(wrappedRightwards.latitude(), 38.0, 1e-8);
ASSERT_NEAR(wrappedRightwards.longitude(), 283.0, 1e-8);
wrappedRightwards.wrap();
ASSERT_NEAR(wrappedRightwards.longitude(), -77.0, 1e-8);
LatLng wrappedLeftwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({ 38, -437 }));
LatLng wrappedLeftwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({38, -437}));
ASSERT_DOUBLE_EQ(wrappedLeftwards.latitude(), wrappedRightwards.latitude());
ASSERT_NEAR(wrappedLeftwards.longitude(), -437.0, 1e-8);
wrappedLeftwards.wrap();
@@ -176,7 +176,7 @@ TEST(Transform, UnwrappedLatLng) {
TEST(Transform, ConstrainHeightOnly) {
Transform transform(MapObserver::nullObserver(), ConstrainMode::HeightOnly);
transform.resize({ 2, 2 });
transform.resize({2, 2});
transform.jumpTo(CameraOptions().withCenter(LatLngBounds::world().southwest()).withZoom(util::MAX_ZOOM));
ASSERT_NEAR(-util::LATITUDE_MAX, transform.getLatLng().latitude(), 1e-7);
@@ -189,7 +189,7 @@ TEST(Transform, ConstrainHeightOnly) {
TEST(Transform, ConstrainWidthAndHeight) {
Transform transform(MapObserver::nullObserver(), ConstrainMode::WidthAndHeight);
transform.resize({ 2, 2 });
transform.resize({2, 2});
transform.jumpTo(CameraOptions().withCenter(LatLngBounds::world().southwest()).withZoom(util::MAX_ZOOM));
ASSERT_NEAR(-util::LATITUDE_MAX, transform.getLatLng().latitude(), 1e-7);
@@ -202,10 +202,10 @@ TEST(Transform, ConstrainWidthAndHeight) {
TEST(Transform, Anchor) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
const LatLng latLng { 10, -100 };
const ScreenCoordinate anchorPoint = { 150, 150 };
const LatLng latLng{10, -100};
const ScreenCoordinate anchorPoint = {150, 150};
transform.jumpTo(CameraOptions().withCenter(latLng).withZoom(10.0));
ASSERT_DOUBLE_EQ(latLng.latitude(), transform.getLatLng().latitude());
@@ -299,11 +299,11 @@ TEST(Transform, Anchor) {
TEST(Transform, Padding) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
ASSERT_DOUBLE_EQ(0, transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude());
CameraOptions nonPaddedCameraOptions = CameraOptions().withCenter(LatLng { 10, -100 }).withZoom(10.0);
CameraOptions nonPaddedCameraOptions = CameraOptions().withCenter(LatLng{10, -100}).withZoom(10.0);
transform.jumpTo(nonPaddedCameraOptions);
const LatLng trueCenter = transform.getLatLng();
@@ -349,7 +349,7 @@ TEST(Transform, Padding) {
TEST(Transform, MoveBy) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(10.0));
@@ -362,8 +362,8 @@ TEST(Transform, MoveBy) {
bool odd = x % 2;
bool forward = x % 10;
LatLng coordinate = transform.screenCoordinateToLatLng({ odd ? 400. : 600., forward ? 400. : 600 });
transform.moveBy({ odd ? 100. : -100., forward ? 100. : -100 });
LatLng coordinate = transform.screenCoordinateToLatLng({odd ? 400. : 600., forward ? 400. : 600});
transform.moveBy({odd ? 100. : -100., forward ? 100. : -100});
trueCenter = transform.getLatLng();
ASSERT_NEAR(coordinate.latitude(), trueCenter.latitude(), 1e-8);
@@ -377,17 +377,17 @@ TEST(Transform, MoveBy) {
TEST(Transform, Antimeridian) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(1.0));
// San Francisco
const LatLng coordinateSanFrancisco { 37.7833, -122.4167 };
const LatLng coordinateSanFrancisco{37.7833, -122.4167};
ScreenCoordinate pixelSF = transform.latLngToScreenCoordinate(coordinateSanFrancisco);
ASSERT_DOUBLE_EQ(151.79249437176432, pixelSF.x);
ASSERT_DOUBLE_EQ(383.76720782527661, pixelSF.y);
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, -181.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, -181.0}));
ScreenCoordinate pixelSFLongest = transform.latLngToScreenCoordinate(coordinateSanFrancisco);
ASSERT_DOUBLE_EQ(-357.36306616412816, pixelSFLongest.x);
@@ -399,19 +399,19 @@ TEST(Transform, Antimeridian) {
ASSERT_DOUBLE_EQ(666.63694385219173, pixelSFShortest.x);
ASSERT_DOUBLE_EQ(pixelSF.y, pixelSFShortest.y);
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, 179.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, 179.0}));
pixelSFShortest = transform.latLngToScreenCoordinate(coordinateSanFrancisco);
ASSERT_DOUBLE_EQ(pixelSFLongest.x, pixelSFShortest.x);
ASSERT_DOUBLE_EQ(pixelSFLongest.y, pixelSFShortest.y);
// Waikiri
const LatLng coordinateWaikiri{ -16.9310, 179.9787 };
const LatLng coordinateWaikiri{-16.9310, 179.9787};
transform.jumpTo(CameraOptions().withCenter(coordinateWaikiri).withZoom(10.0));
ScreenCoordinate pixelWaikiri = transform.latLngToScreenCoordinate(coordinateWaikiri);
ASSERT_DOUBLE_EQ(500, pixelWaikiri.x);
ASSERT_DOUBLE_EQ(500, pixelWaikiri.y);
transform.jumpTo(CameraOptions().withCenter(LatLng { coordinateWaikiri.latitude(), 180.0213 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{coordinateWaikiri.latitude(), 180.0213}));
ScreenCoordinate pixelWaikiriLongest = transform.latLngToScreenCoordinate(coordinateWaikiri);
ASSERT_DOUBLE_EQ(524725.96438108233, pixelWaikiriLongest.x);
ASSERT_DOUBLE_EQ(pixelWaikiri.y, pixelWaikiriLongest.y);
@@ -423,31 +423,31 @@ TEST(Transform, Antimeridian) {
ASSERT_DOUBLE_EQ(pixelWaikiri.y, pixelWaikiriShortest.y);
LatLng coordinateFromPixel = transform.screenCoordinateToLatLng(pixelWaikiriLongest);
ASSERT_NEAR(coordinateWaikiri.latitude(), coordinateFromPixel.latitude(), 1e-4);
ASSERT_NEAR(coordinateWaikiri.latitude(), coordinateFromPixel.latitude(), 1e-4);
ASSERT_NEAR(coordinateWaikiri.longitude(), coordinateFromPixel.longitude(), 1e-4);
transform.jumpTo(CameraOptions().withCenter(LatLng { coordinateWaikiri.latitude(), 180.0213 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{coordinateWaikiri.latitude(), 180.0213}));
pixelWaikiriShortest = transform.latLngToScreenCoordinate(coordinateWaikiri);
ASSERT_DOUBLE_EQ(pixelWaikiriLongest.x, pixelWaikiriShortest.x);
ASSERT_DOUBLE_EQ(pixelWaikiriLongest.y, pixelWaikiriShortest.y);
coordinateFromPixel = transform.screenCoordinateToLatLng(pixelWaikiriShortest);
ASSERT_NEAR(coordinateWaikiri.latitude(), coordinateFromPixel.latitude(), 1e-4);
ASSERT_NEAR(coordinateWaikiri.latitude(), coordinateFromPixel.latitude(), 1e-4);
ASSERT_NEAR(coordinateWaikiri.longitude(), coordinateFromPixel.longitude(), 1e-4);
}
TEST(Transform, Camera) {
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
const LatLng latLng1 { 45, 135 };
const LatLng latLng1{45, 135};
CameraOptions cameraOptions1 = CameraOptions().withCenter(latLng1).withZoom(20.0);
transform.jumpTo(cameraOptions1);
ASSERT_DOUBLE_EQ(latLng1.latitude(), transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(latLng1.longitude(), transform.getLatLng().longitude());
ASSERT_DOUBLE_EQ(20, transform.getZoom());
const LatLng latLng2 { -45, -135 };
const LatLng latLng2{-45, -135};
CameraOptions cameraOptions2 = CameraOptions().withCenter(latLng2).withZoom(10.0);
transform.jumpTo(cameraOptions2);
ASSERT_DOUBLE_EQ(latLng2.latitude(), transform.getLatLng().latitude());
@@ -498,8 +498,8 @@ TEST(Transform, Camera) {
// Anchor and center points are mutually exclusive.
CameraOptions camera;
camera.center = LatLng { 0, 0 };
camera.anchor = ScreenCoordinate { 0, 0 }; // top-left
camera.center = LatLng{0, 0};
camera.anchor = ScreenCoordinate{0, 0}; // top-left
camera.zoom = transform.getState().getMaxZoom();
transform.easeTo(camera, AnimationOptions(Seconds(1)));
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(250));
@@ -521,8 +521,7 @@ TEST(Transform, ProjectionMode) {
EXPECT_EQ(*options.ySkew, 0.0);
}
TEST(Transform, IsPanning)
{
TEST(Transform, IsPanning) {
Transform transform;
AnimationOptions easeOptions(Seconds(1));
@@ -530,7 +529,7 @@ TEST(Transform, IsPanning)
ASSERT_TRUE(transform.getState().isPanning());
};
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
transform.easeTo(CameraOptions().withCenter(LatLng(0, 360.0)), easeOptions);
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(250));
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(500));
@@ -540,13 +539,9 @@ TEST(Transform, IsPanning)
TEST(Transform, DefaultTransform) {
struct TransformObserver : public mbgl::MapObserver {
void onCameraWillChange(MapObserver::CameraChangeMode) final {
cameraWillChangeCallback();
};
void onCameraWillChange(MapObserver::CameraChangeMode) final { cameraWillChangeCallback(); };
void onCameraDidChange(MapObserver::CameraChangeMode) final {
cameraDidChangeCallback();
};
void onCameraDidChange(MapObserver::CameraChangeMode) final { cameraDidChangeCallback(); };
std::function<void()> cameraWillChangeCallback;
std::function<void()> cameraDidChangeCallback;
@@ -556,8 +551,12 @@ TEST(Transform, DefaultTransform) {
uint32_t cameraDidChangeCount = 0;
TransformObserver observer;
observer.cameraWillChangeCallback = [&cameraWillChangeCount]() { cameraWillChangeCount++; };
observer.cameraDidChangeCallback = [&cameraDidChangeCount]() { cameraDidChangeCount++; };
observer.cameraWillChangeCallback = [&cameraWillChangeCount]() {
cameraWillChangeCount++;
};
observer.cameraDidChangeCallback = [&cameraDidChangeCount]() {
cameraDidChangeCount++;
};
Transform transform(observer);
const TransformState& state = transform.getState();
@@ -569,7 +568,7 @@ TEST(Transform, DefaultTransform) {
const uint32_t max = 65535;
// Cannot assign invalid sizes.
std::vector<Size> invalidSizes = { {}, { min, max }, { max, min } };
std::vector<Size> invalidSizes = {{}, {min, max}, {max, min}};
for (const Size& size : invalidSizes) {
try {
transform.resize(size);
@@ -579,7 +578,7 @@ TEST(Transform, DefaultTransform) {
}
}
Size validSize { max, max };
Size validSize{max, max};
ASSERT_FALSE(validSize.isEmpty());
try {
@@ -601,7 +600,7 @@ TEST(Transform, DefaultTransform) {
ASSERT_TRUE(false) << "Should not throw";
}
center = { max / 2., max / 2. };
center = {max / 2., max / 2.};
latLng = state.screenCoordinateToLatLng(center);
ASSERT_NEAR(latLng.latitude(), nullIsland.latitude(), 1e-8);
ASSERT_NEAR(latLng.longitude(), nullIsland.longitude(), 1e-8);
@@ -612,11 +611,11 @@ TEST(Transform, DefaultTransform) {
}
TEST(Transform, LatLngBounds) {
const LatLng nullIsland {};
const LatLng sanFrancisco { 37.7749, -122.4194 };
const LatLng nullIsland{};
const LatLng sanFrancisco{37.7749, -122.4194};
Transform transform;
transform.resize({ 1000, 1000 });
transform.resize({1000, 1000});
transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(transform.getState().getMaxZoom()));
@@ -646,17 +645,17 @@ TEST(Transform, LatLngBounds) {
// ├───┼───╂───┼───╂───┼───┤
// │ │ ┃▓▓▓│▓▓▓┃ │ │
// └───┴───┸───┴───┸───┴───┘
transform.setLatLngBounds(LatLngBounds::hull({ -90.0, -180.0 }, { 0.0, 180.0 }));
transform.setLatLngBounds(LatLngBounds::hull({-90.0, -180.0}, {0.0, 180.0}));
transform.jumpTo(CameraOptions().withCenter(sanFrancisco));
ASSERT_EQ(transform.getLatLng().latitude(), 0.0);
ASSERT_EQ(transform.getLatLng().longitude(), sanFrancisco.longitude());
// Try crossing the antimeridian from the left.
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, -200.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, -200.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -180.0);
// Try crossing the antimeridian from the right.
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, 200.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, 200.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng(LatLng::Unwrapped).longitude(), 180.0);
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -180.0);
@@ -666,7 +665,7 @@ TEST(Transform, LatLngBounds) {
// ├───┼───╂───┼───╂───┼───┤
// │ │ ┃ │▓▓▓┃ │ │
// └───┴───┸───┴───┸───┴───┘
transform.setLatLngBounds(LatLngBounds::hull({ -90.0, 0.0 }, { 90.0, 180.0 }));
transform.setLatLngBounds(LatLngBounds::hull({-90.0, 0.0}, {90.0, 180.0}));
transform.jumpTo(CameraOptions().withCenter(sanFrancisco));
ASSERT_NEAR(transform.getLatLng().latitude(), sanFrancisco.latitude(), 1e-8);
ASSERT_EQ(transform.getLatLng().longitude(), 0.0);
@@ -677,7 +676,7 @@ TEST(Transform, LatLngBounds) {
// ├───┼───╂───┼───╂───┼───┤
// │ │ ┃ │▓▓▓┃ │ │
// └───┴───┸───┴───┸───┴───┘
transform.setLatLngBounds(LatLngBounds::hull({ -90.0, 0.0 }, { 0.0, 180.0 }));
transform.setLatLngBounds(LatLngBounds::hull({-90.0, 0.0}, {0.0, 180.0}));
transform.jumpTo(CameraOptions().withCenter(sanFrancisco));
ASSERT_EQ(transform.getLatLng().latitude(), 0.0);
ASSERT_EQ(transform.getLatLng().longitude(), 0.0);
@@ -688,34 +687,34 @@ TEST(Transform, LatLngBounds) {
// ├───┼───╂───┼───╂───┼───┤
// │ │ ┃ │ ┃ │ │
// └───┴───┸───┴───┸───┴───┘
LatLng inside { 45.0, 150.0 };
transform.setLatLngBounds(LatLngBounds::hull({ 0.0, 120.0 }, { 90.0, 240.0 }));
LatLng inside{45.0, 150.0};
transform.setLatLngBounds(LatLngBounds::hull({0.0, 120.0}, {90.0, 240.0}));
transform.jumpTo(CameraOptions().withCenter(inside));
ASSERT_EQ(transform.getLatLng().latitude(), inside.latitude());
ASSERT_EQ(transform.getLatLng().longitude(), inside.longitude());
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, 140.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, 140.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 140.0);
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, 160.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, 160.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 160.0);
// Constrain latitude only.
transform.jumpTo(CameraOptions().withCenter(LatLng { -45.0, inside.longitude() }));
transform.jumpTo(CameraOptions().withCenter(LatLng{-45.0, inside.longitude()}));
ASSERT_EQ(transform.getLatLng().latitude(), 0.0);
ASSERT_EQ(transform.getLatLng().longitude(), inside.longitude());
// Crossing the antimeridian, within bounds.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), 181.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), 181.0}));
ASSERT_EQ(transform.getLatLng().longitude(), -179.0);
// Crossing the antimeridian, outside bounds.
transform.jumpTo(CameraOptions().withCenter(inside));
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), 250.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), 250.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -120.0);
// Constrain to the left edge.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), 119.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), 119.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 120.0);
// Simulate swipe to the left.
@@ -726,7 +725,7 @@ TEST(Transform, LatLngBounds) {
easeOptions.transitionFinishFn = [&]() {
ASSERT_NEAR(transform.getLatLng().longitude(), 120.0, 1e-4);
};
transform.moveBy(ScreenCoordinate { -500, -500 }, easeOptions);
transform.moveBy(ScreenCoordinate{-500, -500}, easeOptions);
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(0));
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(250));
@@ -735,7 +734,7 @@ TEST(Transform, LatLngBounds) {
transform.updateTransitions(transform.getTransitionStart() + transform.getTransitionDuration());
// Constrain to the right edge.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), 241.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), 241.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -120.0);
// Simulate swipe to the right.
@@ -745,7 +744,7 @@ TEST(Transform, LatLngBounds) {
easeOptions.transitionFinishFn = [&]() {
ASSERT_NEAR(transform.getLatLng().longitude(), -120.0, 1e-4);
};
transform.moveBy(ScreenCoordinate { 500, 500 }, easeOptions);
transform.moveBy(ScreenCoordinate{500, 500}, easeOptions);
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(0));
transform.updateTransitions(transform.getTransitionStart() + Milliseconds(250));
@@ -759,45 +758,45 @@ TEST(Transform, LatLngBounds) {
// ├───┼───╂───┼───╂───┼───┤
// │ │ ▓┃▓ │ ┃ │ │
// └───┴───┸───┴───┸───┴───┘
inside = LatLng{ -45.0, -150.0 };
transform.setLatLngBounds(LatLngBounds::hull({ -90.0, -240.0 }, { 0.0, -120.0 }));
inside = LatLng{-45.0, -150.0};
transform.setLatLngBounds(LatLngBounds::hull({-90.0, -240.0}, {0.0, -120.0}));
transform.jumpTo(CameraOptions().withCenter(inside));
ASSERT_DOUBLE_EQ(transform.getLatLng().latitude(), inside.latitude());
ASSERT_EQ(transform.getLatLng().longitude(), inside.longitude());
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, -140.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, -140.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -140.0);
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.0, -160.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{0.0, -160.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -160.0);
// Constrain latitude only.
transform.jumpTo(CameraOptions().withCenter(LatLng { 45.0, inside.longitude() }));
transform.jumpTo(CameraOptions().withCenter(LatLng{45.0, inside.longitude()}));
ASSERT_EQ(transform.getLatLng().latitude(), 0.0);
ASSERT_EQ(transform.getLatLng().longitude(), inside.longitude());
// Crossing the antimeridian, within bounds.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), -181.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), -181.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().latitude(), inside.latitude());
ASSERT_EQ(transform.getLatLng().longitude(), 179.0);
// Crossing the antimeridian, outside bounds.
transform.jumpTo(CameraOptions().withCenter(inside));
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), -250.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), -250.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 120.0);
// Constrain to the left edge.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), -119.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), -119.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -120.0);
transform.moveBy(ScreenCoordinate { -500, 0 });
transform.moveBy(ScreenCoordinate{-500, 0});
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), -120.0);
// Constrain to the right edge.
transform.jumpTo(CameraOptions().withCenter(LatLng { inside.latitude(), -241.0 }));
transform.jumpTo(CameraOptions().withCenter(LatLng{inside.latitude(), -241.0}));
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 120.0);
transform.moveBy(ScreenCoordinate { 500, 0 });
transform.moveBy(ScreenCoordinate{500, 0});
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 120.0);
}
@@ -1094,7 +1093,8 @@ TEST(Transform, FreeCameraOptionsStateSynchronization) {
Vec3NearEquals1E5(vec3{{0.569273, 0.289453, 0.292969}}));
transform.jumpTo(CameraOptions().withPitch(20.0).withBearing(77.0).withCenter(LatLng{-20.0, 20.0}));
EXPECT_THAT(transform.getFreeCameraOptions().position.value(), Vec3NearEquals1E5(vec3{{0.457922, 0.57926, 0.275301}}));
EXPECT_THAT(transform.getFreeCameraOptions().position.value(),
Vec3NearEquals1E5(vec3{{0.457922, 0.57926, 0.275301}}));
// Invalid pitch
transform.jumpTo(CameraOptions().withPitch(-10.0).withBearing(0.0));