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 /include/mbgl/util | |
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 'include/mbgl/util')
-rw-r--r-- | include/mbgl/util/geo.hpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 0943c64d5f..a9c1112fd1 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -105,6 +105,15 @@ public: return bounds; } + /// Returns an infinite bound, a bound for which the constrain method returns its + /// input unmodified. + /// + /// Note: this is different than LatLngBounds::world() since arbitrary unwrapped + /// coordinates are also inside the bounds. + static LatLngBounds unbounded() { + return {}; + } + // Constructs a LatLngBounds object with the tile's exact boundaries. LatLngBounds(const CanonicalTileID&); @@ -159,15 +168,19 @@ public: private: LatLng sw; LatLng ne; + bool bounded = true; LatLngBounds(LatLng sw_, LatLng ne_) : sw(std::move(sw_)), ne(std::move(ne_)) {} + LatLngBounds() + : sw({-90, -180}), ne({90, 180}), bounded(false) {} + bool containsLatitude(double latitude) const; bool containsLongitude(double longitude, LatLng::WrapMode wrap) const; friend bool operator==(const LatLngBounds& a, const LatLngBounds& b) { - return a.sw == b.sw && a.ne == b.ne; + return (!a.bounded && !b.bounded) || (a.bounded && b.bounded && a.sw == b.sw && a.ne == b.ne); } friend bool operator!=(const LatLngBounds& a, const LatLngBounds& b) { |