[core] Improve LatLngBounds API
* Use "named constructors": empty, world, hull * Make the two-argument constructor lenient (i.e., it is a hull operation) * Add various accessors * Enforce a single empty representation
This commit is contained in:
@@ -142,18 +142,17 @@ TEST(Transform, PerspectiveProjection) {
|
||||
TEST(Transform, ConstrainHeightOnly) {
|
||||
MockView view;
|
||||
LatLng loc;
|
||||
LatLngBounds bounds;
|
||||
|
||||
Transform transform(view, ConstrainMode::HeightOnly);
|
||||
transform.resize({{ 1000, 1000 }});
|
||||
transform.setScale(1024);
|
||||
|
||||
transform.setLatLng(bounds.sw);
|
||||
transform.setLatLng(LatLngBounds::world().southwest());
|
||||
loc = transform.getState().pointToLatLng({ 500, 500 });
|
||||
ASSERT_NEAR(-85.021422866378714, loc.latitude, 0.0001);
|
||||
ASSERT_NEAR(180, std::abs(loc.longitude), 0.0001);
|
||||
|
||||
transform.setLatLng(bounds.ne);
|
||||
transform.setLatLng(LatLngBounds::world().northeast());
|
||||
loc = transform.getState().pointToLatLng({ 500, 500 });
|
||||
ASSERT_NEAR(85.021422866378742, loc.latitude, 0.0001);
|
||||
ASSERT_NEAR(180, std::abs(loc.longitude), 0.0001);
|
||||
@@ -162,18 +161,17 @@ TEST(Transform, ConstrainHeightOnly) {
|
||||
TEST(Transform, ConstrainWidthAndHeight) {
|
||||
MockView view;
|
||||
LatLng loc;
|
||||
LatLngBounds bounds;
|
||||
|
||||
Transform transform(view, ConstrainMode::WidthAndHeight);
|
||||
transform.resize({{ 1000, 1000 }});
|
||||
transform.setScale(1024);
|
||||
|
||||
transform.setLatLng(bounds.sw);
|
||||
transform.setLatLng(LatLngBounds::world().southwest());
|
||||
loc = transform.getState().pointToLatLng({ 500, 500 });
|
||||
ASSERT_NEAR(-85.021422866378714, loc.latitude, 0.0001);
|
||||
ASSERT_NEAR(-179.65667724609375, loc.longitude, 0.0001);
|
||||
|
||||
transform.setLatLng(bounds.ne);
|
||||
transform.setLatLng(LatLngBounds::world().northeast());
|
||||
loc = transform.getState().pointToLatLng({ 500, 500 });
|
||||
ASSERT_NEAR(85.021422866378742, loc.latitude, 0.0001);
|
||||
ASSERT_NEAR(179.65667724609358, std::abs(loc.longitude), 0.0001);
|
||||
|
||||
Reference in New Issue
Block a user