-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
67 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Cesium3DTilesContent/include/Cesium3DTilesContent/ImplicitTiling.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace CesiumGeometry { | ||
struct QuadtreeTileID; | ||
struct OctreeTileID; | ||
} // namespace CesiumGeometry | ||
|
||
namespace Cesium3DTilesContent { | ||
|
||
/** | ||
* @brief Helper functions for working with 3D Tiles implicit tiling. | ||
*/ | ||
class ImplicitTiling { | ||
public: | ||
/** | ||
* @brief Resolves a templatized implicit tiling URL with a quadtree tile ID. | ||
* | ||
* @param baseUrl The base URL that is used to resolve the urlTemplate if it | ||
* is a relative path. | ||
* @param urlTemplate The templatized URL. | ||
* @param quadtreeID The quadtree ID to use in resolving the parameters in the | ||
* URL template. | ||
* @return The resolved URL. | ||
*/ | ||
static std::string resolveUrl( | ||
const std::string& baseUrl, | ||
const std::string& urlTemplate, | ||
const CesiumGeometry::QuadtreeTileID& quadtreeID); | ||
|
||
/** | ||
* @brief Resolves a templatized implicit tiling URL with an octree tile ID. | ||
* | ||
* @param baseUrl The base URL that is used to resolve the urlTemplate if it | ||
* is a relative path. | ||
* @param urlTemplate The templatized URL. | ||
* @param octreeID The octree ID to use in resolving the parameters in the | ||
* URL template. | ||
* @return The resolved URL. | ||
*/ | ||
static std::string resolveUrl( | ||
const std::string& baseUrl, | ||
const std::string& urlTemplate, | ||
const CesiumGeometry::OctreeTileID& octreeID); | ||
}; | ||
|
||
} // namespace Cesium3DTilesContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <Cesium3DTilesContent/ImplicitTiling.h> | ||
#include <CesiumGeometry/OctreeTileID.h> | ||
#include <CesiumGeometry/QuadtreeTileID.h> | ||
#include <CesiumUtility/Uri.h> | ||
|
||
namespace Cesium3DTilesContent { | ||
|
||
/*static*/ std::string ImplicitTiling::resolveUrl( | ||
const std::string& baseUrl, | ||
const std::string& urlTemplate, | ||
const CesiumGeometry::QuadtreeTileID& quadtreeID) { | ||
std::string url = CesiumUtility::Uri::substituteTemplateParameters( | ||
urlTemplate, | ||
[&quadtreeID](const std::string& placeholder) { | ||
if (placeholder == "level") { | ||
return std::to_string(quadtreeID.level); | ||
} | ||
if (placeholder == "x") { | ||
return std::to_string(quadtreeID.x); | ||
} | ||
if (placeholder == "y") { | ||
return std::to_string(quadtreeID.y); | ||
} | ||
|
||
return placeholder; | ||
}); | ||
|
||
return CesiumUtility::Uri::resolve(baseUrl, url); | ||
} | ||
|
||
/*static*/ std::string ImplicitTiling::resolveUrl( | ||
const std::string& baseUrl, | ||
const std::string& urlTemplate, | ||
const CesiumGeometry::OctreeTileID& octreeID) { | ||
std::string url = CesiumUtility::Uri::substituteTemplateParameters( | ||
urlTemplate, | ||
[&octreeID](const std::string& placeholder) { | ||
if (placeholder == "level") { | ||
return std::to_string(octreeID.level); | ||
} | ||
if (placeholder == "x") { | ||
return std::to_string(octreeID.x); | ||
} | ||
if (placeholder == "y") { | ||
return std::to_string(octreeID.y); | ||
} | ||
if (placeholder == "z") { | ||
return std::to_string(octreeID.z); | ||
} | ||
|
||
return placeholder; | ||
}); | ||
|
||
return CesiumUtility::Uri::resolve(baseUrl, url); | ||
} | ||
|
||
} // namespace Cesium3DTilesContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters