cesium-native 0.67.0
Loading...
Searching...
No Matches
FileFormat.h
1#pragma once
2
3#include <Cesium3DTiles/Library.h>
4
5#include <rapidjson/document.h>
6
7#include <cstddef>
8#include <span>
9#include <string>
10#include <unordered_map>
11
12namespace Cesium3DTiles {
13
18class CESIUM3DTILES_API FileFormat {
19public:
76
87 static CESIUM3DTILES_API std::string
88 getMagic(const std::span<const std::byte>& data, size_t length = 4);
89
99 static CESIUM3DTILES_API std::string getMagicForType(Type type);
100
110 static CESIUM3DTILES_API Type getTypeFromMagic(const std::string& magic);
111
121 static CESIUM3DTILES_API Type
122 getBestFittingFormat(const rapidjson::Document& document);
123
133 static CESIUM3DTILES_API Type
134 getBestFittingFormat(const std::span<const std::byte>& data);
135
136private:
137 static std::unordered_map<std::string, Type> _magicToType;
138 static std::unordered_map<Type, std::string> _typeToMagic;
139};
140
141} // namespace Cesium3DTiles
Utility for identifying file formats and content types supported in 3D Tiles.
Definition FileFormat.h:18
static Type getBestFittingFormat(const rapidjson::Document &document)
Infers the file format that best fits the given JSON document based on its available members.
Type
Enumerates the supported file formats for 3D Tiles.
Definition FileFormat.h:23
@ Composite
Indicates a Composite (cmpt) from 3D Tiles 1.0.
Definition FileFormat.h:43
@ SubtreeJson
Indicates a subtree in JSON format from 3D Tiles 1.1.
Definition FileFormat.h:55
@ Instanced3DModel
Indicates an Instanced 3D Model (i3dm) from 3D Tiles 1.0.
Definition FileFormat.h:47
@ Unknown
Indicates an unknown file format.
Definition FileFormat.h:27
@ SubtreeBinary
Indicates a subtree in binary (subt) format from 3D Tiles 1.1.
Definition FileFormat.h:59
@ Batched3dModel
Indicates a Batched 3D Model (b3dm) from 3D Tiles 1.0.
Definition FileFormat.h:39
@ GltfJson
Indicates a glTF model in JSON format.
Definition FileFormat.h:31
@ LayerJson
A quantized-mesh layer.json. Alhough quantized-mesh is distinct from the 3D Tiles spec,...
Definition FileFormat.h:69
@ PointCloud
Indicates a Point Cloud (pnts) from 3D Tiles 1.0.
Definition FileFormat.h:51
@ GltfBinary
Indicates a glTF model in binary (glb) format.
Definition FileFormat.h:35
@ GeoJson
A GeoJSON file, supported in 3D Tiles through CesiumTilesetJson::ExtensionTilesetMaxarContentGeoJson.
Definition FileFormat.h:74
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.
static std::string getMagicForType(Type type)
Gets the magic identifier associated with the given file format. Returns an empty string if no magic ...
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 st...
static Type getTypeFromMagic(const std::string &magic)
Gets the file format type associated with the given magic identifier. Returns Type::Unknown if no typ...
Classes that represent or enable fundamental elements of 3D Tiles.