summaryrefslogtreecommitdiff
path: root/include/mbgl/util/geo.hpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2015-11-10 11:45:07 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2015-11-11 16:59:49 +0200
commite5c460f2db3f7506f4fc38b16747f0ace9151017 (patch)
tree4184fd983cbc254748c93b316412bc043c393c25 /include/mbgl/util/geo.hpp
parent54e08b1f83504e12cbc19b08295d9f9ed5177ab5 (diff)
downloadqtlocation-mapboxgl-e5c460f2db3f7506f4fc38b16747f0ace9151017.tar.gz
[core] Added isValid to geo helper structs
Diffstat (limited to 'include/mbgl/util/geo.hpp')
-rw-r--r--include/mbgl/util/geo.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index 307134f666..bfcb84bd7c 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -14,6 +14,10 @@ struct LatLng {
inline LatLng(double lat = 0, double lon = 0)
: latitude(lat), longitude(lon) {}
+ inline bool isValid() const {
+ return !(std::isnan(latitude) || std::isnan(longitude));
+ }
+
// Constructs a LatLng object with the top left position of the specified tile.
LatLng(const TileID& id);
@@ -26,6 +30,10 @@ struct ProjectedMeters {
inline ProjectedMeters(double n = 0, double e = 0)
: northing(n), easting(e) {}
+
+ inline bool isValid() const {
+ return !(std::isnan(northing) || std::isnan(easting));
+ }
};
struct LatLngBounds {
@@ -35,6 +43,10 @@ struct LatLngBounds {
inline LatLngBounds(LatLng sw_ = {90, 180}, LatLng ne_ = {-90, -180})
: sw(sw_), ne(ne_) {}
+ inline bool isValid() const {
+ return sw.isValid() && ne.isValid();
+ }
+
// Constructs a LatLngBounds object with the tile's exact boundaries.
LatLngBounds(const TileID& id);