26 #include <boost/optional.hpp>
28 #include <olp/core/CoreApi.h>
65 enum { LevelCount = 32 };
66 enum { MaxLevel = LevelCount - 1 };
77 constexpr
TileKey() : row_(0), column_(0), level_(LevelCount) {}
87 return level_ < LevelCount && row_ < (1u << level_) &&
88 column_ < (1u << level_);
97 return level_ == other.level_ && row_ == other.row_ &&
98 column_ == other.column_;
107 return !operator==(other);
118 return level_ != other.level_
119 ? level_ < other.level_
120 : row_ != other.row_ ? row_ < other.row_
121 : column_ < other.column_;
184 std::uint32_t level);
191 constexpr std::uint32_t
Level()
const {
return level_; }
200 constexpr std::uint32_t
Row()
const {
return row_; }
209 constexpr std::uint32_t
RowCount()
const {
return 1 << level_; }
219 constexpr std::uint32_t
Column()
const {
return column_; }
228 constexpr std::uint32_t
ColumnCount()
const {
return 1 << level_; }
323 constexpr
bool HasNextRow()
const {
return row_ < (1u << level_) - 1; }
338 constexpr
bool HasNextColumn()
const {
return column_ < (1u << level_) - 1; }
404 std::uint32_t row_{0};
405 std::uint32_t column_{0};
406 std::uint32_t level_{LevelCount};
477 static inline constexpr std::uint32_t
RowsAtLevel(std::uint32_t level) {
491 return 1u << (level << 1u);
495 std::uint64_t key{0};
498 using TileKeyLevels = std::bitset<TileKey::LevelCount>;
507 CORE_API boost::optional<std::uint32_t> GetMinTileKeyLevel(
508 const TileKeyLevels& levels);
517 CORE_API boost::optional<std::uint32_t> GetMaxTileKeyLevel(
518 const TileKeyLevels& levels);
529 CORE_API boost::optional<std::uint32_t> GetNearestAvailableTileKeyLevel(
530 const TileKeyLevels& levels,
const std::uint32_t reference_level);
535 CORE_API std::ostream& operator<<(std::ostream& out,
545 struct hash<
olp::geo::TileKey> {
552 return std::hash<std::uint64_t>()(tile_key.
ToQuadKey64());
Addresses a tile in a quadtree.
Definition: TileKey.h:63
TileKey NextColumn() const
Gets the key of the tile that has the same level and row numbers but belongs to the next column.
static TileKey FromRowColumnLevel(std::uint32_t row, std::uint32_t column, std::uint32_t level)
Creates a tile key.
static TileKey FromQuadKey(const std::string &quad_key)
Creates a tile key from a quad string.
constexpr bool HasPreviousColumn() const
Checks whether there is the previous column at this level.
Definition: TileKey.h:368
bool IsParentOf(const TileKey &tile_key) const
Checks whether the current tile is a parent of another tile.
std::string ToQuadKey() const
Creates a quad string from a tile key to later use it in REST API calls.
TileKey AddedSubHereTile(const std::string &sub_here_tile) const
Gets the absolute quadkey that is constructed from its HERE child tile key.
TileKey & operator=(const TileKey &)=default
The default copy operator.
TileKey Parent() const
Gets the key of the parent tile.
TileKey ChangedLevelTo(std::uint32_t level) const
Gets a new tile key at the requested level.
constexpr std::uint32_t Column() const
Gets the tile column.
Definition: TileKey.h:219
constexpr bool operator==(const TileKey &other) const
Checks whether the tile keys are equal.
Definition: TileKey.h:96
constexpr std::uint32_t RowCount() const
Gets the number of available rows at the tile level.
Definition: TileKey.h:209
constexpr bool operator!=(const TileKey &other) const
Checks whether the tile keys are not equal.
Definition: TileKey.h:106
constexpr bool HasNextColumn() const
Checks whether there is the next column at this level.
Definition: TileKey.h:338
constexpr bool HasNextRow() const
Checks whether there is the next row at this level.
Definition: TileKey.h:323
constexpr bool IsValid() const
Checks whether the tile key is valid.
Definition: TileKey.h:86
constexpr std::uint32_t Row() const
Gets the tile row.
Definition: TileKey.h:200
std::uint64_t GetSubkey64(int delta) const
Gets a subquadkey that is a relative of its parent.
bool IsChildOf(const TileKey &tile_key) const
Checks whether the current tile is a child of another tile.
TileKey GetChild(TileKeyQuadrant direction) const
Gets the child of the current tile using a direction.
constexpr std::uint32_t ColumnCount() const
Gets the number of available columns at the tile level.
Definition: TileKey.h:228
std::string ToHereTile() const
Creates a HERE tile code string from a tile key to later use it in REST API calls.
TileKey GetChild(std::uint8_t index) const
Gets the child of the current tile by its index.
constexpr bool operator<(const TileKey &other) const
Implements the following order on tile keys so they can be used in maps: first level,...
Definition: TileKey.h:117
static TileKey FromHereTile(const std::string &key)
Creates a tile key from a HERE tile code string.
TileKey ChangedLevelBy(int delta) const
Gets a new tile key at a level that differs from this tile level by delta.
static TileKey FromQuadKey64(std::uint64_t quad_key)
Creates a tile key from a 64-bit Morton code.
constexpr std::uint32_t Level() const
Gets the tile level.
Definition: TileKey.h:191
TileKey NextRow() const
Gets the key of the tile that has the same level and column numbers but belongs to the next row.
TileKey PreviousColumn() const
Gets the key of the tile that has the same level and row numbers but belongs to the previous column.
TileKey AddedSubkey(const std::string &sub_quad_key) const
Gets the absolute quadkey that is constructed from its subquadkey.
constexpr TileKey(const TileKey &)=default
The default copy constructor.
std::uint64_t ToQuadKey64() const
Creates a 64-bit Morton code from a tile key.
constexpr TileKey()
Creates an invalid tile key.
Definition: TileKey.h:77
TileKey PreviousRow() const
Gets the key of the tile that has the same level and column numbers but belongs to the previous row.
constexpr bool HasPreviousRow() const
Checks whether there is the previous row at this level.
Definition: TileKey.h:353
TileKey AddedSubkey64(std::uint64_t sub_quad_key) const
Gets the absolute quadkey that is constructed from its subquadkey.
TileKeyQuadrant RelationshipToParent() const
Computes the direction of the relationship to the parent.
TileKeyQuadrant
The main direction used to find a child node or the relationship to the parent.
Definition: TileKey.h:74
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
A helper structure for basic operations on 64-bit Morton quadkeys.
Definition: TileKey.h:415
constexpr QuadKey64Helper Parent() const
Gets the quadkey of the parent.
Definition: TileKey.h:426
static constexpr std::uint32_t ChildrenAtLevel(std::uint32_t level)
Gets the number of children at a level.
Definition: TileKey.h:490
QuadKey64Helper AddedSubkey(QuadKey64Helper sub_key) const
Gets the absolute quadkey that is constructed from its subquadkey.
QuadKey64Helper GetSubkey(int delta) const
Gets a subquadkey that is a relative of its parent.
static constexpr std::uint32_t RowsAtLevel(std::uint32_t level)
Gets the number of rows at a given level.
Definition: TileKey.h:477
constexpr QuadKey64Helper Child() const
Gets the quadkey representing the first child of this quad.
Definition: TileKey.h:433
constexpr QuadKey64Helper(std::uint64_t key)
The default constructor.
Definition: TileKey.h:419
std::size_t operator()(const olp::geo::TileKey &tile_key) const
The hash function for tile keys.
Definition: TileKey.h:551