diff options
Diffstat (limited to 'src/mbgl/map/tile_id.hpp')
-rw-r--r-- | src/mbgl/map/tile_id.hpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mbgl/map/tile_id.hpp b/src/mbgl/map/tile_id.hpp index dddbce3bb7..a193b63392 100644 --- a/src/mbgl/map/tile_id.hpp +++ b/src/mbgl/map/tile_id.hpp @@ -6,6 +6,7 @@ #include <string> #include <functional> #include <forward_list> +#include <limits> namespace mbgl { @@ -25,12 +26,6 @@ public: return ((std::pow(2, z) * y + x) * 32) + z; } - struct Hash { - std::size_t operator()(const TileID& id) const { - return std::hash<uint64_t>()(id.to_uint64()); - } - }; - inline bool operator==(const TileID& rhs) const { return w == rhs.w && z == rhs.z && x == rhs.x && y == rhs.y; } @@ -48,12 +43,24 @@ public: TileID parent(int8_t z, int8_t sourceMaxZoom) const; TileID normalized() const; - std::forward_list<TileID> children(int8_t sourceMaxZoom) const; + std::forward_list<TileID> + children(int8_t sourceMaxZoom = std::numeric_limits<int8_t>::max()) const; bool isChildOf(const TileID&) const; operator std::string() const; - }; } // namespace mbgl +namespace std { +template <> +struct hash<mbgl::TileID> { + typedef mbgl::TileID argument_type; + typedef std::size_t result_type; + + result_type operator()(const mbgl::TileID& id) const { + return std::hash<uint64_t>()(id.to_uint64()); + } +}; +} // namespace std + #endif |