IonAssetElementService
Cesium v1.147 · 中文

使用 BIM/CAD 数据库模型支持的 ion REST API 的 Asset Elements 端点,查询 Cesium ion 资产中的单个元素。 Element ids are typically obtained by picking a Cesium3DTileFeature 并读取其 element 属性获得的。 此对象通常不直接实例化,应使用 IonAssetElementService.fromAssetId。

new Cesium.IonAssetElementService(options)

Name Type Description
options object 具有以下属性的对象:
Name Type Description
assetId number ion 资产 ID。
resource Resource 资产的 ion API 资源。
Example:
const elements = Cesium.IonAssetElementService.fromAssetId(123456);
const page = await elements.listElements({
filter: { "IFC Attributes.name": { $like: "%Rebar%" } },
top: 50,
});
console.log(`${page.items.length} of ${page.total} elements`);
Experimental

This 该特性不是最终的,并且根据 Cesium 的标准弃用政策可能会发生变化。

See:

Extends

Members

此服务所操作的 ion 资产 ID。

Methods

static Cesium.IonAssetElementService.fromAssetId(assetId, options) → IonAssetElementService

为给定的 ion 资产创建 IonAssetElementService。
Name Type Description
assetId number 由 BIM/CAD 数据库模型支持的资产的 ion ID。
options object optional 具有以下属性的对象:
Name Type Default Description
accessToken string Ion.defaultAccessToken optional 要使用的 ion 访问令牌。
server string | Resource Ion.defaultServer optional 要使用的 ion API 服务器。
Returns:
A 绑定到资产的服务。

static Cesium.IonAssetElementService.getBoundingSphere(element) → BoundingSphere|undefined

Computes a BoundingSphere enclosing an element from its location 计算包围该元素的 BoundingSphere,适用于使用 Camera#flyToBoundingSphere 或 Viewer#zoomTo 调整相机视角。
Name Type Description
element IonAssetElementService.Element 由 IonAssetElementService#getElement 或 IonAssetElementService#listElements 返回的实体。
Returns:
A 实体的边界球体,如果实体没有有效位置则为 undefined。
Example:
const element = await elements.getElement(elementId);
const boundingSphere = Cesium.IonAssetElementService.getBoundingSphere(element);
if (Cesium.defined(boundingSphere)) {
viewer.camera.flyToBoundingSphere(boundingSphere);
}

static Cesium.IonAssetElementService.getElementId(feature) → string|undefined

从选中的 Cesium3DTileFeature 中读取实体 ID。进行渲染。 特征在其 element 属性中携带所属实体的 ID。 返回的 ID 可以直接传递给 IonAssetElementService#getElement。
Name Type Description
feature Cesium3DTileFeature 从资产 tileset 中选中的特征。
Returns:
The 作为十进制字符串的实体 ID,例如 "3298534886898",如果特征没有实体 ID 则为 undefined。
Example:
const feature = viewer.scene.pick(movement.position);
const elementId = Cesium.IonAssetElementService.getElementId(feature);
if (Cesium.defined(elementId)) {
const element = await elements.getElement(elementId);
}

async aggregate(options) → Promise.<{aggregations: Array.<IonAssetElementService.Aggregation>, total: number}>

计算该资产中一个或多个数值属性的聚合统计信息(计数、最小值、最大值、平均值和总和)。 可选地,针对已过滤的元素进行统计。 聚合统计信息。如果请求失败,则承诺会拒绝并抛出 RequestErrorEvent。
Name Type Description
options object 包含以下属性的对象:
Name Type Description
propertyKeys Array.<string> 用于聚合的限定属性键。至少需要一个。
filter object | string optional 一个元素过滤器。有关支持的结构,请参阅Aggregate elements ion REST API 文档中的查询参数部分。
Returns:
一个承诺,用于获取聚合统计信息。如果请求失败,则承诺会拒绝并抛出 RequestErrorEvent。
Throws:
  • DeveloperError : options.propertyKeys 必须是一个非空字符串数组。
Example:
try {
const result = await elements.aggregate({
propertyKeys: ["Volume Aspect.Net Volume"],
filter: { "IFC Class Name": "ifcwall" },
  });
console.log(result.aggregations, result.total);
} catch (error) {
console.error(error.statusCode, error.response);
};
检索单个实体的元数据和位置信息。 使用 IonAssetElementService.getElementId 从 选中的 Cesium3DTileFeature 中获取 ID。
Name Type Description
elementId string 作为十进制字符串的实体 ID,例如 "3298534886898"。
Returns:
A 一个承诺,用于获取请求的元素。如果请求失败或元素不存在,则承诺会拒绝并抛出 RequestErrorEvent。

async getElementTreeChildren(options) → Promise.<{nodes: Array.<IonAssetElementService.ElementTreeNode>}>

列出该资产元素树中节点的子节点,或当未指定键时列出根节点。 包含以下属性的对象:
Name Type Description
options object optional 由端点返回的不透明节点键。省略它以列出根节点。
Name Type Description
nodeKey string optional 一个承诺,用于获取子节点。如果请求失败或提供了不存在的节点键,则承诺会拒绝并抛出 RequestErrorEvent。
Returns:
A promise that resolves to the child nodes. The promise rejects with a RequestErrorEvent if the request fails or a key for a node that does not exist is provided.
Throws:
  • DeveloperError : options.nodeKey try {
Example:
const { nodes } = await elements.getElementTreeChildren();
const { nodes: children } = await elements.getElementTreeChildren({
nodeKey: nodes[0].key,
console.log(nodes);
  });
} catch (error) {
console.error(error.statusCode, error.response);
获取该资产元素树中元素的父节点,从根节点到该元素,使用 ion 的 <code>tree/parents</code> 端点。
}

async getElementTreeParents(elementId) → Promise.<{path: Array.<IonAssetElementService.ElementTreePathEntry>}>

作为十进制字符串的元素 ID,例如 "3298534886898"。 一个承诺,用于获取根优先路径。如果请求失败或不存在路径,则承诺会拒绝并抛出 RequestErrorEvent。
Name Type Description
elementId string 必须是一个字符串。
Returns:
A promise that resolves to the root-first path. The promise rejects with a RequestErrorEvent if the request fails or no path exists.
Throws:
  • DeveloperError : elementId const { path } = await elements.getElementTreeParents(elementId);
Example:
console.log(path);
} catch (error) {
console.error(error.statusCode, error.response);
} catch (error) {
console.error(error.statusCode, error.response);
}
检索该资产的页面中的实体,可选择性过滤。 结果以不透明光标进行分页。通过传递返回的 continuationToken 作为 options.continuationToken 来请求后续页面,直到其变为 undefined。 具有以下属性的对象:
Name Type Description
options object optional 每页返回的实体最大数量。
Name Type Default Description
top number 100 optional 从之前调用中返回的用于获取下一页结果的令牌。
continuationToken string optional 一个实体过滤器。有关支持的结构,请参阅 List elements ion REST API 文档中的查询参数部分。
filter object | string optional 一个 promise,用于返回页面中的实体。如果请求失败,promise 会拒绝并抛出 RequestErrorEvent。
Returns:
A promise that resolves to a page of elements. The promise rejects with a RequestErrorEvent if the request fails.
Throws:
  • DeveloperError : options.top 必须是字符串。
  • DeveloperError : options.continuationToken const page = await elements.listElements({
Example:
filter: {
filter: {
$or: [{ "IFC Class Name": "ifcwall" }, { "IFC Class Name": "ifccolumn" }],
  },
});

Type Definitions

Cesium.IonAssetElementService.Aggregation

一组元素中单个数值属性的聚合统计信息。 由 IonAssetElementService#aggregate 返回的统计信息。 非数值属性会返回 count 为 0 的结果。 最小值、最大值和平均值返回 null,总和返回 0。
Properties:
Name Type Description
propertyKey string 这些统计信息所描述的限定属性键。
count number 具有该属性键数值的元素数量。
min number | null 匹配元素中的最小值,或者当没有数值时返回 null。
max number | null 匹配元素中的最大值,如果没有数值则为 null。
avg number | null 匹配元素的平均值,如果没有数值则为 null。
sum number 匹配元素中数值的总和。

Cesium.IonAssetElementService.Element

Cesium 离子资产中的单个元素,例如 BIM/CAD 模型中的墙或柱子。 该元素的唯一整数标识符,以十进制字符串形式表示,例如 "3298534886898"。
Properties:
Name Type Attributes Description
id string 该元素的用户友好标签(如果有的话)。
label string <optional>
该元素的地理位置,或者当元素没有位置时返回 undefined(例如概念性元素或没有地理坐标系统的资产)。
location IonAssetElementService.ElementLocation <optional>
该元素的属性,按属性名称排序。结果列表可能省略某些属性;使用 IonAssetElementService#getElement 获取元素详细信息。属性名称保持原样,包括任何点号命名空间(例如 "Volume Aspect.Net Volume")。
properties Object.<string, IonAssetElementService.ElementProperty> <optional>
IonAssetElementService#listElements 返回的结果页面。

Cesium.IonAssetElementService.ElementLocation

IonAssetElementService.Element 的地理位置,仅在元素具有地理位置时显示。 仅当元素具有地理位置时显示。

Cesium.IonAssetElementService.ElementPage

A page of results from IonAssetElementService#listElements.
Properties:
Name Type Attributes Description
items Array.<IonAssetElementService.Element> 所有页面中符合查询条件的元素总数,或者当无法获取总数时返回 null。
total number | null 用于获取下一页的令牌,作为 options.continuationToken 传递,或者当没有更多结果时返回 undefined。
continuationToken string <optional>
单个数值属性的聚合统计信息,由 IonAssetElementService#aggregate 返回。

Cesium.IonAssetElementService.ElementProperty

IonAssetElementService.Element 的单个属性。
Properties:
Name Type Attributes Description
value * 该属性的原始值。
displayValue string <optional>
可阅读且预格式化的数值,包含任何单位后缀(例如 "0.6208 m³")。
units string | null <optional>
value 的单位,或者当属性无单位时返回 null 或 undefined。

Cesium.IonAssetElementService.ElementTreeNode

Cesium ion 资产元素树中的一个节点,由 IonAssetElementService#getElementTreeChildren 返回。
Properties:
Name Type Description
key string 该节点的不透明键。将它作为 options.nodeKey 传递给 IonAssetElementService#getElementTreeChildren 以列出该节点的子节点。
label string 该节点的用户友好标签。
hasChildren boolean 该节点是否有子节点。
id string 该节点所代表的整数实例 ID,以十进制字符串形式表示。
kind "subject" | "model" | "category" | "element" 节点的类型。

Cesium.IonAssetElementService.ElementTreePathEntry

由 IonAssetElementService#getElementTreeParents 返回的根优先路径中的条目。条目包括 目标元素及其祖先元素。
Properties:
Name Type Description
kind "subject" | "model" | "category" | "element" 路径条目的类型。
id string 该主题、模型、类别或元素的整数实例 ID,以十进制字符串形式表示。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.