cesium-native 0.67.0
Loading...
Searching...
No Matches
Cesium3DTiles::FileFormat Class Reference

Utility for identifying file formats and content types supported in 3D Tiles. More...

#include <Cesium3DTiles/FileFormat.h>

Public Types

enum class  Type {
  Unknown , GltfJson , GltfBinary , Batched3dModel ,
  Composite , Instanced3DModel , PointCloud , SubtreeJson ,
  SubtreeBinary , TilesetJson , LayerJson , GeoJson
}
 Enumerates the supported file formats for 3D Tiles. More...
 

Static Public Member Functions

static std::string getMagic (const std::span< const std::byte > &data, size_t length=4)
 Retrieves the specified number of bytes at the start of the given buffer, and interprets them as a string magic identifier for the data.
 
static std::string getMagicForType (Type type)
 Gets the magic identifier associated with the given file format. Returns an empty string if no magic exists.
 
static Type getTypeFromMagic (const std::string &magic)
 Gets the file format type associated with the given magic identifier. Returns Type::Unknown if no type has the specified magic.
 
static Type getBestFittingFormat (const rapidjson::Document &document)
 Infers the file format that best fits the given JSON document based on its available members.
 
static Type getBestFittingFormat (const std::span< const std::byte > &data)
 Infers the file format that best fits the given data buffer based on its four-letter magic.
 

Detailed Description

Utility for identifying file formats and content types supported in 3D Tiles.

Definition at line 18 of file FileFormat.h.

Member Enumeration Documentation

◆ Type

Enumerates the supported file formats for 3D Tiles.

Enumerator
Unknown 

Indicates an unknown file format.

GltfJson 

Indicates a glTF model in JSON format.

GltfBinary 

Indicates a glTF model in binary (glb) format.

Batched3dModel 

Indicates a Batched 3D Model (b3dm) from 3D Tiles 1.0.

Composite 

Indicates a Composite (cmpt) from 3D Tiles 1.0.

Instanced3DModel 

Indicates an Instanced 3D Model (i3dm) from 3D Tiles 1.0.

PointCloud 

Indicates a Point Cloud (pnts) from 3D Tiles 1.0.

SubtreeJson 

Indicates a subtree in JSON format from 3D Tiles 1.1.

SubtreeBinary 

Indicates a subtree in binary (subt) format from 3D Tiles 1.1.

TilesetJson 

A tileset.json.

LayerJson 

A quantized-mesh layer.json. Alhough quantized-mesh is distinct from the 3D Tiles spec, cesium-native supports quantized-mesh by converting it to 3D Tiles at runtime.

GeoJson 

A GeoJSON file, supported in 3D Tiles through CesiumTilesetJson::ExtensionTilesetMaxarContentGeoJson.

Definition at line 23 of file FileFormat.h.

Member Function Documentation

◆ getBestFittingFormat() [1/2]

static Type Cesium3DTiles::FileFormat::getBestFittingFormat ( const rapidjson::Document & document)
static

Infers the file format that best fits the given JSON document based on its available members.

Parameters
documentThe parsed JSON document.
Returns
The best-fitting file format, or Type::Unknown if one could not be deduced.

◆ getBestFittingFormat() [2/2]

static Type Cesium3DTiles::FileFormat::getBestFittingFormat ( const std::span< const std::byte > & data)
static

Infers the file format that best fits the given data buffer based on its four-letter magic.

Parameters
dataThe binary data.
Returns
The best-fitting file format, or Type::Unknown if one could not be deduced.

◆ getMagic()

static std::string Cesium3DTiles::FileFormat::getMagic ( const std::span< const std::byte > & data,
size_t length = 4 )
static

Retrieves the specified number of bytes at the start of the given buffer, and interprets them as a string magic identifier for the data.

Parameters
dataThe data buffer.
lengthThe target length for the magic.
Returns
The bytes as a string magic identifier. If there are less bytes than requested, returns an empty string.

◆ getMagicForType()

static std::string Cesium3DTiles::FileFormat::getMagicForType ( Type type)
static

Gets the magic identifier associated with the given file format. Returns an empty string if no magic exists.

Parameters
typeThe file format type.
Returns
The magic associated with the format, or an empty string if there isn't one.

◆ getTypeFromMagic()

static Type Cesium3DTiles::FileFormat::getTypeFromMagic ( const std::string & magic)
static

Gets the file format type associated with the given magic identifier. Returns Type::Unknown if no type has the specified magic.

Parameters
magicThe magic identifier.
Returns
The file format type associated with the magic, or Type::Unknown if there is no such type.

The documentation for this class was generated from the following file: