KOSMIndoorMap

ztile.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
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
13namespace OSM {
14class BoundingBox;
15
16/** Tile in a quad tree made up out of z-order curve positions. */
17class ZTile
18{
19public:
20 constexpr ZTile() = default;
21 constexpr inline ZTile(uint64_t _z, uint8_t _depth)
22 : z(_z)
23 , depth(_depth)
24 {}
25
26 [[nodiscard]] constexpr inline bool operator<(ZTile other) const
27 {
28 return depth == other.depth ? z < other.z : depth > other.depth;
29 }
30 [[nodiscard]] 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 [[nodiscard]] constexpr inline uint32_t size() const
37 {
38 return (1ull << depth) - 1;
39 }
40
41 [[nodiscard]] BoundingBox boundingBox() const;
42 [[nodiscard]] bool intersects(BoundingBox bbox) const;
43 [[nodiscard]] bool intersects(ZTile other) const;
44
45 /** The parent tile in a quad tree. */
46 [[nodiscard]] ZTile parent() const;
47 /** Split into four sub-tiles on one level below. */
48 [[nodiscard]] 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. */
56ZTile ztileFromBoundingBox(BoundingBox bbox);
57
58}
59
60#endif // OSM_ZTILE_H
Bounding box, ie.
Definition datatypes.h:95
Tile in a quad tree made up out of z-order curve positions.
Definition ztile.h:18
std::array< ZTile, 4 > quadSplit() const
Split into four sub-tiles on one level below.
Definition ztile.cpp:37
ZTile parent() const
The parent tile in a quad tree.
Definition ztile.cpp:32
constexpr uint32_t size() const
tile size in 1e7-th degrees
Definition ztile.h:36
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-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.