cesium-native 0.52.0
Loading...
Searching...
No Matches
IonRasterOverlay.h
1#pragma once
2
3#include <CesiumAsync/IAssetRequest.h>
4#include <CesiumAsync/NetworkAssetDescriptor.h>
5#include <CesiumAsync/SharedAssetDepot.h>
6#include <CesiumGeospatial/Ellipsoid.h>
7#include <CesiumRasterOverlays/Library.h>
8#include <CesiumRasterOverlays/RasterOverlay.h>
9#include <CesiumUtility/SharedAsset.h>
10
11#include <chrono>
12#include <memory>
13#include <optional>
14#include <string>
15#include <unordered_map>
16#include <variant>
17#include <vector>
18
19namespace CesiumRasterOverlays {
20
24class CESIUMRASTEROVERLAYS_API IonRasterOverlay : public RasterOverlay {
25public:
41 const std::string& name,
42 int64_t ionAssetID,
43 const std::string& ionAccessToken,
44 const RasterOverlayOptions& overlayOptions = {},
45 const std::string& ionAssetEndpointUrl = "https://api.cesium.com/");
46 virtual ~IonRasterOverlay() override;
47
54 const std::optional<std::string>& getAssetOptions() const noexcept;
55
62 void setAssetOptions(const std::optional<std::string>& options) noexcept;
63
65 const CesiumAsync::AsyncSystem& asyncSystem,
66 const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
67 const std::shared_ptr<CesiumUtility::CreditSystem>& pCreditSystem,
69 pPrepareRendererResources,
70 const std::shared_ptr<spdlog::logger>& pLogger,
71 CesiumUtility::IntrusivePointer<const RasterOverlay> pOwner)
72 const override;
73
74protected:
91 const std::string& name,
92 const std::string& overlayUrl,
93 const std::string& ionAccessToken,
94 bool needsAuthHeader,
95 const RasterOverlayOptions& overlayOptions = {});
96
97private:
98 std::string _overlayUrl;
99 std::string _ionAccessToken;
100 bool _needsAuthHeader;
101 std::optional<std::string> _assetOptions;
102
103 class TileProvider;
104
105 struct AssetEndpointAttribution {
106 std::string html;
107 bool collapsible = true;
108 };
109
110 struct ExternalAssetEndpoint
111 : public CesiumUtility::SharedAsset<ExternalAssetEndpoint> {
112 ExternalAssetEndpoint() noexcept = default;
113 ~ExternalAssetEndpoint() noexcept = default;
114 ExternalAssetEndpoint(const ExternalAssetEndpoint&) noexcept = default;
115 ExternalAssetEndpoint(ExternalAssetEndpoint&&) noexcept = default;
116
117 std::chrono::steady_clock::time_point requestTime{};
118 std::string externalType{};
119 std::vector<AssetEndpointAttribution> attributions{};
120 std::shared_ptr<CesiumAsync::IAssetRequest> pRequestThatFailed{};
121
123 struct TileMapService {
124 std::string url;
125 std::string accessToken;
126 };
127
129 struct Bing {
130 std::string key;
131 std::string url;
132 std::string mapStyle;
133 std::string culture;
134 };
135
137 struct Google2D {
138 std::string url;
139 std::string key;
140 std::string session;
141 std::string expiry;
142 std::string imageFormat;
143 uint32_t tileWidth;
144 uint32_t tileHeight;
145 };
146
147 std::variant<std::monostate, TileMapService, Bing, Google2D> options{};
148 };
149
150 static std::unordered_map<std::string, ExternalAssetEndpoint> endpointCache;
151
152 using EndpointDepot = CesiumAsync::SharedAssetDepot<
153 ExternalAssetEndpoint,
154 CesiumAsync::NetworkAssetDescriptor,
155 RasterOverlayExternals>;
156
157 static CesiumUtility::IntrusivePointer<EndpointDepot> getEndpointCache();
158};
159
160} // namespace CesiumRasterOverlays
An interface between Cesium Native and the application using it, allowing Cesium Native to pass loade...
A RasterOverlay that obtains imagery data from Cesium ion.
void setAssetOptions(const std::optional< std::string > &options) noexcept
Sets the additional options to be passed to the asset endpoint.
const std::optional< std::string > & getAssetOptions() const noexcept
Gets the additional options to be passed to the asset endpoint.
IonRasterOverlay(const std::string &name, int64_t ionAssetID, const std::string &ionAccessToken, const RasterOverlayOptions &overlayOptions={}, const std::string &ionAssetEndpointUrl="https://api.cesium.com/")
Creates a new instance.
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 override
Begins asynchronous creation of a tile provider for this overlay and eventually returns it via a Futu...
RasterOverlay(const std::string &name, const RasterOverlayOptions &overlayOptions=RasterOverlayOptions())
Creates a new instance.
nonstd::expected< CesiumUtility::IntrusivePointer< RasterOverlayTileProvider >, RasterOverlayLoadFailureDetails > CreateTileProviderResult
A result from a call to createTileProvider. This is expected to be an IntrusivePointer to a RasterOve...
An asset that is potentially shared between multiple objects, such as an image shared between multipl...
Definition SharedAsset.h:55
Classes that support asynchronous operations.
@ Bing
Bing geocoder, for use with Bing data.
Definition Geocoder.h:43
Classes for raster overlays, which allow draping massive 2D textures over a model.
@ TileProvider
An initial load needed to create the overlay's tile provider.
Utility classes for Cesium.
STL namespace.
Options for loading raster overlays.