QGIS API Documentation 4.1.0-Master (64dc32379c2)
Loading...
Searching...
No Matches
qgscesiumimplicittiling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscesiumimplicittiling.h
3 -------------------------
4 begin : March 2026
5 copyright : (C) 2026 by Martin Dobias
6 email : wonder dot sk at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSCESIUMIMPLICITTILING_H
19#define QGSCESIUMIMPLICITTILING_H
20
21#include <nlohmann/json.hpp>
22
23#include "qgis_core.h"
25
26#include <QBitArray>
27#include <QUrl>
28
29#define SIP_NO_FILE
30
32
43class CORE_EXPORT QgsCesiumImplicitTiling
44{
45 public:
48 {
49 int level = 0;
50 int x = 0;
51 int y = 0;
52
53 auto operator<=>( const TileCoordinate & ) const = default;
54 bool operator==( const TileCoordinate & ) const = default;
55
56 friend inline size_t qHash( const TileCoordinate &c, size_t seed = 0 ) { return qHashMulti( seed, c.level, c.x, c.y ); }
57 };
58
70 struct Subtree
71 {
96 };
97
106 struct Root
107 {
108 // definition of the tiling scheme
109
117
118 // data related to the root node
119
123 std::optional<QgsBox3D> rootRegion;
124
127 std::optional<QgsMatrix4x4> rootTransform;
129
130 QMap<TileCoordinate, Subtree> subtreeCache;
131 };
132
134 static bool parseImplicitTiling( const json &tileJson, QgsTiledSceneNode *newNode, const QUrl &baseUrl, Qgis::Axis gltfUpAxis, Root &tilingData );
135
137 static Subtree parseSubtree( const Root &tilingData, const QByteArray &data );
138
140 static QString expandTemplateUri( const QString &templateUri, const QUrl &baseUrl, const TileCoordinate &coord );
141
143 static TileCoordinate tileCoordinateToParentSubtree( TileCoordinate coord, int subtreeLevels );
144
146 static QMap<TileCoordinate, QgsTiledSceneNode *> createImplicitTilingChildren(
147 QgsTiledSceneNode *node, const TileCoordinate &coord, Root &tilingData, const TileCoordinate &subtreeCoord, QgsCoordinateTransformContext &transformContext, long long &nextTileId
148 );
149
151 static Qgis::TileChildrenAvailability childAvailability( const Root &tilingData, const TileCoordinate &coord );
152
154 static int subtreeBitIndex( int localLevel, int localX, int localY );
155
156 private:
157 static int subtreeTileCount( int levels );
158 static int mortonIndex( int x, int y );
159 static QgsTiledSceneBoundingVolume computeImplicitBoundingVolume( const QgsTiledSceneBoundingVolume &rootVolume, const TileCoordinate &coord );
160 static QgsBox3D computeImplicitRegionBoundingVolume( const QgsBox3D &rootRegion, const TileCoordinate &coord );
161};
162
163#endif // QGSCESIUMIMPLICITTILING_H
TileChildrenAvailability
Possible availability states for a tile's children.
Definition qgis.h:6194
Axis
Cartesian axes.
Definition qgis.h:2607
@ Y
Y-axis.
Definition qgis.h:2609
TileRefinementProcess
Tiled scene tile refinement processes.
Definition qgis.h:6182
@ Replacement
When tile is refined then its children should be used in place of itself.
Definition qgis.h:6183
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
Contains utilities for working with Cesium 3D Tiles implicit tiling.
static QMap< TileCoordinate, QgsTiledSceneNode * > createImplicitTilingChildren(QgsTiledSceneNode *node, const TileCoordinate &coord, Root &tilingData, const TileCoordinate &subtreeCoord, QgsCoordinateTransformContext &transformContext, long long &nextTileId)
Creates immediate children of a node according to implicit tiling.
static TileCoordinate tileCoordinateToParentSubtree(TileCoordinate coord, int subtreeLevels)
Returns parent subtree's tile coordinates of the given tile.
static QString expandTemplateUri(const QString &templateUri, const QUrl &baseUrl, const TileCoordinate &coord)
Expands template URI (using {level}, {x}, {y} markers) to the final URI.
static Qgis::TileChildrenAvailability childAvailability(const Root &tilingData, const TileCoordinate &coord)
Returns tile availability of a child based on cached subtree data.
static bool parseImplicitTiling(const json &tileJson, QgsTiledSceneNode *newNode, const QUrl &baseUrl, Qgis::Axis gltfUpAxis, Root &tilingData)
Parses JSON definition of implicit tiling into tilingData argument and returns true on success.
static Subtree parseSubtree(const Root &tilingData, const QByteArray &data)
Parses subtree definition and returns it.
static int subtreeBitIndex(int localLevel, int localX, int localY)
Returns the bit index within a subtree's availability bitstream for a given local tile position.
Contains information about the context in which a coordinate transform is executed.
Represents a bounding volume for a tiled scene.
Allows representing QgsTiledSceneTiles in a hierarchical tree.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition of root implicit tiling node (typically root node of the whole tileset,...
QMap< TileCoordinate, Subtree > subtreeCache
Qgis::TileRefinementProcess refinementProcess
std::optional< QgsBox3D > rootRegion
if the root node uses "region" bounding volume (in lat/lon), we use it to create child regions and th...
int subtreeLevels
how many levels are stored in a single subtree
int availableLevels
total number of available levels within the implicit tiling
std::optional< QgsMatrix4x4 > rootTransform
QgsTiledSceneBoundingVolume rootBoundingVolume
if the root node uses OBB as the bounding volume, we use it directly to create child volumes
Data about subtree of a node - there should be subtree at least for root implicit tiling node,...
QBitArray contentAvailability
Bit array whether a tile has some content.
QBitArray tileAvailability
Bit array whether a tile is available.
QBitArray childSubtreeAvailability
Bit array to know where to look for more subtree definitions deeper in the hierarchy.
Contains ZXY coordinates of a node within implicit tiling.
bool operator==(const TileCoordinate &) const =default
friend size_t qHash(const TileCoordinate &c, size_t seed=0)
auto operator<=>(const TileCoordinate &) const =default