cesium-native 0.43.0
Loading...
Searching...
No Matches
QuadtreeRasterOverlayTileProvider.h
1#pragma once
2
3#include "IPrepareRasterOverlayRendererResources.h"
4#include "Library.h"
5#include "RasterOverlayTileProvider.h"
6
7#include <CesiumAsync/AsyncSystem.h>
8#include <CesiumAsync/IAssetAccessor.h>
9#include <CesiumAsync/SharedAssetDepot.h>
10#include <CesiumGeometry/QuadtreeTileID.h>
11#include <CesiumGeometry/QuadtreeTilingScheme.h>
12#include <CesiumUtility/CreditSystem.h>
13#include <CesiumUtility/Result.h>
14#include <CesiumUtility/SharedAsset.h>
15
16#include <list>
17#include <memory>
18#include <optional>
19
20namespace CesiumRasterOverlays {
21
32class CESIUMRASTEROVERLAYS_API QuadtreeRasterOverlayTileProvider
34
35public:
58 const CesiumAsync::AsyncSystem& asyncSystem,
59 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
60 std::optional<CesiumUtility::Credit> credit,
61 const std::shared_ptr<IPrepareRasterOverlayRendererResources>&
62 pPrepareRendererResources,
63 const std::shared_ptr<spdlog::logger>& pLogger,
64 const CesiumGeospatial::Projection& projection,
65 const CesiumGeometry::QuadtreeTilingScheme& tilingScheme,
66 const CesiumGeometry::Rectangle& coverageRectangle,
67 uint32_t minimumLevel,
68 uint32_t maximumLevel,
69 uint32_t imageWidth,
70 uint32_t imageHeight) noexcept;
71
75 uint32_t getMinimumLevel() const noexcept { return this->_minimumLevel; }
76
80 uint32_t getMaximumLevel() const noexcept { return this->_maximumLevel; }
81
85 uint32_t getWidth() const noexcept { return this->_imageWidth; }
86
90 uint32_t getHeight() const noexcept { return this->_imageHeight; }
91
97 return this->_tilingScheme;
98 }
99
110 const CesiumGeometry::Rectangle& rectangle,
111 const glm::dvec2& screenPixels);
112
113protected:
123
124private:
126 loadTileImage(RasterOverlayTile& overlayTile) override final;
127
128 struct LoadedQuadtreeImage
129 : public CesiumUtility::SharedAsset<LoadedQuadtreeImage> {
130 LoadedQuadtreeImage(
131 const std::shared_ptr<LoadedRasterOverlayImage>& pLoaded_,
132 const std::optional<CesiumGeometry::Rectangle>& subset_)
133 : pLoaded(pLoaded_), subset(subset_) {}
134 std::shared_ptr<LoadedRasterOverlayImage> pLoaded = nullptr;
135 std::optional<CesiumGeometry::Rectangle> subset = std::nullopt;
136
137 int64_t getSizeBytes() const {
138 int64_t accum = 0;
139 accum += int64_t(sizeof(LoadedQuadtreeImage));
140 if (pLoaded) {
141 accum += pLoaded->getSizeBytes();
142 }
143 return accum;
144 }
145 };
146
148 getQuadtreeTile(const CesiumGeometry::QuadtreeTileID& tileID);
149
160 std::vector<CesiumAsync::SharedFuture<
162 mapRasterTilesToGeometryTile(
163 const CesiumGeometry::Rectangle& geometryRectangle,
164 const glm::dvec2 targetScreenPixels);
165
166 struct CombinedImageMeasurements {
168 int32_t widthPixels;
169 int32_t heightPixels;
170 int32_t channels;
171 int32_t bytesPerChannel;
172 };
173
174 static CombinedImageMeasurements measureCombinedImage(
175 const CesiumGeometry::Rectangle& targetRectangle,
177 images);
178
179 static LoadedRasterOverlayImage combineImages(
180 const CesiumGeometry::Rectangle& targetRectangle,
181 const CesiumGeospatial::Projection& projection,
183
184 uint32_t _minimumLevel;
185 uint32_t _maximumLevel;
186 uint32_t _imageWidth;
187 uint32_t _imageHeight;
189
191 LoadedQuadtreeImage,
193 _pTileDepot;
194};
195} // namespace CesiumRasterOverlays
A system for managing asynchronous requests and tasks.
Definition AsyncSystem.h:36
A value that will be available in the future, as produced by AsyncSystem.
Definition Promise.h:11
A depot for CesiumUtility::SharedAsset instances, which are potentially shared between multiple objec...
Definition SharedAsset.h:11
A value that will be available in the future, as produced by AsyncSystem. Unlike Future,...
Defines how a rectangular region is divided into quadtree tiles.
A base class used for raster overlay providers that use a quadtree-based tiling scheme....
uint32_t getHeight() const noexcept
Returns the image height of this instance, in pixels.
uint32_t computeLevelFromTargetScreenPixels(const CesiumGeometry::Rectangle &rectangle, const glm::dvec2 &screenPixels)
Computes the best quadtree level to use for an image intended to cover a given projected rectangle wh...
uint32_t getMinimumLevel() const noexcept
Returns the minimum tile level of this instance.
QuadtreeRasterOverlayTileProvider(const CesiumUtility::IntrusivePointer< const RasterOverlay > &pOwner, const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, std::optional< CesiumUtility::Credit > credit, const std::shared_ptr< IPrepareRasterOverlayRendererResources > &pPrepareRendererResources, const std::shared_ptr< spdlog::logger > &pLogger, const CesiumGeospatial::Projection &projection, const CesiumGeometry::QuadtreeTilingScheme &tilingScheme, const CesiumGeometry::Rectangle &coverageRectangle, uint32_t minimumLevel, uint32_t maximumLevel, uint32_t imageWidth, uint32_t imageHeight) noexcept
Creates a new instance.
uint32_t getWidth() const noexcept
Returns the image width of this instance, in pixels.
virtual CesiumAsync::Future< LoadedRasterOverlayImage > loadQuadtreeTileImage(const CesiumGeometry::QuadtreeTileID &tileID) const =0
Asynchronously loads a tile in the quadtree.
uint32_t getMaximumLevel() const noexcept
Returns the maximum tile level of this instance.
const CesiumGeometry::QuadtreeTilingScheme & getTilingScheme() const noexcept
Returns the CesiumGeometry::QuadtreeTilingScheme of this instance.
Provides individual tiles for a RasterOverlay on demand.
Raster image data for a tile in a quadtree.
A smart pointer that calls addReference and releaseReference on the controlled object.
An asset that is potentially shared between multiple objects, such as an image shared between multipl...
Definition SharedAsset.h:52
std::variant< GeographicProjection, WebMercatorProjection > Projection
A projection.
Definition Projection.h:25
Classes for raster overlays, which allow draping massive 2D textures over a model.
Uniquely identifies a node in a quadtree.
A 2D rectangle.
Definition Rectangle.h:14
Holds the result of an operation. If the operation succeeds, it will provide a value....
Definition Result.h:16