cesium-native 0.44.2
Loading...
Searching...
No Matches
QuadtreeRasterOverlayTileProvider.h
1#pragma once
2
3#include <CesiumAsync/AsyncSystem.h>
4#include <CesiumAsync/IAssetAccessor.h>
5#include <CesiumAsync/SharedAssetDepot.h>
6#include <CesiumGeometry/QuadtreeTileID.h>
7#include <CesiumGeometry/QuadtreeTilingScheme.h>
8#include <CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h>
9#include <CesiumRasterOverlays/Library.h>
10#include <CesiumRasterOverlays/RasterOverlayTileProvider.h>
11#include <CesiumUtility/CreditSystem.h>
12#include <CesiumUtility/Result.h>
13#include <CesiumUtility/SharedAsset.h>
14
15#include <list>
16#include <memory>
17#include <optional>
18
19namespace CesiumRasterOverlays {
20
31class CESIUMRASTEROVERLAYS_API QuadtreeRasterOverlayTileProvider
33
34public:
57 const CesiumAsync::AsyncSystem& asyncSystem,
58 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
59 std::optional<CesiumUtility::Credit> credit,
60 const std::shared_ptr<IPrepareRasterOverlayRendererResources>&
61 pPrepareRendererResources,
62 const std::shared_ptr<spdlog::logger>& pLogger,
63 const CesiumGeospatial::Projection& projection,
64 const CesiumGeometry::QuadtreeTilingScheme& tilingScheme,
65 const CesiumGeometry::Rectangle& coverageRectangle,
66 uint32_t minimumLevel,
67 uint32_t maximumLevel,
68 uint32_t imageWidth,
69 uint32_t imageHeight) noexcept;
70
74 uint32_t getMinimumLevel() const noexcept { return this->_minimumLevel; }
75
79 uint32_t getMaximumLevel() const noexcept { return this->_maximumLevel; }
80
84 uint32_t getWidth() const noexcept { return this->_imageWidth; }
85
89 uint32_t getHeight() const noexcept { return this->_imageHeight; }
90
96 return this->_tilingScheme;
97 }
98
109 const CesiumGeometry::Rectangle& rectangle,
110 const glm::dvec2& screenPixels);
111
112protected:
122
123private:
125 loadTileImage(RasterOverlayTile& overlayTile) override final;
126
127 struct LoadedQuadtreeImage
128 : public CesiumUtility::SharedAsset<LoadedQuadtreeImage> {
129 LoadedQuadtreeImage(
130 const std::shared_ptr<LoadedRasterOverlayImage>& pLoaded_,
131 const std::optional<CesiumGeometry::Rectangle>& subset_)
132 : pLoaded(pLoaded_), subset(subset_) {}
133 std::shared_ptr<LoadedRasterOverlayImage> pLoaded = nullptr;
134 std::optional<CesiumGeometry::Rectangle> subset = std::nullopt;
135
136 int64_t getSizeBytes() const {
137 int64_t accum = 0;
138 accum += int64_t(sizeof(LoadedQuadtreeImage));
139 if (pLoaded) {
140 accum += pLoaded->getSizeBytes();
141 }
142 return accum;
143 }
144 };
145
147 getQuadtreeTile(const CesiumGeometry::QuadtreeTileID& tileID);
148
159 std::vector<CesiumAsync::SharedFuture<
161 mapRasterTilesToGeometryTile(
162 const CesiumGeometry::Rectangle& geometryRectangle,
163 const glm::dvec2 targetScreenPixels);
164
165 struct CombinedImageMeasurements {
167 int32_t widthPixels;
168 int32_t heightPixels;
169 int32_t channels;
170 int32_t bytesPerChannel;
171 };
172
173 static CombinedImageMeasurements measureCombinedImage(
174 const CesiumGeometry::Rectangle& targetRectangle,
176 images);
177
178 static LoadedRasterOverlayImage combineImages(
179 const CesiumGeometry::Rectangle& targetRectangle,
180 const CesiumGeospatial::Projection& projection,
182
183 uint32_t _minimumLevel;
184 uint32_t _maximumLevel;
185 uint32_t _imageWidth;
186 uint32_t _imageHeight;
188
190 LoadedQuadtreeImage,
192 _pTileDepot;
193};
194} // 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:12
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