cesium-native  0.41.0
RasterOverlay.h
1 #pragma once
2 
3 #include "Library.h"
4 #include "RasterOverlayLoadFailureDetails.h"
5 
6 #include <CesiumAsync/AsyncSystem.h>
7 #include <CesiumAsync/IAssetAccessor.h>
8 #include <CesiumGeospatial/Ellipsoid.h>
9 #include <CesiumGltf/Ktx2TranscodeTargets.h>
10 #include <CesiumUtility/IntrusivePointer.h>
11 #include <CesiumUtility/ReferenceCounted.h>
12 
13 #include <nonstd/expected.hpp>
14 #include <spdlog/fwd.h>
15 
16 #include <any>
17 #include <functional>
18 #include <memory>
19 #include <optional>
20 #include <string>
21 
22 namespace CesiumUtility {
23 struct Credit;
24 class CreditSystem;
25 } // namespace CesiumUtility
26 
27 namespace CesiumRasterOverlays {
28 
29 class IPrepareRasterOverlayRendererResources;
30 class RasterOverlayTileProvider;
31 
35 struct CESIUMRASTEROVERLAYS_API RasterOverlayOptions {
40  int32_t maximumSimultaneousTileLoads = 20;
41 
53  int64_t subTileCacheBytes = 16 * 1024 * 1024;
54 
66  int32_t maximumTextureSize = 2048;
67 
76  double maximumScreenSpaceError = 2.0;
77 
83 
96 
100  bool showCreditsOnScreen = false;
101 
110  std::any rendererOptions;
111 
115  std::optional<CesiumGeospatial::Ellipsoid> ellipsoid = std::nullopt;
116 };
117 
135  : public CesiumUtility::ReferenceCountedNonThreadSafe<RasterOverlay> {
136 public:
144  const std::string& name,
145  const RasterOverlayOptions& overlayOptions = RasterOverlayOptions());
146  virtual ~RasterOverlay() noexcept;
147 
157  CesiumAsync::SharedFuture<void>&
158  getAsyncDestructionCompleteEvent(const CesiumAsync::AsyncSystem& asyncSystem);
159 
163  const std::string& getName() const noexcept { return this->_name; }
164 
168  RasterOverlayOptions& getOptions() noexcept { return this->_options; }
169 
171  const RasterOverlayOptions& getOptions() const noexcept {
172  return this->_options;
173  }
174 
178  const std::vector<CesiumUtility::Credit>& getCredits() const noexcept {
179  return this->_credits;
180  }
181 
185  std::vector<CesiumUtility::Credit>& getCredits() noexcept {
186  return this->_credits;
187  }
188 
199  const CesiumAsync::AsyncSystem& asyncSystem,
200  const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
201  const CesiumGeospatial::Ellipsoid& ellipsoid
202  CESIUM_DEFAULT_ELLIPSOID) const;
203 
204  using CreateTileProviderResult = nonstd::expected<
207 
227  const CesiumAsync::AsyncSystem& asyncSystem,
228  const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
229  const std::shared_ptr<CesiumUtility::CreditSystem>& pCreditSystem,
230  const std::shared_ptr<IPrepareRasterOverlayRendererResources>&
231  pPrepareRendererResources,
232  const std::shared_ptr<spdlog::logger>& pLogger,
234 
235 private:
236  struct DestructionCompleteDetails {
237  CesiumAsync::AsyncSystem asyncSystem;
240  };
241 
242  std::string _name;
243  RasterOverlayOptions _options;
244  std::vector<CesiumUtility::Credit> _credits;
245  std::optional<DestructionCompleteDetails> _destructionCompleteDetails;
246 };
247 
248 } // 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: Future.h:29
A quadratic surface defined in Cartesian coordinates.
Definition: Ellipsoid.h:38
The base class for a rasterized image that can be draped over a Tileset. The image may be very,...
CesiumAsync::SharedFuture< void > & getAsyncDestructionCompleteEvent(const CesiumAsync::AsyncSystem &asyncSystem)
A future that resolves when this RasterOverlay has been destroyed (i.e. its destructor has been calle...
RasterOverlayOptions & getOptions() noexcept
Gets options for this overlay.
const std::vector< CesiumUtility::Credit > & getCredits() const noexcept
Gets the credits for this overlay.
CesiumUtility::IntrusivePointer< RasterOverlayTileProvider > createPlaceholder(const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const CesiumGeospatial::Ellipsoid &ellipsoid CESIUM_DEFAULT_ELLIPSOID) const
Create a placeholder tile provider can be used in place of the real one while createTileProvider comp...
RasterOverlay(const std::string &name, const RasterOverlayOptions &overlayOptions=RasterOverlayOptions())
Creates a new instance.
std::vector< CesiumUtility::Credit > & getCredits() noexcept
Gets the credits for this overlay.
const std::string & getName() const noexcept
Gets the name of this overlay.
virtual CesiumAsync::Future< CreateTileProviderResult > createTileProvider(const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::shared_ptr< CesiumUtility::CreditSystem > &pCreditSystem, const std::shared_ptr< IPrepareRasterOverlayRendererResources > &pPrepareRendererResources, const std::shared_ptr< spdlog::logger > &pLogger, CesiumUtility::IntrusivePointer< const RasterOverlay > pOwner) const =0
Begins asynchronous creation of a tile provider for this overlay and eventually returns it via a Futu...
const RasterOverlayOptions & getOptions() const noexcept
Gets options for this overlay.
A smart pointer that calls addReference and releaseReference on the controlled object.
A reference-counted base class, meant to be used with IntrusivePointer.
Classes that support asynchronous operations.
Classes for raster overlays, which allow draping massive 2D textures over a model.
Utility classes for Cesium.
For each possible input transmission format, this struct names the ideal target gpu-compressed pixel ...
Options for loading raster overlays.
Definition: RasterOverlay.h:35
std::any rendererOptions
Arbitrary data that will be passed to prepareRasterInLoadThread, for example, data to control the per...
std::function< void(const RasterOverlayLoadFailureDetails &)> loadErrorCallback
A callback function that is invoked when a raster overlay resource fails to load.
Definition: RasterOverlay.h:95
CesiumGltf::Ktx2TranscodeTargets ktx2TranscodeTargets
For each possible input transmission format, this struct names the ideal target gpu-compressed pixel ...
Definition: RasterOverlay.h:82