diff options
author | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-03-08 15:53:25 +0200 |
---|---|---|
committer | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-03-14 18:33:11 +0200 |
commit | 11de777628e9e2c4b219bae3f1a6eabd86f2a3c5 (patch) | |
tree | 202156e7253dbc6cbb5fc5c4a04a98e8ed55e681 /src/mbgl/map/transform.cpp | |
parent | a73cc9d8e363b0b3f4fa66c5d9c34625dffbb7e5 (diff) | |
download | qtlocation-mapboxgl-11de777628e9e2c4b219bae3f1a6eabd86f2a3c5.tar.gz |
[core] Remove optional from Map::setLatLngBounds()
This is a first step into grouping together bounds related Map methods
into one that takes a "BoundOptions" object. LatLngBounds::unbounded()
replaces an undefined optional<LatLngBounds>.
v2: Document LatLngBounds::unbounded()
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index a90bf9871f..e97f0da3f1 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -85,7 +85,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim const EdgeInsets& padding = camera.padding; LatLng startLatLng = getLatLng(padding, LatLng::Unwrapped); const LatLng& unwrappedLatLng = camera.center.value_or(startLatLng); - const LatLng& latLng = state.bounds ? unwrappedLatLng : unwrappedLatLng.wrapped(); + const LatLng& latLng = state.bounds != LatLngBounds::unbounded() ? unwrappedLatLng : unwrappedLatLng.wrapped(); double zoom = camera.zoom.value_or(getZoom()); double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing(); double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch(); @@ -94,7 +94,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim return; } - if (!state.bounds) { + if (state.bounds == LatLngBounds::unbounded()) { if (isGestureInProgress()) { // If gesture in progress, we transfer the wrap rounds from the end longitude into // start, so the "scroll effect" of rounding the world is the same while assuring the @@ -344,11 +344,11 @@ double Transform::getZoom() const { #pragma mark - Bounds -void Transform::setLatLngBounds(optional<LatLngBounds> bounds) { - if (bounds && !bounds->valid()) { +void Transform::setLatLngBounds(LatLngBounds bounds) { + if (!bounds.valid()) { throw std::runtime_error("failed to set bounds: bounds are invalid"); } - state.setLatLngBounds(bounds); + state.setLatLngBounds(std::move(bounds)); } void Transform::setMinZoom(const double minZoom) { |