summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/map/map.hpp4
-rw-r--r--include/mbgl/util/geo.hpp15
2 files changed, 16 insertions, 3 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 0c979f3e19..93e5190f99 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -77,8 +77,8 @@ public:
LatLngBounds latLngBoundsForCamera(const CameraOptions&) const;
// Bounds
- void setLatLngBounds(optional<LatLngBounds>);
- optional<LatLngBounds> getLatLngBounds() const;
+ void setLatLngBounds(LatLngBounds);
+ LatLngBounds getLatLngBounds() const;
void setMinZoom(double);
double getMinZoom() const;
void setMaxZoom(double);
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) {