Merge branch 'master' of github.com:mapbox/llmr-native
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
||||
int8_t z = 0;
|
||||
int32_t x = 0, y = 0;
|
||||
|
||||
inline ID(uint8_t z, uint32_t x, uint32_t y)
|
||||
inline ID(int8_t z, int32_t x, int32_t y)
|
||||
: z(z), x(x), y(y) {
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
return z == rhs.z && x == rhs.x && y == rhs.y;
|
||||
}
|
||||
|
||||
ID parent(int32_t z) const;
|
||||
ID parent(int8_t z) const;
|
||||
void normalize();
|
||||
ID normalized() const;
|
||||
std::forward_list<ID> children(int32_t z) const;
|
||||
|
||||
@@ -8,15 +8,14 @@ Tile::Tile(const ID& id)
|
||||
: id(id) {
|
||||
}
|
||||
|
||||
Tile::ID Tile::ID::parent(int32_t parent_z) const {
|
||||
Tile::ID Tile::ID::parent(int8_t parent_z) const {
|
||||
assert(parent_z < z);
|
||||
ID pos(z, x, y);
|
||||
while (pos.z > parent_z) {
|
||||
--pos.z;
|
||||
pos.x = floor(pos.x / 2);
|
||||
pos.y = floor(pos.y / 2);
|
||||
}
|
||||
return pos;
|
||||
int32_t dim = pow(2, z - parent_z);
|
||||
return Tile::ID{
|
||||
parent_z,
|
||||
(x >= 0 ? x : x - dim + 1) / dim,
|
||||
y / dim
|
||||
};
|
||||
}
|
||||
|
||||
std::forward_list<Tile::ID> Tile::ID::children(int32_t child_z) const {
|
||||
|
||||
Reference in New Issue
Block a user