summaryrefslogtreecommitdiff
path: root/include/mbgl/util/geo.hpp
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-01-15 08:23:10 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-01-18 16:54:57 -0800
commit143f8a78170065fc46afba1eaf987258e9c9f99b (patch)
tree854e6e55b5d08b4c524afb30c7f4c6ff2d8d3821 /include/mbgl/util/geo.hpp
parentcb126eafe0e9b482162414d0fbbc0ae4d4f3cea9 (diff)
downloadqtlocation-mapboxgl-143f8a78170065fc46afba1eaf987258e9c9f99b.tar.gz
[core] Added padding option to CameraOptions
Moved EdgeInsets to geo.hpp so CameraOptions and Transform can refer to it. Added a padding option to CameraOptions that alters the frame of reference for the center option. Added optional padding parameters to LatLng getters and setters. Working towards #2600.
Diffstat (limited to 'include/mbgl/util/geo.hpp')
-rw-r--r--include/mbgl/util/geo.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index e815456f22..db7d9c792e 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -108,6 +108,40 @@ enum class NorthOrientation : uint8_t {
Leftwards,
};
+/// The distance on each side between a rectangle and a rectangle within.
+struct EdgeInsets {
+ double top = 0; ///< Number of pixels inset from the top edge.
+ double left = 0; ///< Number of pixels inset from the left edge.
+ double bottom = 0; ///< Number of pixels inset from the bottom edge.
+ double right = 0; ///< Number of pixels inset from the right edge.
+
+ inline EdgeInsets() {}
+
+ inline EdgeInsets(const double t, const double l, const double b, const double r)
+ : top(t), left(l), bottom(b), right(r) {}
+
+ inline operator bool() const {
+ return top || left || bottom || right;
+ }
+
+ inline void operator+=(const EdgeInsets& o) {
+ top += o.top;
+ left += o.left;
+ bottom += o.bottom;
+ right += o.right;
+ }
+
+ inline EdgeInsets operator+(const EdgeInsets& o) const {
+ return {
+ top + o.top, left + o.left, bottom + o.bottom, right + o.right,
+ };
+ }
+
+ PrecisionPoint getCenter(uint16_t width, uint16_t height) const;
+
+ void flip();
+};
+
} // namespace mbgl
#endif