cesium-native 0.52.0
Loading...
Searching...
No Matches
RasterOverlayTileProvider.h
1#pragma once
2
3#include <CesiumAsync/IAssetAccessor.h>
4#include <CesiumGeospatial/Projection.h>
5#include <CesiumGltfReader/GltfReader.h>
6#include <CesiumRasterOverlays/Library.h>
7#include <CesiumRasterOverlays/RasterOverlayExternals.h>
8#include <CesiumUtility/Assert.h>
9#include <CesiumUtility/CreditSystem.h>
10#include <CesiumUtility/ErrorList.h>
11#include <CesiumUtility/IntrusivePointer.h>
12#include <CesiumUtility/ReferenceCounted.h>
13#include <CesiumUtility/Tracing.h>
14
15#include <spdlog/fwd.h>
16
17#include <optional>
18
19namespace CesiumUtility {
21}
22
23namespace CesiumRasterOverlays {
24
25class RasterOverlay;
28
32struct CESIUMRASTEROVERLAYS_API LoadedRasterOverlayImage {
40
48
53 std::vector<CesiumUtility::Credit> credits{};
54
62
67 bool moreDetailAvailable = false;
68
72 int64_t getSizeBytes() const {
73 int64_t accum = 0;
74 accum += int64_t(sizeof(LoadedRasterOverlayImage));
75 accum += int64_t(this->credits.capacity() * sizeof(CesiumUtility::Credit));
76 if (this->pImage) {
77 accum += this->pImage->getSizeBytes();
78 }
79 return accum;
80 }
81};
82
92
99 std::vector<CesiumUtility::Credit> credits{};
100
106
124 bool allowEmptyImages = false;
125};
126
128
135class CESIUMRASTEROVERLAYS_API RasterOverlayTileProvider
137 RasterOverlayTileProvider> {
138public:
150 const RasterOverlayExternals& externals,
151 const CesiumGeospatial::Projection& projection,
152 const CesiumGeometry::Rectangle& coverageRectangle) noexcept;
153
161 const CesiumAsync::AsyncSystem& asyncSystem,
162 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
163 const std::shared_ptr<CesiumUtility::CreditSystem>& pCreditSystem,
164 std::optional<CesiumUtility::Credit> credit,
165 const std::shared_ptr<IPrepareRasterOverlayRendererResources>&
166 pPrepareRendererResources,
167 const std::shared_ptr<spdlog::logger>& pLogger,
168 const CesiumGeospatial::Projection& projection,
169 const CesiumGeometry::Rectangle& coverageRectangle) noexcept;
170
172 virtual ~RasterOverlayTileProvider() noexcept;
173
180
185
187 const RasterOverlay& getOwner() const noexcept;
188
192 const RasterOverlayExternals& getExternals() const noexcept;
193
197 const std::shared_ptr<CesiumAsync::IAssetAccessor>&
198 getAssetAccessor() const noexcept;
199
203 const std::shared_ptr<CesiumUtility::CreditSystem>&
204 getCreditSystem() const noexcept;
205
209 const CesiumAsync::AsyncSystem& getAsyncSystem() const noexcept;
210
217
222 const std::shared_ptr<spdlog::logger>& getLogger() const noexcept;
223
227 const CesiumGeospatial::Projection& getProjection() const noexcept;
228
233 const CesiumGeometry::Rectangle& getCoverageRectangle() const noexcept;
234
239 [[deprecated(
240 "Use addCredits instead.")]] const std::optional<CesiumUtility::Credit>&
241 getCredit() const noexcept;
242
250 loadTileImage(const RasterOverlayTile& overlayTile) = 0;
251
262 virtual void
263 addCredits(CesiumUtility::CreditReferencer& creditReferencer) noexcept;
264
265protected:
277 const std::string& url,
278 const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers = {},
279 LoadTileImageFromUrlOptions&& options = {}) const;
280
281private:
282 struct DestructionCompleteDetails {
285 };
286
287 CesiumUtility::IntrusivePointer<RasterOverlay> _pOwner;
288 RasterOverlayExternals _externals;
289 std::optional<CesiumUtility::Credit> _credit;
291 CesiumGeometry::Rectangle _coverageRectangle;
292 std::optional<DestructionCompleteDetails> _destructionCompleteDetails;
293};
294} // namespace CesiumRasterOverlays
A system for managing asynchronous requests and tasks.
Definition AsyncSystem.h:36
A promise that can be resolved or rejected by an asynchronous task.
Definition Promise.h:19
A value that will be available in the future, as produced by AsyncSystem. Unlike Future,...
An interface between Cesium Native and the application using it, allowing Cesium Native to pass loade...
External interfaces used by a RasterOverlay.
Provides individual tiles for a RasterOverlay on demand.
const std::optional< CesiumUtility::Credit > & getCredit() const noexcept
Get the per-TileProvider CesiumUtility::Credit if one exists.
virtual CesiumAsync::Future< LoadedRasterOverlayImage > loadTileImage(const RasterOverlayTile &overlayTile)=0
Loads the image for a tile.
RasterOverlay & getOwner() noexcept
Returns the RasterOverlay that created this instance.
virtual void addCredits(CesiumUtility::CreditReferencer &creditReferencer) noexcept
Adds this tile provider's credits to a credit referencer.
CesiumAsync::SharedFuture< void > & getAsyncDestructionCompleteEvent()
A future that resolves when this RasterOverlayTileProvider has been destroyed (i.e....
const std::shared_ptr< IPrepareRasterOverlayRendererResources > & getPrepareRendererResources() const noexcept
Gets the interface used to prepare raster overlay images for rendering.
virtual ~RasterOverlayTileProvider() noexcept
Default destructor.
CesiumAsync::Future< LoadedRasterOverlayImage > loadTileImageFromUrl(const std::string &url, const std::vector< CesiumAsync::IAssetAccessor::THeader > &headers={}, LoadTileImageFromUrlOptions &&options={}) const
Loads an image from a URL and optionally some request headers.
const CesiumGeometry::Rectangle & getCoverageRectangle() const noexcept
Returns the coverage CesiumGeometry::Rectangle of this instance.
const std::shared_ptr< spdlog::logger > & getLogger() const noexcept
Gets the logger to which to send messages about the tile provider and tiles.
const RasterOverlayExternals & getExternals() const noexcept
Get the external interfaces for use by the tile provider.
RasterOverlayTileProvider(const CesiumUtility::IntrusivePointer< const RasterOverlay > &pOwner, const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::shared_ptr< CesiumUtility::CreditSystem > &pCreditSystem, std::optional< CesiumUtility::Credit > credit, const std::shared_ptr< IPrepareRasterOverlayRendererResources > &pPrepareRendererResources, const std::shared_ptr< spdlog::logger > &pLogger, const CesiumGeospatial::Projection &projection, const CesiumGeometry::Rectangle &coverageRectangle) noexcept
Creates a new instance.
RasterOverlayTileProvider(const CesiumUtility::IntrusivePointer< const RasterOverlay > &pOwner, const RasterOverlayExternals &externals, const CesiumGeospatial::Projection &projection, const CesiumGeometry::Rectangle &coverageRectangle) noexcept
Creates a new instance.
const CesiumGeospatial::Projection & getProjection() const noexcept
Returns the CesiumGeospatial::Projection of this instance.
const CesiumAsync::AsyncSystem & getAsyncSystem() const noexcept
Gets the async system used to do work in threads.
const std::shared_ptr< CesiumUtility::CreditSystem > & getCreditSystem() const noexcept
Get the credit system that receives credits from this tile provider.
const std::shared_ptr< CesiumAsync::IAssetAccessor > & getAssetAccessor() const noexcept
Get the system to use for asychronous requests and threaded work.
Raster image data for a tile in a quadtree.
The base class for a rasterized image that can be draped over a Cesium3DTilesSelection::Tileset....
Provides a way to reference a set of credits in a CreditSystem so that the references can easily be r...
A smart pointer that calls addReference and releaseReference on the controlled object.
Classes that support asynchronous operations.
Basic geometry classes for Cesium.
Classes for geospatial computations in Cesium.
std::variant< GeographicProjection, WebMercatorProjection > Projection
A projection.
Definition Projection.h:25
Classes for raster overlays, which allow draping massive 2D textures over a model.
Utility classes for Cesium.
ReferenceCounted< T, false > ReferenceCountedNonThreadSafe
A reference-counted base class, meant to be used with IntrusivePointer. The reference count is not th...
STL namespace.
A 2D rectangle.
Definition Rectangle.h:14
Options for RasterOverlayTileProvider::loadTileImageFromUrl.
CesiumGeometry::Rectangle rectangle
The rectangle definining the bounds of the image being loaded, expressed in the RasterOverlayTileProv...
std::vector< CesiumUtility::Credit > credits
The credits to display with this tile.
bool moreDetailAvailable
Whether more detailed data, beyond this image, is available within the bounds of this image.
bool allowEmptyImages
Whether empty (zero length) images are accepted as a valid response.
Summarizes the result of loading an image of a RasterOverlay.
int64_t getSizeBytes() const
Returns the size of this LoadedRasterOverlayImage in bytes.
CesiumUtility::ErrorList errorList
Errors and warnings from loading the image.
std::vector< CesiumUtility::Credit > credits
The CesiumUtility::Credit objects that decribe the attributions that are required when using the imag...
CesiumGeometry::Rectangle rectangle
The projected rectangle defining the bounds of this image.
bool moreDetailAvailable
Whether more detailed data, beyond this image, is available within the bounds of this image.
CesiumUtility::IntrusivePointer< CesiumGltf::ImageAsset > pImage
The loaded image.
Represents an HTML string that should be shown on screen to attribute third parties for used data,...
The container to store the error and warning list when loading a tile or glTF content.
Definition ErrorList.h:18