3D Tiles要素表(Feature Table)数据格式标准规范

导航


引

官网文档


概述

要素表(Feature Table)是瓦片的实例二进制组件,用户描述每一个瓦片在 渲染 时的位置和外观属性。而批处理表(Batch Table),只用于包含应用程序特定的 属性,在渲染时不是必须的。

要素表可以被所有瓦片格式使用,例如批处理 3D 模型 (Batched 3D Model (b3dm)),每一个模型是一个要素;点云 (Point Cloud (pnts)),每一个点是一个要素。

每个要素的属性是由每种数据格式规范所定义的特定语法。例如,实例 3D 模型,SCALE_NON_UNIFORM 定义每个 3D 模型实例的非均匀比例。


文件结构

要素表由两部分组成:JSON 头和可选的小端字节序二进制主体。JSON 属性名称是数据格式特定的语法,并且它们的值可以直接在 JSON 中定义,也可以引用二进制主体部分。将长数字数组存储在二进制体中的效率更高。下图显示了要素表布局:

当一种数据包括要素表时,要素表紧随在若干个字节的文件头后。文件头还要包含 featureTableJSONByteLength 和 featureTableBinaryByteLength 的 uint32 字段,可用于表示要素表的各个部分。


结构填充

JSON 头必须以 8 个字节为界结束,否则,在 JSON 头尾部填充空格(0x20)以满足此要求。

二进制体必须以 8 个字节为界开始和结束。为了满足此要求,可以用任意值填充空白部分。

二进制属性必须以一个字节偏移量开始,该字节偏移量是必须是属性隐含类型大小的倍数。例如,组件的某个元素有 4 个字节长度的属性 FLOAT ,因此必须以 4 的倍数计算偏移量。为了满足此要求,可以用任意值填充空白部分。

这里如果看不懂,先把后面看完再回头来看,应该就懂了。


JSON 头

可以通过以下三种方式在 JSON 标中表示要素表的值:

  1. 单个值或对象,如,"INSTANCES_LENGTH": 4。

    • 这用于全局定义,如,"INSTANCES_LENGTH",它定义了实例化 3D 模型数据中的模型实例数。
  2. 数组,如,"POSITION" : [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]。

    • 这用于按要素定义,如,实例 3D 模型中的"POSITION"。如上面的数组,每个都 POSITION 对应 float32[3] 数据类型,因此有三个要素:要素 0's position= (1.0, 0.0, 0.0),要素 1's position= (0.0, 1.0, 0.0),要素 2's position= (0.0, 0.0, 1.0)。
  3. 一个指向二进制体中数据的引用,由具有 byteOffset 属性的对象表示,例如"SCALE" : { "byteOffset" : 24}。

    • byteOffset 指定相对于二进制体从零开始的偏移量。byteOffset 的值必须是属性隐含类型大小(以字节为单位)的倍数,例如,"POSITION"属性的数据类型是 FLOAT(4 个字节),因此 byteOffset的值必须是 4 的倍数 。

    • 语法定义了允许的数据类型。例如,实例 3D 模型的"POSITION"属性从二进制体中引用时,属性类型为FLOAT,属性长度为3。

    • 有些语法允许覆盖(override)属性隐含的类型。这些情况以每种图块格式指定,如,"BATCH_ID" : { "byteOffset" : 24, "componentType" : "UNSIGNED_BYTE"}。JSON 头中有效的属性是各个数据格式预定义的,以及可选的 extras 和 extensions 属性。应用程序特定的数据应存储在批处理表(Batch Table)中。

完整的 JSON 头定义,详见属性参考。以下是一个完整的 JSON 格式。

JSON:

{
  "$schema": "http://json-schema.org/draft-04/schema",
  "id": "featureTable.schema.json",
  "title": "Feature Table",
  "type": "object",
  "description": "A set of semantics containing per-tile and per-feature values defining the position and appearance properties for features in a tile.",
  "definitions": {
    "binaryBodyReference": {
      "title": "BinaryBodyReference",
      "type": "object",
      "description": "An object defining the reference to a section of the binary body of the features table where the property values are stored if not defined directly in the JSON.",
      "properties": {
        "byteOffset": {
          "type": "number",
          "description": "The offset into the buffer in bytes.",
          "minimum": 0
        },
        "componentType": {
          "type": "number",
          "description": "The datatype of components in the property. This is defined only if the semantic allows for overriding the implicit component type. These cases are specified in each tile format.",
          "enum": [
            "BYTE",
            "UNSIGNED_BYTE",
            "SHORT",
            "UNSIGNED_SHORT",
            "INT",
            "UNSIGNED_INT",
            "FLOAT",
            "DOUBLE"
          ]
        }
      },
      "required": ["byteOffset"]
    },
    "numericArray": {
      "type": "array",
      "items": {
        "type": "number"
      }
    },
    "property": {
      "title": "Property",
      "description": "A user-defined property which specifies per-feature application-specific metadata in a tile. Values either can be defined directly in the JSON as an array, or can refer to sections in the binary body with a `BinaryBodyReference` object.",
      "oneOf": [
        {
          "$ref": "#/definitions/binaryBodyReference"
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        {
          "type": "number"
        }
      ]
    },
    "globalPropertyBoolean": {
      "title": "GlobalPropertyBoolean",
      "description": "An object defining a global boolean property value for all features.",
      "type": "boolean"
    },
    "globalPropertyScalar": {
      "title": "GlobalPropertyScalar",
      "description": "An object defining a global numeric property value for all features.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "byteOffset": {
              "type": "number",
              "description": "The offset into the buffer in bytes.",
              "minimum": 0
            }
          },
          "required": ["byteOffset"]
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 1,
          "maxItems": 1
        },
        {
          "type": "number",
          "minimum": 0
        }
      ]
    },
    "globalPropertyCartesian3": {
      "title": "GlobalPropertyCartesian3",
      "description": "An object defining a global 3-component numeric property values for all features.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "byteOffset": {
              "type": "number",
              "description": "The offset into the buffer in bytes.",
              "minimum": 0
            }
          },
          "required": ["byteOffset"]
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 3,
          "maxItems": 3
        }
      ]
    },
    "globalPropertyCartesian4": {
      "title": "GlobalPropertyCartesian4",
      "description": "An object defining a global 4-component numeric property values for all features.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "byteOffset": {
              "type": "number",
              "description": "The offset into the buffer in bytes.",
              "minimum": 0
            }
          },
          "required": ["byteOffset"]
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 4,
          "maxItems": 4
        }
      ]
    }
  },
  "properties": {
    "extensions": {
      "$ref": "extension.schema.json"
    },
    "extras": {
      "$ref": "extras.schema.json"
    }
  },
  "additionalProperties": {
    "$ref": "#/definitions/property"
  }
}

二进制体

当 JSON 头包含对二进制文件的引用时,所提供的byteOffset内容将用于索引数据。下图显示了如何在要素表二进制体中索引数据:

使用要素数量来检索值,featuresLength;要素 ID,featureId;以及要素定义的其他数据类型(属性类型和长度)。


实例

本节是非规范性的

以下示例使用POSITION访问 position 属性,POSITION是float32[3]的类型:

var byteOffset = featureTableJSON.POSITION.byteOffset

var positionArray = new Float32Array(
  featureTableBinary.buffer,
  byteOffset,
  featuresLength * 3
) // There are three components for each POSITION feature.
var position = positionArray.subarray(featureId * 3, featureId * 3 + 3) // Using subarray creates a view into the array, and not a new array.

CesiumJS 的 3D Tiles 实现了读取要素表的功能,Cesium3DTileFeatureTable.js。


属性参考

要素表


要素表

一组语法定义,用于为瓦片中的要素提供每个瓦片每个要素的位置和属性的定义。

类型 描述 是否必须
extensions object 具有扩展特定对象的字典对象 No
extras any 应用特定数据 No

允许其他属性。


二进制体引用

一个对象,用于定义对要素表的二进制主体部分的引用,如果未在 JSON 头中直接定义属性值,则在该部分存储。

类型 描述 是否必须
byteOffset number 缓冲区的偏移量(以字节为单位) ✅ Yes

允许其他属性。


属性

用户定义的属性,用于在数据中指定每个功能的特定于应用程序的元数据。值可以直接在 JSON 中定义为数组,也可以使用 二进制体引用 对象引用二进制主体中的部分。

JSON 参考,见上面。



版权声明:
除非注明,本博文章均为原创,转载请以链接形式标明本文地址。



赏

   转载规则


《3D Tiles要素表(Feature Table)数据格式标准规范》 由 Jackie Tang(唐浩桀) 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
3D Tiles批处理表(Batch Table)数据格式标准规范 3D Tiles批处理表(Batch Table)数据格式标准规范
导航 引 概述 文件结构 结构填充 JSON 头 二进制体 实例 属性参考 引官网文档 概述批处理表是瓦片二进制体的一个组成部分,包含瓦片中每个要素的应用程序特定属性。在运行时查询这些属性以声明样式和任何应用程序特定的用法,例如
下一篇 
3D Tiles复合对象(Composite)数据格式标准规范 3D Tiles复合对象(Composite)数据格式标准规范
导航 引 概述 文件结构 结构填充 文件头 内部瓦片 文件扩展名和 MIME 类型 实现示例 引官网文档 概述复合对象格式允许拼接的不同格式的数据变成一个区块。 3D 瓦片和复合对象瓦片为流式异构数据集提供了灵活性
  目录