summaryrefslogtreecommitdiff
path: root/src/mbgl/util/geo.cpp
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 /src/mbgl/util/geo.cpp
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 'src/mbgl/util/geo.cpp')
-rw-r--r--src/mbgl/util/geo.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mbgl/util/geo.cpp b/src/mbgl/util/geo.cpp
index e82f4afad2..a0ba44c4a9 100644
--- a/src/mbgl/util/geo.cpp
+++ b/src/mbgl/util/geo.cpp
@@ -28,4 +28,16 @@ LatLngBounds::LatLngBounds(const TileID& id)
ne(TileID{ id.z, id.x + 1, id.y, id.sourceZ }) {
}
+PrecisionPoint EdgeInsets::getCenter(uint16_t width, uint16_t height) const {
+ return {
+ (width - left - right) / 2.0f + left,
+ (height - top - bottom) / 2.0f + top,
+ };
+}
+
+void EdgeInsets::flip() {
+ std::swap(top, bottom);
+ std::swap(left, right);
+}
+
} // end namespace mbgl