Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into request-headers-tileset
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jan 17, 2025
2 parents 96cf605 + a9fa1fc commit 04b6a7d
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
### ? - ?

##### Additions :tada:

- Added `CesiumUrlTemplateRasterOverlay`, allowing a raster overlay to be added using tiles requested based on a specified URL template.
- Added `RequestHeaders` property to `Cesium3DTileset`, allowing per-tileset headers to be specified.

##### Fixes :wrench:

- Fixed another bug in `CesiumSubLevelSwitcherComponent` that could prevent all sub-levels from loading if a single sub-level failed to load.

### v2.12.0 - 2025-01-02

##### Breaking Changes :mega:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
*GetActorLabel(this->_pCurrent.Get()));
this->_isTransitioningSubLevels = true;
break;
case ELevelStreamingState::FailedToLoad:
case ELevelStreamingState::LoadedNotVisible:
case ELevelStreamingState::LoadedVisible:
UE_LOG(
Expand All @@ -235,6 +234,7 @@ void UCesiumSubLevelSwitcherComponent::_updateSubLevelStateGame() {
this->_isTransitioningSubLevels = true;
this->_pCurrent->UnloadLevelInstance();
break;
case ELevelStreamingState::FailedToLoad:
case ELevelStreamingState::Removed:
case ELevelStreamingState::Unloaded:
UE_LOG(
Expand Down
64 changes: 64 additions & 0 deletions Source/CesiumRuntime/Private/CesiumUrlTemplateRasterOverlay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2020-2024 CesiumGS, Inc. and Contributors

#include "CesiumUrlTemplateRasterOverlay.h"

#include "CesiumCustomVersion.h"
#include "CesiumGeometry/QuadtreeTilingScheme.h"
#include "CesiumGeospatial/GlobeRectangle.h"
#include "CesiumGeospatial/Projection.h"
#include "CesiumRasterOverlays/UrlTemplateRasterOverlay.h"

#include "CesiumRuntime.h"

std::unique_ptr<CesiumRasterOverlays::RasterOverlay>
UCesiumUrlTemplateRasterOverlay::CreateOverlay(
const CesiumRasterOverlays::RasterOverlayOptions& options) {
if (this->TemplateUrl.IsEmpty()) {
// Don't create an overlay with an empty base URL.
return nullptr;
}

CesiumRasterOverlays::UrlTemplateRasterOverlayOptions urlTemplateOptions;

urlTemplateOptions.minimumLevel = MinimumLevel;
urlTemplateOptions.maximumLevel = MaximumLevel;

urlTemplateOptions.tileWidth = this->TileWidth;
urlTemplateOptions.tileHeight = this->TileHeight;

const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid;

if (this->Projection ==
ECesiumUrlTemplateRasterOverlayProjection::Geographic) {
urlTemplateOptions.projection =
CesiumGeospatial::GeographicProjection(ellipsoid);
} else {
urlTemplateOptions.projection =
CesiumGeospatial::WebMercatorProjection(ellipsoid);
}

if (bSpecifyTilingScheme) {
CesiumGeospatial::GlobeRectangle globeRectangle =
CesiumGeospatial::GlobeRectangle::fromDegrees(
RectangleWest,
RectangleSouth,
RectangleEast,
RectangleNorth);
CesiumGeometry::Rectangle coverageRectangle =
CesiumGeospatial::projectRectangleSimple(
*urlTemplateOptions.projection,
globeRectangle);
urlTemplateOptions.coverageRectangle = coverageRectangle;
urlTemplateOptions.tilingScheme = CesiumGeometry::QuadtreeTilingScheme(
coverageRectangle,
RootTilesX,
RootTilesY);
}

return std::make_unique<CesiumRasterOverlays::UrlTemplateRasterOverlay>(
TCHAR_TO_UTF8(*this->MaterialLayerKey),
TCHAR_TO_UTF8(*this->TemplateUrl),
std::vector<CesiumAsync::IAssetAccessor::THeader>(),
urlTemplateOptions,
options);
}
226 changes: 226 additions & 0 deletions Source/CesiumRuntime/Public/CesiumUrlTemplateRasterOverlay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
// Copyright 2020-2024 CesiumGS, Inc. and Contributors

#pragma once

#include "CesiumRasterOverlay.h"
#include "Components/ActorComponent.h"
#include "CoreMinimal.h"
#include "CesiumUrlTemplateRasterOverlay.generated.h"

/**
* Specifies the type of projection used for projecting a URL template
* raster overlay.
*/
UENUM(BlueprintType)
enum class ECesiumUrlTemplateRasterOverlayProjection : uint8 {
/**
* The raster overlay is projected using Web Mercator.
*/
WebMercator,

/**
* The raster overlay is projected using a geographic projection.
*/
Geographic
};

/**
* A raster overlay that loads tiles from a templated URL.
*/
UCLASS(ClassGroup = (Cesium), meta = (BlueprintSpawnableComponent))
class CESIUMRUNTIME_API UCesiumUrlTemplateRasterOverlay
: public UCesiumRasterOverlay {
GENERATED_BODY()

public:
/**
* @brief The URL containing template parameters that will be substituted when
* loading tiles.
*
* The following template parameters are supported in `url`:
* - `{x}` - The tile X coordinate in the tiling scheme, where 0 is the
* westernmost tile.
* - `{y}` - The tile Y coordinate in the tiling scheme, where 0 is the
* nothernmost tile.
* - `{z}` - The level of the tile in the tiling scheme, where 0 is the root
* of the quadtree pyramid.
* - `{reverseX}` - The tile X coordinate in the tiling scheme, where 0 is the
* easternmost tile.
* - `{reverseY}` - The tile Y coordinate in the tiling scheme, where 0 is the
* southernmost tile.
* - `{reverseZ}` - The tile Z coordinate in the tiling scheme, where 0 is
* equivalent to `urlTemplateOptions.maximumLevel`.
* - `{westDegrees}` - The western edge of the tile in geodetic degrees.
* - `{southDegrees}` - The southern edge of the tile in geodetic degrees.
* - `{eastDegrees}` - The eastern edge of the tile in geodetic degrees.
* - `{northDegrees}` - The northern edge of the tile in geodetic degrees.
* - `{minimumX}` - The minimum X coordinate of the tile's projected
* coordinates.
* - `{minimumY}` - The minimum Y coordinate of the tile's projected
* coordinates.
* - `{maximumX}` - The maximum X coordinate of the tile's projected
* coordinates.
* - `{maximumY}` - The maximum Y coordinate of the tile's projected
* coordinates.
* - `{width}` - The width of each tile in pixels.
* - `{height}` - The height of each tile in pixels.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
FString TemplateUrl;

/**
* The type of projection used to project the imagery onto the globe.
* For instance, EPSG:4326 uses geographic projection and EPSG:3857 uses Web
* Mercator.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
ECesiumUrlTemplateRasterOverlayProjection Projection =
ECesiumUrlTemplateRasterOverlayProjection::WebMercator;

/**
* Set this to true to specify the quadtree tiling scheme according to the
* specified root tile numbers and projected bounding rectangle. If false, the
* tiling scheme will be deduced from the projection.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
bool bSpecifyTilingScheme = false;

/**
* If specified, this determines the number of tiles at the
* root of the quadtree tiling scheme in the X direction.
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (EditCondition = "bSpecifyTilingScheme", ClampMin = 1))
int32 RootTilesX = 1;

/**
* If specified, this determines the number of tiles at the
* root of the quadtree tiling scheme in the Y direction.
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (EditCondition = "bSpecifyTilingScheme", ClampMin = 1))
int32 RootTilesY = 1;

/**
* The west boundary of the bounding rectangle used for the quadtree tiling
* scheme. Specified in longitude degrees in the range [-180, 180].
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
Category = "Cesium",
EditAnywhere,
BlueprintReadWrite,
meta =
(EditCondition = "bSpecifyTilingScheme",
ClampMin = -180.0,
ClampMax = 180.0))
double RectangleWest = -180;

/**
* The south boundary of the bounding rectangle used for the quadtree tiling
* scheme. Specified in latitude degrees in the range [-90, 90].
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
Category = "Cesium",
Category = "Cesium",
EditAnywhere,
BlueprintReadWrite,
meta =
(EditCondition = "bSpecifyTilingScheme",
ClampMin = -90.0,
ClampMax = 90.0))
double RectangleSouth = -90;

/**
* The east boundary of the bounding rectangle used for the quadtree tiling
* scheme. Specified in longitude degrees in the range [-180, 180].
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
Category = "Cesium",
EditAnywhere,
BlueprintReadWrite,
meta =
(EditCondition = "bSpecifyTilingScheme",
ClampMin = -180.0,
ClampMax = 180.0))
double RectangleEast = 180;

/**
* The north boundary of the bounding rectangle used for the quadtree tiling
* scheme. Specified in latitude degrees in the range [-90, 90].
*
* Only applicable if "Specify Tiling Scheme" is set to true.
*/
UPROPERTY(
Category = "Cesium",
EditAnywhere,
BlueprintReadWrite,
meta =
(EditCondition = "bSpecifyTilingScheme",
ClampMin = -90.0,
ClampMax = 90.0))
double RectangleNorth = 90;

/**
* Minimum zoom level.
*
* Take care when specifying this that the number of tiles at the minimum
* level is small, such as four or less. A larger number is likely to result
* in rendering problems.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (ClampMin = 0))
int32 MinimumLevel = 0;

/**
* Maximum zoom level.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (ClampMin = 0))
int32 MaximumLevel = 25;

/**
* The pixel width of the image tiles.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (ClampMin = 64, ClampMax = 2048))
int32 TileWidth = 256;

/**
* The pixel height of the image tiles.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (ClampMin = 64, ClampMax = 2048))
int32 TileHeight = 256;

protected:
virtual std::unique_ptr<CesiumRasterOverlays::RasterOverlay> CreateOverlay(
const CesiumRasterOverlays::RasterOverlayOptions& options = {}) override;
};
2 changes: 1 addition & 1 deletion extern/cesium-native
Submodule cesium-native updated 137 files

0 comments on commit 04b6a7d

Please sign in to comment.