实体

AMD: require(["geoscene/rest/knowledgeGraph/Entity"], (Entity) => { /* code goes here */ });
ESM: import Entity from "@geoscene/core/rest/knowledgeGraph/Entity";
类: geoscene/rest/knowledgeGraph/Entity
起始版本:GeoScene Maps SDK for JavaScript 4.25
beta

实体是可以存在于知识图谱中的 EntityType 的特定实例。实体通常表示真实世界的对象或位置,例如人、组织、建筑物或车辆。每个实体都有一组由其所属的实体类型定义的属性。

另请参阅
示例
//create a new entity
require([
   "geoscene/rest/knowledgeGraphService",
   "geoscene/rest/knowledgeGraph/Entity",
  ], (knowledgeGraphModule, Entity) => {
  const newEntity = new Entity({
    typeName: "Supplier",
    properties: {
      Name: "Supplier 5",
      EmployeeCount: 681
    }
  });
});
//searches for 'solar' in the properties of all entities in a knowledge graph
require([
 "geoscene/rest/knowledgeGraphService"
], (KnowledgeGraphModule)  => {
 KnowledgeGraphModule
   .executeSearch(kg, {
     searchQuery: "solar",
     typeCategoryFilter: "entity",
   })
   .then((queryResult) => {
     // do something with the search results
     console.log("Graph Search Result", queryResult);
   });
});
//example of a return from the above search, printed to the console.
{
 resultRows: [{
  "declaredClass": "geoscene.rest.knowledgeGraph.Entity",
  "properties": {
    "shape": {
      "declaredClass": "geoscene.geometry.Point",
      "cache": {},
      "hasM": false,
      "hasZ": false,
      "latitude": 53.589000000000009,
      "longitude": -0.9633,
      "type": "point",
      "extent": null,
      "spatialReference": {
       "wkid": 4326
      },
      "x": -0.9633,
      "y": 53.589000000000009
    },
    "Name": "Suncommon",
    "Employee_Count": 400,
    "energyType": "solar"
  },
  "typeName": "Company",
  "id": ""{9D2D6AFD-41F1-49A4-8412-CACCC9906E88}","
 }]
}

构造函数

new Entity(properties)
参数
properties Object
optional

有关可能传递给构造函数的所有属性的列表,请参见属性

示例
// create a new entity object
const newEntity = new Entity({
    typeName: "Supplier",
    properties: {
      Name: "Supplier 5",
      EmployeeCount: 681
    }
s});

属性概述

可以设置、检索或侦听任何属性。请参阅使用属性主题。
显示继承属性 隐藏继承属性
名称 类型 描述
String

类的名称。

更多详情
Accessor
String

对象的唯一 ID。

更多详情
GraphNamedObject
Object

图谱对象的属性。

更多详情
GraphObject
String

指定知识图谱中定义的所有类似类型对象 (entitiesrelationships) 的名称。

更多详情
GraphNamedObject

属性详细信息

declaredClass Stringreadonly inherited

类的名称。声明的类名称格式化为 geoscene.folder.className

对象的唯一 ID。

properties Object inherited

图谱对象的属性。对于实体关系,属性由其实体类型关系类型指定。属性的值特定于对象。

示例
//example of properties structure that includes geometry
"properties": {
  "shape": {
    "declaredClass": "geoscene.geometry.Point",
    "cache": {},
    "hasM": false,
    "hasZ": false,
    "latitude": 53.589000000000009,
    "longitude": -0.9633,
    "type": "point",
    "extent": null,
    "spatialReference": {
      "wkid": 4326
    },
    "x": -0.9633,
    "y": 53.589000000000009
  },
  "Name": "Suncommon",
  "Employee_Count": 400,
  "Address": "123 Broadway, New York, New York",
  "EnergyType": "solar"
}
//two entities of different entity types with different properties
[{
  "declaredClass": "geoscene.rest.knowledgeGraph.Entity",
  "properties": {
    "Name": "Suncommon",
    "Employee_Count": 400,
    "energyType": "solar"
  },
  "typeName": "Company",
  "id": "1256"
},
{
  "declaredClass": "geoscene.rest.knowledgeGraph.Entity",
  "properties": {
    "Name": "Empire State Building",
    "height": 1454,
    "heightUnits": "feet",
    "city": "New York"
  },
  "typeName": "Building",
  "id": "B7889541"
}]
//two relationships of different relationship types with different properties
[{
  "declaredClass": "geoscene.rest.Relationship.Relationship",
  "properties": {
    "start_date": "2020-04-17",
    "employee_id": "4589",
    "office": "152 Building A"
  },
  "typeName": "Employed_by",
  "id": "B7889541"
},
{
  "declaredClass": "geoscene.rest.Relationship.Relationship",
  "properties": {
    "quantity": 125000,
    "frequency": "bi-weekly",
    "contact_person": "Betty White"
  },
  "typeName": "buys_part",
  "id": "B7889541"
}]
typeName String inherited

指定知识图谱中定义的所有类似类型对象 (entitiesrelationships) 的名称。例如,组织的知识图谱中的所有 'employee’ 实体都可能具有 typeName 'employee'。

方法概述

显示继承的方法 隐藏继承的方法
名称 返回值类值 描述

添加一个或多个与对象的生命周期相关联的句柄。

更多详情
Accessor
Boolean

如果存在指定的句柄组,则返回 true。

更多详情
Accessor

移除对象拥有的句柄组。

更多详情
Accessor

方法详细说明

addHandles(handleOrHandles, groupKey)inherited

添加一个或多个与对象的生命周期相关联的句柄。当对象被销毁时,将移除句柄。

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

// Handle gets removed when the object is destroyed.
this.addHandles(handle);
参数
handleOrHandles WatchHandle|WatchHandle[]

对象销毁后,标记为要移除的句柄。

groupKey *
optional

标识句柄应添加到的组的键。组中的所有句柄稍后都可使用 Accessor.removeHandles() 进行删除。如果未提供键,则句柄将被添加到默认组。

hasHandles(groupKey){Boolean}inherited

如果存在指定的句柄组,则返回 true。

参数
groupKey *
optional

组键。

返回
类型 描述
Boolean 如果存在指定的句柄组,则返回 true
示例
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}
removeHandles(groupKey)inherited

移除对象拥有的句柄组。

参数
groupKey *
optional

要移除的组键或组键的数组或集合。

示例
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

您的浏览器不再受支持。请升级您的浏览器以获得最佳体验。请参阅浏览器弃用帖子以获取更多信息