KOSMIndoorMap

ztile.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef OSM_ZTILE_H
8 #define OSM_ZTILE_H
9 
10 #include <array>
11 #include <cstdint>
12 
13 namespace OSM {
14 class BoundingBox;
15 
16 /** Tile in a quad tree made up out of z-order curve positions. */
17 class ZTile
18 {
19 public:
20  constexpr ZTile() = default;
21  constexpr inline ZTile(uint64_t _z, uint8_t _depth)
22  : z(_z)
23  , depth(_depth)
24  {}
25 
26  constexpr inline bool operator<(ZTile other) const
27  {
28  return depth == other.depth ? z < other.z : depth > other.depth;
29  }
30  constexpr inline bool operator==(ZTile other) const
31  {
32  return depth == other.depth && z == other.z;
33  }
34 
35  /** tile size in 1e7-th degrees **/
36  constexpr inline uint32_t size() const
37  {
38  return (1ull << depth) - 1;
39  }
40 
41  BoundingBox boundingBox() const;
42  bool intersects(BoundingBox bbox) const;
43  bool intersects(ZTile other) const;
44 
45  /** The parent tile in a quad tree. */
46  ZTile parent() const;
47  /** Split into four sub-tiles on one level below. */
48  std::array<ZTile, 4> quadSplit() const;
49 
50 
51  uint64_t z = 0;
52  uint8_t depth = 0;
53 };
54 
55 /** The smallest tile entirely containing the given bounding box. */
57 
58 }
59 
60 #endif // OSM_ZTILE_H
constexpr uint32_t size() const
tile size in 1e7-th degrees
Definition: ztile.h:36
std::array< ZTile, 4 > quadSplit() const
Split into four sub-tiles on one level below.
Definition: ztile.cpp:37
Tile in a quad tree made up out of z-order curve positions.
Definition: ztile.h:17
ZTile parent() const
The parent tile in a quad tree.
Definition: ztile.cpp:32
Bounding box, ie.
Definition: datatypes.h:95
Low-level types and functions to work with raw OSM data as efficiently as possible.
ZTile ztileFromBoundingBox(BoundingBox bbox)
The smallest tile entirely containing the given bounding box.
Definition: ztile.cpp:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.