cesium-native  0.41.0
S2CellID.h
1 #pragma once
2 
3 #include "Cartographic.h"
4 #include "GlobeRectangle.h"
5 #include "Library.h"
6 
7 #include <array>
8 #include <cstdint>
9 #include <string>
10 #include <string_view>
11 
12 namespace CesiumGeometry {
13 struct QuadtreeTileID;
14 }
15 
16 namespace CesiumGeospatial {
17 
47 class CESIUMGEOSPATIAL_API S2CellID {
48 public:
56  static S2CellID fromToken(const std::string_view& token);
57 
68  static S2CellID
69  fromFaceLevelPosition(uint8_t face, uint32_t level, uint64_t position);
70 
79  uint8_t face,
80  const CesiumGeometry::QuadtreeTileID& quadtreeTileID);
81 
90  S2CellID(uint64_t id);
91 
97  bool isValid() const;
98 
104  uint64_t getID() const { return this->_id; }
105 
109  std::string toToken() const;
110 
116  int32_t getLevel() const;
117 
121  uint8_t getFace() const;
122 
131 
142  std::array<Cartographic, 4> getVertices() const;
143 
150 
160  S2CellID getChild(size_t index) const;
161 
168 
169 private:
170  uint64_t _id;
171 };
172 
173 } // namespace CesiumGeospatial
A position defined by longitude, latitude, and height.
Definition: Cartographic.h:12
A two-dimensional, rectangular region on a globe, specified using longitude and latitude coordinates....
A 64-bit unsigned integer that uniquely identifies a cell in the S2 cell decomposition.
Definition: S2CellID.h:47
Cartographic getCenter() const
Gets the longitude/latitude position at the center of this cell.
int32_t getLevel() const
Gets the level of the cell from the cell ID.
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 ...
std::string toToken() const
Converts the cell ID to a hexadecimal token.
S2CellID getChild(size_t index) const
Gets a child cell of this cell.
GlobeRectangle computeBoundingRectangle() const
Computes the globe rectangle that bounds this cell.
uint64_t getID() const
Gets the ID of the cell.
Definition: S2CellID.h:104
bool isValid() const
Determines if this cell ID is valid.
S2CellID getParent() const
Gets the parent cell of this cell.
S2CellID(uint64_t id)
Constructs a new S2 cell ID.
uint8_t getFace() const
Gets the face id (0...5) for this S2 cell.
std::array< Cartographic, 4 > getVertices() const
Gets the vertices at the corners of the cell.
static S2CellID fromQuadtreeTileID(uint8_t face, const CesiumGeometry::QuadtreeTileID &quadtreeTileID)
Create an S2 id from a face and a quadtree tile id.
Basic geometry classes for Cesium.
Classes for geospatial computations in Cesium.
Uniquely identifies a node in a quadtree.