olp-cpp-sdk
1.22.0
|
Addresses a tile in a quadtree. More...
#include <TileKey.h>
Public Types | |
enum | { LevelCount = 32 } |
enum | { MaxLevel = LevelCount - 1 } |
enum class | TileKeyQuadrant : uint8_t { SW , SE , NW , NE , Invalid } |
The main direction used to find a child node or the relationship to the parent. More... | |
Public Member Functions | |
constexpr | TileKey () |
Creates an invalid tile key. | |
constexpr | TileKey (const TileKey &)=default |
The default copy constructor. | |
TileKey & | operator= (const TileKey &)=default |
The default copy operator. | |
constexpr bool | IsValid () const |
Checks whether the tile key is valid. | |
constexpr bool | operator== (const TileKey &other) const |
Checks whether the tile keys are equal. More... | |
constexpr bool | operator!= (const TileKey &other) const |
Checks whether the tile keys are not equal. More... | |
constexpr bool | operator< (const TileKey &other) const |
Implements the following order on tile keys so they can be used in maps: first level, row, and then column. More... | |
std::string | ToQuadKey () const |
Creates a quad string from a tile key to later use it in REST API calls. More... | |
std::string | ToHereTile () const |
Creates a HERE tile code string from a tile key to later use it in REST API calls. More... | |
std::uint64_t | ToQuadKey64 () const |
Creates a 64-bit Morton code from a tile key. More... | |
constexpr std::uint32_t | Level () const |
Gets the tile level. More... | |
constexpr std::uint32_t | Row () const |
Gets the tile row. More... | |
constexpr std::uint32_t | RowCount () const |
Gets the number of available rows at the tile level. More... | |
constexpr std::uint32_t | Column () const |
Gets the tile column. More... | |
constexpr std::uint32_t | ColumnCount () const |
Gets the number of available columns at the tile level. More... | |
TileKey | Parent () const |
Gets the key of the parent tile. More... | |
bool | IsChildOf (const TileKey &tile_key) const |
Checks whether the current tile is a child of another tile. More... | |
bool | IsParentOf (const TileKey &tile_key) const |
Checks whether the current tile is a parent of another tile. More... | |
TileKey | ChangedLevelBy (int delta) const |
Gets a new tile key at a level that differs from this tile level by delta. More... | |
TileKey | ChangedLevelTo (std::uint32_t level) const |
Gets a new tile key at the requested level. More... | |
std::uint64_t | GetSubkey64 (int delta) const |
Gets a subquadkey that is a relative of its parent. More... | |
TileKey | AddedSubkey64 (std::uint64_t sub_quad_key) const |
Gets the absolute quadkey that is constructed from its subquadkey. More... | |
TileKey | AddedSubkey (const std::string &sub_quad_key) const |
Gets the absolute quadkey that is constructed from its subquadkey. More... | |
TileKey | AddedSubHereTile (const std::string &sub_here_tile) const |
Gets the absolute quadkey that is constructed from its HERE child tile key. More... | |
constexpr bool | HasNextRow () const |
Checks whether there is the next row at this level. More... | |
TileKey | NextRow () const |
Gets the key of the tile that has the same level and column numbers but belongs to the next row. More... | |
constexpr bool | HasNextColumn () const |
Checks whether there is the next column at this level. More... | |
TileKey | NextColumn () const |
Gets the key of the tile that has the same level and row numbers but belongs to the next column. More... | |
constexpr bool | HasPreviousRow () const |
Checks whether there is the previous row at this level. More... | |
TileKey | PreviousRow () const |
Gets the key of the tile that has the same level and column numbers but belongs to the previous row. More... | |
constexpr bool | HasPreviousColumn () const |
Checks whether there is the previous column at this level. More... | |
TileKey | PreviousColumn () const |
Gets the key of the tile that has the same level and row numbers but belongs to the previous column. More... | |
TileKey | GetChild (std::uint8_t index) const |
Gets the child of the current tile by its index. More... | |
TileKey | GetChild (TileKeyQuadrant direction) const |
Gets the child of the current tile using a direction. More... | |
TileKeyQuadrant | RelationshipToParent () const |
Computes the direction of the relationship to the parent. More... | |
Static Public Member Functions | |
static TileKey | FromQuadKey (const std::string &quad_key) |
Creates a tile key from a quad string. More... | |
static TileKey | FromHereTile (const std::string &key) |
Creates a tile key from a HERE tile code string. More... | |
static TileKey | FromQuadKey64 (std::uint64_t quad_key) |
Creates a tile key from a 64-bit Morton code. More... | |
static TileKey | FromRowColumnLevel (std::uint32_t row, std::uint32_t column, std::uint32_t level) |
Creates a tile key. More... | |
Addresses a tile in a quadtree.
Each tile key is defined by a row, a column, and a level. The tree has a root at level 0 with one single tile. At every level, each tile is divided into four child tiles (hence the name quadtree).
Within a level, each tile has its unique row and column numbers. The number of rows and columns in each level is 2 to the power of the level. It means that on level 0, there is only one tile in one row and one column. At level 1, there are four tiles in two rows and two columns. At level 2, there are 16 tiles in four rows and four columns. And so on.
To create a tile key, use FromRowColumnLevel()
.
For vertical navigation within the tree, use the following functions: Parent()
, ChangedLevelBy()
, and ChangedLevelTo()
. To navigate within a level, use the HasNextRow()
, NextRow()
, HasNextColumn()
, and NextColumn()
functions. To get the number of available rows and columns on the tile level, use RowCount()
and ColumnCount()
.
You can also create tile keys from and converted them into various alternative formats:
ToQuadKey()
/ FromQuadKey()
– 4-based string representation.ToHereTile()
/ FromHereTile()
– 10-based string representation.ToQuadKey64()
/ FromQuadKey64()
– 64-bit Morton code representation.
|
strong |
The main direction used to find a child node or the relationship to the parent.
Corresponds directly to the index in the GetChild
function.
TileKey olp::geo::TileKey::AddedSubHereTile | ( | const std::string & | sub_here_tile | ) | const |
Gets the absolute quadkey that is constructed from its HERE child tile key.
sub_here_tile | The HERE child tile key. |
TileKey olp::geo::TileKey::AddedSubkey | ( | const std::string & | sub_quad_key | ) | const |
Gets the absolute quadkey that is constructed from its subquadkey.
It is the reverse function of GetSubkey()
. It returns the absolute quadkey in the tree based on the subquadkey.
sub_quad_key | The subquadkey generated with ToSubQuadKey() . |
TileKey olp::geo::TileKey::AddedSubkey64 | ( | std::uint64_t | sub_quad_key | ) | const |
Gets the absolute quadkey that is constructed from its subquadkey.
It is the reverse function of GetSubkey()
. It returns the absolute quadkey in the tree based on the subquadkey.
sub_quad_key | The subquadkey generated with ToSubQuadKey() . |
TileKey olp::geo::TileKey::ChangedLevelBy | ( | int | delta | ) | const |
Gets a new tile key at a level that differs from this tile level by delta.
Equivalent to changedLevelTo(Level() + delta)
delta | The numeric difference between the current level and the requested level. |
TileKey olp::geo::TileKey::ChangedLevelTo | ( | std::uint32_t | level | ) | const |
Gets a new tile key at the requested level.
level | The requested level. |
|
inlineconstexpr |
Gets the tile column.
To get the number of available columns on a tile level, use ColumnCount()
.
|
inlineconstexpr |
Gets the number of available columns at the tile level.
It is 2 to the power of the level.
|
static |
Creates a tile key from a HERE tile code string.
To convert the tile key back into the string, use ToHereTile()
.
|
static |
Creates a tile key from a quad string.
To convert the tile key back into the quad string, use ToQuadKey()
.
|
static |
Creates a tile key from a 64-bit Morton code.
To convert a tile key back into a 64-bit Morton code, use ToQuadKey64()
.
|
static |
Creates a tile key.
row | The requested row. Must be less than 2 to the power of the level. |
column | The requested column. Must be less than 2 to the power of the level. |
level | The requested level. |
TileKey olp::geo::TileKey::GetChild | ( | std::uint8_t | index | ) | const |
Gets the child of the current tile by its index.
index | The child index from the [0, 3] range. |
TileKey olp::geo::TileKey::GetChild | ( | TileKeyQuadrant | direction | ) | const |
Gets the child of the current tile using a direction.
direction | The direction to get the child tile. |
std::uint64_t olp::geo::TileKey::GetSubkey64 | ( | int | delta | ) | const |
Gets a subquadkey that is a relative of its parent.
Use this function to generate subkeys that are relatives of a parent that is delta levels up in the subtree.
You can also use this function to create shortened keys for quads on lower levels if the parent is known.
delta | The number of levels that are relatives of the parent quadkey. Must be greater or equal to 0 and smaller than 32. |
|
inlineconstexpr |
Checks whether there is the next column at this level.
|
inlineconstexpr |
Checks whether there is the next row at this level.
|
inlineconstexpr |
Checks whether there is the previous column at this level.
|
inlineconstexpr |
Checks whether there is the previous row at this level.
bool olp::geo::TileKey::IsChildOf | ( | const TileKey & | tile_key | ) | const |
Checks whether the current tile is a child of another tile.
[in] | tile_key | The key of the possible parent tile. |
bool olp::geo::TileKey::IsParentOf | ( | const TileKey & | tile_key | ) | const |
Checks whether the current tile is a parent of another tile.
[in] | tile_key | The key of the child tile. |
|
inlineconstexpr |
Gets the tile level.
TileKey olp::geo::TileKey::NextColumn | ( | ) | const |
Gets the key of the tile that has the same level and row numbers but belongs to the next column.
TileKey olp::geo::TileKey::NextRow | ( | ) | const |
Gets the key of the tile that has the same level and column numbers but belongs to the next row.
|
inlineconstexpr |
Checks whether the tile keys are not equal.
other | The other tile key. |
|
inlineconstexpr |
Implements the following order on tile keys so they can be used in maps: first level, row, and then column.
If you need more locality, use the 64-bit Morton encoding instead (ToQuadKey64()
).
|
inlineconstexpr |
Checks whether the tile keys are equal.
other | The other tile key. |
TileKey olp::geo::TileKey::Parent | ( | ) | const |
Gets the key of the parent tile.
If the tile is the root tile, an invalid tile key is returned.
TileKey olp::geo::TileKey::PreviousColumn | ( | ) | const |
Gets the key of the tile that has the same level and row numbers but belongs to the previous column.
TileKey olp::geo::TileKey::PreviousRow | ( | ) | const |
Gets the key of the tile that has the same level and column numbers but belongs to the previous row.
TileKeyQuadrant olp::geo::TileKey::RelationshipToParent | ( | ) | const |
Computes the direction of the relationship to the parent.
Invalid
if the tile key represents the root.
|
inlineconstexpr |
|
inlineconstexpr |
Gets the number of available rows at the tile level.
It is 2 to the power of the level.
std::string olp::geo::TileKey::ToHereTile | ( | ) | const |
Creates a HERE tile code string from a tile key to later use it in REST API calls.
The string is a quadkey Morton code.
To convert the HERE tile code string back into the tile key, use FromHereTile()
.
std::string olp::geo::TileKey::ToQuadKey | ( | ) | const |
Creates a quad string from a tile key to later use it in REST API calls.
If the tile is the root tile, the quadkey is '-'. Otherwise, the string is a number to the base of 4 without the leading 1 and has the following properties:
To convert the quadkey string back into the tile key, use FromQuadKey()
.
std::uint64_t olp::geo::TileKey::ToQuadKey64 | ( | ) | const |
Creates a 64-bit Morton code from a tile key.
To convert the 64-bit Morton code back into the tile key, use FromQuadKey64()
.