QGIS API Documentation 4.1.0-Master (9af12b5a203)
Loading...
Searching...
No Matches
qgscesiumutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscesiumutils.h
3 --------------------
4 begin : July 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ******************************************************************
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSCESIUMUTILS_H
20#define QGSCESIUMUTILS_H
21
22#include <nlohmann/json_fwd.hpp>
23#include <optional>
24
25#include "qgis.h"
26#include "qgis_core.h"
27#include "qgis_sip.h"
28#include "qgsbox3d.h"
29#include "qgsvector3d.h"
30
31#include <QQuaternion>
32#include <QVector>
33#include <QVector3D>
34
35#ifndef SIP_RUN
36using namespace nlohmann;
37#endif
38
40class QgsSphere;
42class QgsMatrix4x4;
44
45#ifndef SIP_RUN
46namespace tinygltf
47{
48 class Model;
49}
50#include "qgsgltfutils.h"
51#endif
52
60class CORE_EXPORT QgsCesiumUtils
61{
62 public:
63#ifndef SIP_RUN
64
70 static QgsBox3D parseRegion( const json &region );
71#endif
72
76 static QgsBox3D parseRegion( const QVariantList &region );
77
78#ifndef SIP_RUN
79
85 static QgsOrientedBox3D parseBox( const json &box );
86#endif
87
91 static QgsOrientedBox3D parseBox( const QVariantList &box );
92
93#ifndef SIP_RUN
94
100 static QgsSphere parseSphere( const json &sphere );
101#endif
102
106 static QgsSphere parseSphere( const QVariantList &sphere );
107
111 static QgsSphere transformSphere( const QgsSphere &sphere, const QgsMatrix4x4 &transform );
112
117 {
119 QByteArray gltf;
120
123 };
124
129 static B3DMContents extractGltfFromB3dm( const QByteArray &tileContent );
130
131#ifndef SIP_RUN
149 {
153 QVector<QVector3D> translations;
155 QVector<QQuaternion> rotations;
157 QVector<QVector3D> scales;
159 bool eastNorthUp = false;
160 };
161#endif
162
167 {
169 QByteArray gltf;
170
173
174#ifndef SIP_RUN
176 std::optional<TileI3dmData> instancing;
177#endif
178 };
179
188 Q_DECL_DEPRECATED static TileContents extractGltfFromTileContent( const QByteArray &tileContent ) SIP_DEPRECATED;
189
200 static QVector<QgsCesiumUtils::TileContents> extractTileContent( const QByteArray &tileContent, const QString &baseUri = QString() );
201
207
214 static QString appendQueryFromBaseUrl( const QString &contentUri, const QUrl &baseUrl );
215
216#ifndef SIP_RUN
217
235 static QVector<QgsGltfUtils::InstancedPrimitive> resolveInstancing(
236 const tinygltf::Model &model, const std::optional<TileI3dmData> &tileInstancing, Qgis::Axis gltfUpAxis, const QgsMatrix4x4 &tileTransform, const QgsVector3D &rtcCenter
237 );
238
239#endif // SIP_RUN
240};
241
242#endif // QGSCESIUMUTILS_H
Axis
Cartesian axes.
Definition qgis.h:2607
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
Contains utilities for working with Cesium data.
static QgsSphere parseSphere(const json &sphere)
Parses a sphere object from a Cesium JSON document.
static B3DMContents extractGltfFromB3dm(const QByteArray &tileContent)
Extracts GLTF binary data and other contents from the legacy b3dm (Batched 3D Model) tile format.
static QString appendQueryFromBaseUrl(const QString &contentUri, const QUrl &baseUrl)
Copies any query items from the base URL to the content URI - to replicate undocumented Cesium JS beh...
static QgsOrientedBox3D parseBox(const json &box)
Parses a box object from a Cesium JSON document to an oriented bounding box.
static QVector< QgsGltfUtils::InstancedPrimitive > resolveInstancing(const tinygltf::Model &model, const std::optional< TileI3dmData > &tileInstancing, Qgis::Axis gltfUpAxis, const QgsMatrix4x4 &tileTransform, const QgsVector3D &rtcCenter)
Resolves instancing from either i3dm data or EXT_mesh_gpu_instancing.
static QgsTiledSceneBoundingVolume boundingVolumeFromRegion(const QgsBox3D &region, const QgsCoordinateTransformContext &transformContext)
Calculates oriented bounding box in EPSG:4978 from "region" defined with min/max lat/lon coordinates ...
static QgsBox3D parseRegion(const json &region)
Parses a region object from a Cesium JSON object to a 3D box.
static QgsSphere transformSphere(const QgsSphere &sphere, const QgsMatrix4x4 &transform)
Applies a transform to a sphere.
static QVector< QgsCesiumUtils::TileContents > extractTileContent(const QByteArray &tileContent, const QString &baseUri=QString())
Parses tile content and returns a list of TileContents.
static Q_DECL_DEPRECATED TileContents extractGltfFromTileContent(const QByteArray &tileContent)
Parses tile content.
Contains information about the context in which a coordinate transform is executed.
A simple 4x4 matrix implementation useful for transformation in 3D space.
Represents a oriented (rotated) box in 3 dimensions.
A spherical geometry object.
Definition qgssphere.h:46
Represents a bounding volume for a tiled scene.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
#define SIP_DEPRECATED
Definition qgis_sip.h:113
Encapsulates the contents of a B3DM file.
QByteArray gltf
GLTF binary content.
QgsVector3D rtcCenter
Optional RTC center.
Encapsulates the contents of a 3D tile.
QgsVector3D rtcCenter
Center position of relative-to-center coordinates (when used).
QByteArray gltf
GLTF binary content.
std::optional< TileI3dmData > instancing
Optional instancing data, populated for i3dm tiles.
Raw per-instance data parsed from an i3dm feature table of a single tile.
QVector< QVector3D > translations
ECEF-relative positions (Z-up), relative to RTC_CENTER.
QVector< QVector3D > scales
Per-axis scale - (1,1,1) if unspecified.
int instanceCount
Number of instances.
bool eastNorthUp
Whether EAST_NORTH_UP rotations should be computed (deferred until tile transform is available).
QVector< QQuaternion > rotations
Quaternion (x,y,z,w) - identity if unspecified.