diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-12 00:50:00 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-13 21:38:20 +0200 |
commit | 8e30a4a0806e970e727c3563b8ed57dbaf9a0fa0 (patch) | |
tree | 792abd2a0b6d19aac7e60d83cfa4c2d88893b936 /include/mbgl/map | |
parent | a396c6a7f082749476f332c976912f37cbd93c92 (diff) | |
download | qtlocation-mapboxgl-8e30a4a0806e970e727c3563b8ed57dbaf9a0fa0.tar.gz |
[core] Harden Transform anchor & padding usage
Use optional values for anchor & padding in Map and Transform functions
instead of NaNs. Added unit tests to stress some edge cases.
Diffstat (limited to 'include/mbgl/map')
-rw-r--r-- | include/mbgl/map/map.hpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 463bee7938..14595ade63 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -1,6 +1,7 @@ #ifndef MBGL_MAP_MAP #define MBGL_MAP_MAP +#include <mbgl/util/optional.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/image.hpp> #include <mbgl/map/update.hpp> @@ -98,23 +99,23 @@ public: // Position void moveBy(const ScreenCoordinate&, const Duration& = Duration::zero()); - void setLatLng(const LatLng&, const ScreenCoordinate&, const Duration& = Duration::zero()); - void setLatLng(const LatLng&, const EdgeInsets&, const Duration& = Duration::zero()); + void setLatLng(const LatLng&, optional<ScreenCoordinate>, const Duration& = Duration::zero()); + void setLatLng(const LatLng&, optional<EdgeInsets>, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const Duration& = Duration::zero()); - LatLng getLatLng(const EdgeInsets& = {}) const; - void resetPosition(const EdgeInsets& = {}); + LatLng getLatLng(optional<EdgeInsets> = {}) const; + void resetPosition(optional<EdgeInsets> = {}); // Scale - void scaleBy(double ds, const ScreenCoordinate& = { NAN, NAN }, const Duration& = Duration::zero()); - void setScale(double scale, const ScreenCoordinate& = { NAN, NAN }, const Duration& = Duration::zero()); + void scaleBy(double ds, optional<ScreenCoordinate> = {}, const Duration& = Duration::zero()); + void setScale(double scale, optional<ScreenCoordinate> = {}, const Duration& = Duration::zero()); double getScale() const; void setZoom(double zoom, const Duration& = Duration::zero()); - void setZoom(double zoom, const EdgeInsets&, const Duration& = Duration::zero()); + void setZoom(double zoom, optional<EdgeInsets>, const Duration& = Duration::zero()); double getZoom() const; void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); - void setLatLngZoom(const LatLng&, double zoom, const EdgeInsets&, const Duration& = Duration::zero()); - CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&); - CameraOptions cameraForLatLngs(const std::vector<LatLng>&, const EdgeInsets&); + void setLatLngZoom(const LatLng&, double zoom, optional<EdgeInsets>, const Duration& = Duration::zero()); + CameraOptions cameraForLatLngBounds(const LatLngBounds&, optional<EdgeInsets>); + CameraOptions cameraForLatLngs(const std::vector<LatLng>&, optional<EdgeInsets>); void resetZoom(); void setMinZoom(const double minZoom); double getMinZoom() const; @@ -124,15 +125,15 @@ public: // Rotation void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& = Duration::zero()); void setBearing(double degrees, const Duration& = Duration::zero()); - void setBearing(double degrees, const ScreenCoordinate&, const Duration& = Duration::zero()); - void setBearing(double degrees, const EdgeInsets&, const Duration& = Duration::zero()); + void setBearing(double degrees, optional<ScreenCoordinate>, const Duration& = Duration::zero()); + void setBearing(double degrees, optional<EdgeInsets>, const Duration& = Duration::zero()); double getBearing() const; void resetNorth(const Duration& = Milliseconds(500)); - void resetNorth(const EdgeInsets&, const Duration& = Milliseconds(500)); + void resetNorth(optional<EdgeInsets>, const Duration& = Milliseconds(500)); // Pitch void setPitch(double pitch, const Duration& = Duration::zero()); - void setPitch(double pitch, const ScreenCoordinate&, const Duration& = Duration::zero()); + void setPitch(double pitch, optional<ScreenCoordinate>, const Duration& = Duration::zero()); double getPitch() const; // North Orientation |