cesium-native
0.41.0
|
Provides individual tiles for a RasterOverlay on demand. More...
#include <CesiumRasterOverlays/RasterOverlayTileProvider.h>
Public Member Functions | |
RasterOverlayTileProvider (const CesiumUtility::IntrusivePointer< const RasterOverlay > &pOwner, const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const CesiumGeospatial::Ellipsoid &ellipsoid CESIUM_DEFAULT_ELLIPSOID) noexcept | |
RasterOverlayTileProvider (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::Rectangle &coverageRectangle) noexcept | |
Creates a new instance. More... | |
virtual | ~RasterOverlayTileProvider () noexcept |
Default destructor. | |
bool | isPlaceholder () const noexcept |
Returns whether this is a placeholder. More... | |
RasterOverlay & | getOwner () noexcept |
Returns the RasterOverlay that created this instance. | |
const RasterOverlay & | getOwner () const noexcept |
Returns the RasterOverlay that created this instance. More... | |
const std::shared_ptr< CesiumAsync::IAssetAccessor > & | getAssetAccessor () const noexcept |
Get the system to use for asychronous requests and threaded work. | |
const CesiumAsync::AsyncSystem & | getAsyncSystem () const noexcept |
Gets the async system used to do work in threads. | |
const std::shared_ptr< IPrepareRasterOverlayRendererResources > & | getPrepareRendererResources () const noexcept |
Gets the interface used to prepare raster overlay images for rendering. | |
const std::shared_ptr< spdlog::logger > & | getLogger () const noexcept |
Gets the logger to which to send messages about the tile provider and tiles. | |
const CesiumGeospatial::Projection & | getProjection () const noexcept |
Returns the CesiumGeospatial::Projection of this instance. | |
const CesiumGeometry::Rectangle & | getCoverageRectangle () const noexcept |
Returns the coverage CesiumGeometry::Rectangle of this instance. | |
CesiumUtility::IntrusivePointer< RasterOverlayTile > | getTile (const CesiumGeometry::Rectangle &rectangle, const glm::dvec2 &targetScreenPixels) |
Returns a new RasterOverlayTile with the given specifications. More... | |
int64_t | getTileDataBytes () const noexcept |
Gets the number of bytes of tile data that are currently loaded. | |
uint32_t | getNumberOfTilesLoading () const noexcept |
Returns the number of tiles that are currently loading. | |
void | removeTile (RasterOverlayTile *pTile) noexcept |
Removes a no-longer-referenced tile from this provider's cache and deletes it. More... | |
const std::optional< CesiumUtility::Credit > & | getCredit () const noexcept |
Get the per-TileProvider Credit if one exists. | |
CesiumAsync::Future< TileProviderAndTile > | loadTile (RasterOverlayTile &tile) |
Loads a tile immediately, without throttling requests. More... | |
bool | loadTileThrottled (RasterOverlayTile &tile) |
Loads a tile, unless there are too many tile loads already in progress. More... | |
Public Member Functions inherited from CesiumUtility::ReferenceCounted< T, isThreadSafe > | |
void | addReference () const |
Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
void | releaseReference () const |
Removes a counted reference from this object. When the last reference is removed, this method will delete this instance. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
std::int32_t | getReferenceCount () const noexcept |
Returns the current reference count of this instance. | |
Protected Member Functions | |
virtual CesiumAsync::Future< LoadedRasterOverlayImage > | loadTileImage (RasterOverlayTile &overlayTile)=0 |
Loads the image for a tile. More... | |
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. More... | |
Provides individual tiles for a RasterOverlay on demand.
Instances of this class must be allocated on the heap, and their lifetimes must be managed with CesiumUtility::IntrusivePointer.
Definition at line 129 of file RasterOverlayTileProvider.h.
|
noexcept |
Constructs a placeholder tile provider.
pOwner | The raster overlay that created this tile provider. |
asyncSystem | The async system used to do work in threads. |
pAssetAccessor | The interface used to obtain assets (tiles, etc.) for this raster overlay. |
|
noexcept |
Creates a new instance.
pOwner | The raster overlay that created this tile provider. |
asyncSystem | The async system used to do work in threads. |
pAssetAccessor | The interface used to obtain assets (tiles, etc.) for this raster overlay. |
credit | The Credit for this tile provider, if it exists. |
pPrepareRendererResources | The interface used to prepare raster images for rendering. |
pLogger | The logger to which to send messages about the tile provider and tiles. |
projection | The CesiumGeospatial::Projection. |
coverageRectangle | The rectangle that bounds all the area covered by this overlay, expressed in projected coordinates. |
|
inlinenoexcept |
Returns the RasterOverlay that created this instance.
Definition at line 207 of file RasterOverlayTileProvider.h.
CesiumUtility::IntrusivePointer<RasterOverlayTile> CesiumRasterOverlays::RasterOverlayTileProvider::getTile | ( | const CesiumGeometry::Rectangle & | rectangle, |
const glm::dvec2 & | targetScreenPixels | ||
) |
Returns a new RasterOverlayTile with the given specifications.
The returned tile will not start loading immediately. To start loading, call RasterOverlayTileProvider::loadTile or RasterOverlayTileProvider::loadTileThrottled.
rectangle | The rectangle that the returned image must cover. It is allowed to cover a slightly larger rectangle in order to maintain pixel alignment. It may also cover a smaller rectangle when the overlay itself does not cover the entire rectangle. |
targetScreenPixels | The maximum number of pixels on the screen that this tile is meant to cover. The overlay image should be approximately this many pixels divided by the RasterOverlayOptions::maximumScreenSpaceError in order to achieve the desired level-of-detail, but it does not need to be exactly this size. |
|
inlinenoexcept |
Returns whether this is a placeholder.
For many types of RasterOverlay, we can't create a functioning RasterOverlayTileProvider
right away. For example, we may not know the bounds of the overlay, or what projection it uses, until after we've (asynchronously) loaded a metadata service that gives us this information.
So until that real RasterOverlayTileProvider
becomes available, we use a placeholder. When RasterOverlayTileProvider::getTile is invoked on a placeholder, it returns a RasterOverlayTile that is also a placeholder. And whenever we see a placeholder RasterOverTile
in Tile::update, we check if the corresponding RasterOverlay
is ready yet. Once it's ready, we remove the placeholder tile and replace it with the real tiles.
So the placeholder system gives us a way to defer the mapping of raster overlay tiles to geometry tiles until that mapping can be determined.
Definition at line 199 of file RasterOverlayTileProvider.h.
CesiumAsync::Future<TileProviderAndTile> CesiumRasterOverlays::RasterOverlayTileProvider::loadTile | ( | RasterOverlayTile & | tile | ) |
Loads a tile immediately, without throttling requests.
If the tile is not in the Tile::LoadState::Unloaded
state, this method returns without doing anything. Otherwise, it puts the tile into the Tile::LoadState::Loading
state and begins the asynchronous process to load the tile. When the process completes, the tile will be in the Tile::LoadState::Loaded
or Tile::LoadState::Failed
state.
Calling this method on many tiles at once can result in very slow performance. Consider using loadTileThrottled instead.
tile | The tile to load. |
|
protectedpure virtual |
Loads the image for a tile.
overlayTile | The overlay tile for which to load the image. |
|
protected |
Loads an image from a URL and optionally some request headers.
This is a useful helper function for implementing loadTileImage.
url | The URL. |
headers | The request headers. |
options | Additional options for the load process. |
bool CesiumRasterOverlays::RasterOverlayTileProvider::loadTileThrottled | ( | RasterOverlayTile & | tile | ) |
Loads a tile, unless there are too many tile loads already in progress.
If the tile is not in the Tile::LoadState::Unloading
state, this method returns true without doing anything. If too many tile loads are already in flight, it returns false without doing anything. Otherwise, it puts the tile into the Tile::LoadState::Loading
state, begins the asynchronous process to load the tile, and returns true. When the process completes, the tile will be in the Tile::LoadState::Loaded
or Tile::LoadState::Failed
state.
The number of allowable simultaneous tile requests is provided in the RasterOverlayOptions::maximumSimultaneousTileLoads property of RasterOverlay::getOptions.
tile | The tile to load. |
|
noexcept |
Removes a no-longer-referenced tile from this provider's cache and deletes it.
This function is not supposed to be called by client. Calling this method in a tile with a reference count greater than 0 will result in undefined behavior.
pTile | The tile, which must have no oustanding references. |