diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-04-06 12:17:18 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-04-06 13:58:56 -0700 |
commit | d8411f26d24b14b829ecab7617b403ad0c872ed8 (patch) | |
tree | bcf87cb294e2b8a65412dc39d79d0ce2904ecafc /include | |
parent | c5292b7536b5b3a7af83b6616aea84b0d65a4556 (diff) | |
download | qtlocation-mapboxgl-d8411f26d24b14b829ecab7617b403ad0c872ed8.tar.gz |
Tile::ID ⇢ TileID
This allows making both Tile and TileID private.
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/annotation.hpp | 55 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/map/tile.hpp | 90 | ||||
-rw-r--r-- | include/mbgl/map/transform_state.hpp | 7 |
4 files changed, 5 insertions, 149 deletions
diff --git a/include/mbgl/map/annotation.hpp b/include/mbgl/map/annotation.hpp deleted file mode 100644 index efd91d9087..0000000000 --- a/include/mbgl/map/annotation.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef MBGL_MAP_ANNOTATIONS -#define MBGL_MAP_ANNOTATIONS - -#include <mbgl/map/tile.hpp> -#include <mbgl/util/geo.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/std.hpp> -#include <mbgl/util/vec.hpp> - -#include <string> -#include <vector> -#include <mutex> -#include <memory> -#include <unordered_map> -#include <unordered_set> - -namespace mbgl { - -class Annotation; -class Map; -class LiveTile; - -using AnnotationIDs = std::vector<uint32_t>; - -class AnnotationManager : private util::noncopyable { -public: - AnnotationManager(); - ~AnnotationManager(); - - void setDefaultPointAnnotationSymbol(const std::string& symbol); - std::pair<std::vector<Tile::ID>, AnnotationIDs> addPointAnnotations( - const std::vector<LatLng>&, const std::vector<std::string>& symbols, const Map&); - std::vector<Tile::ID> removeAnnotations(const AnnotationIDs&, const Map&); - AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const Map&) const; - LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const; - - const LiveTile* getTile(Tile::ID const& id); - - static const std::string layerID; - -private: - inline uint32_t nextID(); - static vec2<double> projectPoint(const LatLng& point); - -private: - mutable std::mutex mtx; - std::string defaultPointAnnotationSymbol; - std::unordered_map<uint32_t, std::unique_ptr<Annotation>> annotations; - std::unordered_map<Tile::ID, std::pair<std::unordered_set<uint32_t>, std::unique_ptr<LiveTile>>, Tile::ID::Hash> tiles; - uint32_t nextID_ = 0; -}; - -} - -#endif diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index f8e082f693..129d463b25 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -192,7 +192,7 @@ private: void processTasks(); - void updateAnnotationTiles(const std::vector<Tile::ID>&); + void updateAnnotationTiles(const std::vector<TileID>&); enum class Mode : uint8_t { None, // we're not doing any processing diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp deleted file mode 100644 index 146ebe6ad7..0000000000 --- a/include/mbgl/map/tile.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef MBGL_MAP_TILE -#define MBGL_MAP_TILE - -#include <mbgl/util/mat4.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/ptr.hpp> - -#include <cstdint> -#include <bitset> -#include <cmath> -#include <cstdint> -#include <forward_list> -#include <iosfwd> -#include <string> -#include <functional> - -namespace mbgl { - -class TileData; -struct box; - -struct ClipID { - inline ClipID() {} - inline ClipID(const std::string &mask_, const std::string &reference_) : mask(mask_), reference(reference_) {} - - std::bitset<8> mask; - std::bitset<8> reference; - - inline bool operator==(const ClipID &other) const { - return mask == other.mask && reference == other.reference; - } -}; - -class Tile : private util::noncopyable { -public: - struct ID { - const int16_t w = 0; - const int8_t z = 0; - const int32_t x = 0, y = 0; - - inline explicit ID(int8_t z_, int32_t x_, int32_t y_) - : w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_) {} - - inline uint64_t to_uint64() const { - return ((std::pow(2, z) * y + x) * 32) + z; - } - - struct Hash { - std::size_t operator()(ID const& i) const { - return std::hash<uint64_t>()(i.to_uint64()); - } - }; - - inline bool operator==(const ID& rhs) const { - return w == rhs.w && z == rhs.z && x == rhs.x && y == rhs.y; - } - - inline bool operator!=(const ID& rhs) const { - return !operator==(rhs); - } - - inline bool operator<(const ID &rhs) const { - if (w != rhs.w) return w < rhs.w; - if (z != rhs.z) return z < rhs.z; - if (x != rhs.x) return x < rhs.x; - return y < rhs.y; - } - - ID parent(int8_t z) const; - ID normalized() const; - std::forward_list<ID> children(int32_t z) const; - bool isChildOf(const Tile::ID &id) const; - operator std::string() const; - }; - - static std::forward_list<Tile::ID> cover(int8_t z, const box& bounds); - -public: - explicit Tile(const ID& id); - -public: - const Tile::ID id; - ClipID clip; - mat4 matrix; - util::ptr<TileData> data; -}; - -} - -#endif diff --git a/include/mbgl/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp index c1a324a899..f6a00a4a3d 100644 --- a/include/mbgl/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -1,8 +1,6 @@ #ifndef MBGL_MAP_TRANSFORM_STATE #define MBGL_MAP_TRANSFORM_STATE -#include <mbgl/map/tile.hpp> - #include <mbgl/util/mat4.hpp> #include <mbgl/util/geo.hpp> #include <mbgl/util/vec.hpp> @@ -13,12 +11,15 @@ namespace mbgl { +class TileID; +struct box; + class TransformState { friend class Transform; public: // Matrix - void matrixFor(mat4& matrix, const Tile::ID& id) const; + void matrixFor(mat4& matrix, const TileID& id) const; box cornersToBox(uint32_t z) const; // Dimensions |