cesium-native
0.41.0
|
A 64-bit unsigned integer that uniquely identifies a cell in the S2 cell decomposition. More...
#include <CesiumGeospatial/S2CellID.h>
Public Member Functions | |
S2CellID (uint64_t id) | |
Constructs a new S2 cell ID. More... | |
bool | isValid () const |
Determines if this cell ID is valid. More... | |
uint64_t | getID () const |
Gets the ID of the cell. More... | |
std::string | toToken () const |
Converts the cell ID to a hexadecimal token. | |
int32_t | getLevel () const |
Gets the level of the cell from the cell ID. More... | |
uint8_t | getFace () const |
Gets the face id (0...5) for this S2 cell. | |
Cartographic | getCenter () const |
Gets the longitude/latitude position at the center of this cell. More... | |
std::array< Cartographic, 4 > | getVertices () const |
Gets the vertices at the corners of the cell. More... | |
S2CellID | getParent () const |
Gets the parent cell of this cell. More... | |
S2CellID | getChild (size_t index) const |
Gets a child cell of this cell. More... | |
GlobeRectangle | computeBoundingRectangle () const |
Computes the globe rectangle that bounds this cell. More... | |
Static Public Member Functions | |
static S2CellID | fromToken (const std::string_view &token) |
static S2CellID | fromFaceLevelPosition (uint8_t face, uint32_t level, uint64_t position) |
Creates a cell given its face (range 0..5), level, and Hilbert curve cell index within that face and level. More... | |
static S2CellID | fromQuadtreeTileID (uint8_t face, const CesiumGeometry::QuadtreeTileID &quadtreeTileID) |
Create an S2 id from a face and a quadtree tile id. More... | |
A 64-bit unsigned integer that uniquely identifies a cell in the S2 cell decomposition.
It has the following format:
id = [face][face_pos]
face: a 3-bit number (range 0..5) encoding the cube face.
face_pos: a 61-bit number encoding the position of the center of this cell along the Hilbert curve over this face (see the Wiki pages for details).
Sequentially increasing cell ids follow a continuous space-filling curve over the entire sphere. They have the following properties:
This class is adapted from S2CellId in https://github.com/google/s2geometry.
Definition at line 47 of file S2CellID.h.
CesiumGeospatial::S2CellID::S2CellID | ( | uint64_t | id | ) |
Constructs a new S2 cell ID.
The cell ID value is not validated. Use isValid to check the validity after constructions.
id | The 64-bit cell ID value. |
GlobeRectangle CesiumGeospatial::S2CellID::computeBoundingRectangle | ( | ) | const |
Computes the globe rectangle that bounds this cell.
|
static |
Creates a cell given its face (range 0..5), level, and Hilbert curve cell index within that face and level.
face | The face index. |
level | The level within the face. |
position | The Hilbert-order index of the cell within the face and level. |
|
static |
Create an S2 id from a face and a quadtree tile id.
face | The S2 face (0...5) that this tile is on. |
quadtreeTileID | The quadtree tile id for this tile, within the given face. |
|
static |
Cartographic CesiumGeospatial::S2CellID::getCenter | ( | ) | const |
Gets the longitude/latitude position at the center of this cell.
The height is always 0.0.
S2CellID CesiumGeospatial::S2CellID::getChild | ( | size_t | index | ) | const |
Gets a child cell of this cell.
If the index is less than 0 or greater than 3, or if this is a leaf cell, the behavior is unspecified.
index | The index in the range 0 to 3. |
|
inline |
int32_t CesiumGeospatial::S2CellID::getLevel | ( | ) | const |
Gets the level of the cell from the cell ID.
S2CellID CesiumGeospatial::S2CellID::getParent | ( | ) | const |
Gets the parent cell of this cell.
If this is a root cell, the behavior is unspecified.
std::array<Cartographic, 4> CesiumGeospatial::S2CellID::getVertices | ( | ) | const |
Gets the vertices at the corners of the cell.
The height values are always 0.0.
Note that all positions inside the S2 Cell are not guaranteed to fall inside the rectangle formed by these vertices.
bool CesiumGeospatial::S2CellID::isValid | ( | ) | const |
Determines if this cell ID is valid.