9 #ifndef GlobeEngine_SpatialKey_H
10 #define GlobeEngine_SpatialKey_H
21 for (
int i=0;i<D;i++) {
28 for (
int i=0;i<D;i++) {
39 std::string res = std::to_string(this->
lod);
40 for (
int i = 0; i<D; i++) {
41 res +=
"/" + std::to_string(this->
coord[i]);
46 friend std::ostream& operator<< (std::ostream &out, const SpatialTreeKey<D,T> &key) {
47 out <<
"Key: (" << key.lod;
48 for (
int i=0;i<D;i++) {
49 out <<
","<< key.coord[i];
91 return this->
lod < other.
lod;
98 unsigned int getX()
const {
return this->
coord[0]; };
99 void setX(
unsigned int _in) { this->
coord[0] = _in; };
152 void setInitial(
short _lod,
unsigned int _x,
unsigned int _y) {
160 this->
setLod(_copy->getLod());
161 this->
coord[0] = _copy->getX();
162 this->coord[1] = _copy->getY();
164 this->parent = _copy->parent;
165 for(
int i=0;i<4;i++){
166 this->childs[i] = _copy->childs[i];
174 std::shared_ptr< SpatialTreeKey2<T> >
getChildKey(
int _idx)
const {
178 this->childs[_idx] = std::make_shared<SpatialTreeKey2<T> >(this->
lod+1,this->
coord[0]*2, this->coord[1]*2);
181 this->childs[_idx] = std::make_shared<SpatialTreeKey2<T> >(this->
lod+1,this->
coord[0]*2 + 1, this->coord[1]*2);
184 this->childs[_idx] = std::make_shared<SpatialTreeKey2<T> >(this->
lod+1,this->
coord[0]*2, this->coord[1]*2 + 1);
187 this->childs[_idx] = std::make_shared<SpatialTreeKey2<T> >(this->
lod+1,this->
coord[0]*2 + 1, this->coord[1]*2 + 1);
190 std::cout <<
"Child key request out of range" << std::endl;
203 double powOfDiff =
pow(2.0f, _key->getLod() - this->
getLod());
205 for (
int i = 0; i < 2; i++){
206 keysProj[i] = this->
getCoord()[i] * powOfDiff;
208 int sidelenghtOfChild = (
int)(powOfDiff / 2.0f);
209 if (keysProj[0] <= _key->getX() && _key->getX() < keysProj[0] + sidelenghtOfChild) {
210 if (keysProj[1] <= _key->getY() && _key->getY() < keysProj[1] + sidelenghtOfChild) {
218 if (keysProj[1] <= _key->getY() && _key->getY() < keysProj[1] + sidelenghtOfChild) {
229 if(this->inViewFrustum && !other.inViewFrustum)
230 return this->inViewFrustum;
231 if(!this->inViewFrustum && other.inViewFrustum)
232 return this->inViewFrustum;
234 if(this->
lod != other.
lod)
235 return this->
lod < other.
lod;
252 std::shared_ptr< SpatialTreeKey2<T> > parent;
253 std::shared_ptr< SpatialTreeKey2<T> > childs[4];
SpatialTreeKey2()
Definition: SpatialKey.h:140
SpatialTreeKey1< short > SpatialKey1s
Definition: SpatialKey.h:118
void setX(unsigned int _in)
Definition: SpatialKey.h:247
void setInitial(short _lod, unsigned int _x, unsigned int _y)
Definition: SpatialKey.h:152
SpatialTreeKey1< int > SpatialKey1i
Definition: SpatialKey.h:120
short lod
Definition: SpatialKey.h:57
short getLod() const
Definition: SpatialKey.h:33
expr pow(half base, half exp)
Definition: Half.h:2231
SpatialTreeKey(short _lod)
Definition: SpatialKey.h:26
SpatialTreeKey2< unsigned char > SpatialKey2ub
Definition: SpatialKey.h:257
SpatialTreeKey2< short > SpatialKey2s
Definition: SpatialKey.h:258
typedef int(CALL_CONVENTION *func_type_com_asprise_ocr_setup)(bool)
unsigned int getY()
Definition: SpatialKey.h:248
T coord[D]
Definition: SpatialKey.h:58
SpatialTreeKey2(short _lod, unsigned int _x, unsigned int _y)
Definition: SpatialKey.h:148
void setLod(short _in)
Definition: SpatialKey.h:34
bool operator==(const SpatialTreeKey2 &other) const
Definition: SpatialKey.h:242
Definition: SpatialKey.h:61
SpatialTreeKey1< unsigned short > SpatialKey1us
Definition: SpatialKey.h:119
SpatialTreeKey1< unsigned char > SpatialKey1ub
Definition: SpatialKey.h:117
SpatialTreeKey2< char > SpatialKey2b
Definition: SpatialKey.h:256
SpatialTreeKey()
Definition: SpatialKey.h:19
bool isFirstChild() const
Definition: SpatialKey.h:102
Definition: SpatialKey.h:17
SpatialTreeKey1()
Definition: SpatialKey.h:64
bool childOrder
Definition: SpatialKey.h:111
SpatialTreeKey1(short _lod)
Definition: SpatialKey.h:70
void setChildOrder(bool _in)
Definition: SpatialKey.h:106
const T * getCoord() const
Definition: SpatialKey.h:36
std::shared_ptr< SpatialTreeKey2< T > > getChildKey(int _idx) const
Definition: SpatialKey.h:174
Definition: SpatialKey.h:137
SpatialTreeKey2(const std::shared_ptr< SpatialTreeKey2 > _copy)
Definition: SpatialKey.h:159
bool operator<(const SpatialTreeKey2 &other) const
Definition: SpatialKey.h:228
bool operator==(const SpatialTreeKey1 &other) const
Definition: SpatialKey.h:95
void setX(unsigned int _in)
Definition: SpatialKey.h:99
SpatialTreeKey1< unsigned int > SpatialKey1ui
Definition: SpatialKey.h:121
SpatialTreeKey1(short _lod, unsigned int _x)
Definition: SpatialKey.h:76
SpatialTreeKey1(short _lod, unsigned int _x, bool _order)
Definition: SpatialKey.h:82
SpatialTreeKey2< int > SpatialKey2i
Definition: SpatialKey.h:260
SpatialTreeKey2< unsigned int > SpatialKey2ui
Definition: SpatialKey.h:261
SpatialTreeKey1< char > SpatialKey1b
Definition: SpatialKey.h:116
void setY(unsigned int _in)
Definition: SpatialKey.h:249
bool operator<(const SpatialTreeKey1 &other) const
Definition: SpatialKey.h:89
int getChildIdxInDirectionTo(std::shared_ptr< SpatialTreeKey2< T > > _key)
Definition: SpatialKey.h:202
std::shared_ptr< SpatialTreeKey2< T > > getParentKey() const
Definition: SpatialKey.h:170
int getChildKeyInDirectionTo(std::shared_ptr< SpatialTreeKey2< T > > _key)
Definition: SpatialKey.h:198
SpatialTreeKey1< unsigned int > BinaryTreeKey
Definition: SpatialKey.h:114
unsigned int getX()
Definition: SpatialKey.h:246
SpatialTreeKey2< unsigned short > SpatialKey2us
Definition: SpatialKey.h:259
std::string getKeyAsString()
Definition: SpatialKey.h:38
unsigned int getX() const
Definition: SpatialKey.h:98
SpatialTreeKey2(short _lod)
Definition: SpatialKey.h:144
SpatialTreeKey1< unsigned int > MultiwayTreeKey
Definition: SpatialKey.h:115