QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsquantizedmeshdataprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsquantizedmeshdataprovider.h
3 --------------------
4 begin : June 2024
5 copyright : (C) 2024 by David Koňařík
6 email : dvdkon at konarici dot cz
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#pragma once
20
21#include "qgis.h"
24#include "qgshttpheaders.h"
25#include "qgsprovidermetadata.h"
28#include "qgstiledsceneindex.h"
29#include "qgstiles.h"
30#include <optional>
31#include <qmap.h>
32#include <qvector.h>
33
34#define SIP_NO_FILE
35
37
38class CORE_EXPORT QgsQuantizedMeshMetadata
39{
40 public:
41
45 QgsQuantizedMeshMetadata( const QString &uri,
46 const QgsCoordinateTransformContext &transformContext,
47 QgsError &error );
48
49 bool containsTile( QgsTileXYZ tile ) const;
50 double geometricErrorAtZoom( int zoom ) const;
51
52 QString mAuthCfg;
53 QgsHttpHeaders mHeaders;
54
55 QgsRectangle mExtent;
56 QgsTiledSceneBoundingVolume mBoundingVolume;
57 // Map of zoom level -> list of AABBs of available tiles (tile index ranges)
58 QVector<QVector<QgsTileRange>> mAvailableTiles;
60 QString mTileScheme;
61 uint8_t mMinZoom;
62 uint8_t mMaxZoom;
63 std::vector<QString> mTileUrls;
64 QgsTileMatrix mTileMatrix;
65
66 // The Quantized Mesh TileJSON(-ish) metadata doesn't tell us, so choose something big enough for Earth
67 static const QgsDoubleRange dummyZRange;
68};
69
70class CORE_EXPORT QgsQuantizedMeshIndex : public QgsAbstractTiledSceneIndex
71{
72 public:
73 QgsQuantizedMeshIndex( const QgsQuantizedMeshMetadata &metadata,
74 const QgsCoordinateTransform &wgs84ToCrs )
75 : mMetadata( metadata ), mWgs84ToCrs( wgs84ToCrs ) {}
76 QgsTiledSceneTile rootTile() const override;
77 long long parentTileId( long long id ) const override;
78 QVector< long long > childTileIds( long long id ) const override;
79 QgsTiledSceneTile getTile( long long id ) override;
80 QVector< long long > getTiles( const QgsTiledSceneRequest &request ) override;
81 Qgis::TileChildrenAvailability childAvailability( long long id ) const override;
82 bool fetchHierarchy( long long id, QgsFeedback *feedback = nullptr ) override;
83
84 // Tile ID coding scheme:
85 // From MSb, 2 bits zero, 1 bit one, 5 bits zoom, 28 bits X, 28 bits Y
86 static long long encodeTileId( QgsTileXYZ tile );
87 static QgsTileXYZ decodeTileId( long long id );
88
89 static constexpr long long ROOT_TILE_ID = std::numeric_limits<long long>::max();
90
91 protected:
92 QByteArray fetchContent( const QString &uri, QgsFeedback *feedback = nullptr ) override;
93
94 QgsQuantizedMeshMetadata mMetadata;
95 QgsCoordinateTransform mWgs84ToCrs;
96};
97
98class CORE_EXPORT QgsQuantizedMeshDataProvider: public QgsTiledSceneDataProvider
99{
100 Q_OBJECT
101 public:
102 QgsQuantizedMeshDataProvider( const QString &uri,
103 const QgsDataProvider::ProviderOptions &providerOptions,
105 Qgis::TiledSceneProviderCapabilities capabilities() const override;
106 QgsTiledSceneDataProvider *clone() const override;
107 const QgsCoordinateReferenceSystem sceneCrs() const override;
108 const QgsTiledSceneBoundingVolume &boundingVolume() const override;
109 QgsTiledSceneIndex index() const override;
110 QgsDoubleRange zRange() const override;
111 QgsCoordinateReferenceSystem crs() const override;
112 QgsRectangle extent() const override;
113 bool isValid() const override;
114 QString name() const override;
115 QString description() const override;
116
117 const QgsQuantizedMeshMetadata &quantizedMeshMetadata() const;
118
119 static constexpr const char *providerName = "quantizedmesh";
120 static constexpr const char *providerDescription = "Cesium Quantized Mesh tiles";
121
122 private:
123 QString uriFromIon( const QString &uri );
124
125 private:
126 QString mUri; // For clone()
127 QgsDataProvider::ProviderOptions mProviderOptions; // For clone()
128 bool mIsValid = false;
129 std::optional<QgsQuantizedMeshMetadata> mMetadata; // Initialized in constructor
130 std::optional<QgsTiledSceneIndex> mIndex;
131};
132
133class QgsQuantizedMeshProviderMetadata : public QgsProviderMetadata
134{
135 Q_OBJECT
136
137 public:
138 QgsQuantizedMeshProviderMetadata();
139 QgsDataProvider *createProvider( const QString &uri,
140 const QgsDataProvider::ProviderOptions &providerOptions,
142};
143
QFlags< TiledSceneProviderCapability > TiledSceneProviderCapabilities
Tiled scene data provider capabilities.
Definition qgis.h:5229
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
TileChildrenAvailability
Possible availability states for a tile's children.
Definition qgis.h:5266
An abstract base class for tiled scene data provider indices.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Class for doing transforms between two map coordinate systems.
Abstract base class for spatial data provider implementations.
QgsRange which stores a range of double values.
Definition qgsrange.h:231
A container for error messages.
Definition qgserror.h:81
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
This class implements simple http header management.
Holds data provider key, description, and associated shared library file or function pointer informat...
virtual QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Class factory to return a pointer to a newly created QgsDataProvider object.
A rectangle specified with double values.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition qgstiles.h:136
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:40
Represents a bounding volume for a tiled scene.
Base class for data providers for QgsTiledSceneLayer.
An index for tiled scene data providers.
Tiled scene data request.
Represents an individual tile from a tiled scene data source.
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.