diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2015-11-12 17:19:34 +0200 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-11-12 10:46:50 -0800 |
commit | 8b76f00d8cc617abb492c368fc6887183147402b (patch) | |
tree | 584e43e8147ec69be9097a0c52f4309fe639593a /include/mbgl/util/geo.hpp | |
parent | 6748b6155e0bdb61aa33ecfe467711ce7e1189c3 (diff) | |
download | qtlocation-mapboxgl-8b76f00d8cc617abb492c368fc6887183147402b.tar.gz |
[core] PrecisionPoint is now a vec2<double>
We could reuse all the operators defined in vec2<>, including operator
bool() that checks if the contained values are !NaN.
Diffstat (limited to 'include/mbgl/util/geo.hpp')
-rw-r--r-- | include/mbgl/util/geo.hpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index dd2b1567fc..98b5daa6f5 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -9,17 +9,7 @@ namespace mbgl { class TileID; -struct PrecisionPoint { - double x = 0; - double y = 0; - - inline PrecisionPoint(double x_ = 0, double y_ = 0) - : x(x_), y(y_) {} - - inline bool isValid() const { - return !(std::isnan(x) || std::isnan(y)); - } -}; +using PrecisionPoint = vec2<double>; struct LatLng { double latitude = 0; @@ -28,7 +18,7 @@ struct LatLng { inline LatLng(double lat = 0, double lon = 0) : latitude(lat), longitude(lon) {} - inline bool isValid() const { + inline operator bool() const { return !(std::isnan(latitude) || std::isnan(longitude)); } @@ -45,7 +35,7 @@ struct ProjectedMeters { inline ProjectedMeters(double n = 0, double e = 0) : northing(n), easting(e) {} - inline bool isValid() const { + inline operator bool() const { return !(std::isnan(northing) || std::isnan(easting)); } }; @@ -57,8 +47,8 @@ struct LatLngBounds { inline LatLngBounds(const LatLng& sw_ = {90, 180}, const LatLng& ne_ = {-90, -180}) : sw(sw_), ne(ne_) {} - inline bool isValid() const { - return sw.isValid() && ne.isValid(); + inline operator bool() const { + return sw && ne; } // Constructs a LatLngBounds object with the tile's exact boundaries. @@ -98,8 +88,8 @@ struct MetersBounds { inline MetersBounds(const ProjectedMeters& sw_, const ProjectedMeters& ne_) : sw(sw_), ne(ne_) {} - inline bool isValid() const { - return sw.isValid() && ne.isValid(); + inline operator bool() const { + return sw && ne; } }; |