You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何定义Orion负载,实现背景图标记点的JSON格式表示?

在Orion Context Broker中表示背景图上的标记点(JSON格式)

核心思路

Orion Context Broker通过**实体(Entity)和属性(Attribute)**建模上下文信息。针对800×500背景图加标记点的需求,有两种实用建模方式:


方式1:画布与标记点合并为单个实体(适合静态/批量场景)

将背景图建模为自定义类型实体,标记点作为该实体的数组属性。结构紧凑,适合标记点无需单独更新的场景。

创建实体的JSON请求示例(NGSI-v2)

{
  "id": "canvas_office_floorplan_800x500",
  "type": "ImageCanvas",
  "backgroundSize": {
    "type": "StructuredValue",
    "value": {
      "width": 800,
      "height": 500,
      "unit": "pixel"
    }
  },
  "markers": {
    "type": "Array",
    "value": [
      {
        "x": 150,
        "y": 220,
        "markerType": "pin",
        "label": "会议室A",
        "color": "#ff0000"
      },
      {
        "x": 480,
        "y": 350,
        "markerType": "circle",
        "label": "打印机",
        "radius": 8
      }
    ]
  }
}

字段说明

  • id:实体唯一标识,可根据业务自定义
  • type:自定义实体类型(如ImageCanvas),用于区分不同上下文实体
  • backgroundSize:存储画布尺寸,类型为StructuredValue(结构化值)
  • markers:标记点数组,每个元素包含:
    • x/y:标记点相对于画布左上角的像素坐标(原点为左上角)
    • markerType:标记样式(如pin、circle)
    • 自定义扩展字段:如label(显示文本)、color(标记颜色)等

方式2:标记点作为独立实体(适合动态更新场景)

若需单独更新某个标记点的位置或属性,可将每个标记点建模为独立实体,通过关联属性绑定到画布。

画布实体示例

{
  "id": "canvas_office_floorplan_800x500",
  "type": "ImageCanvas",
  "backgroundSize": {
    "type": "StructuredValue",
    "value": {
      "width": 800,
      "height": 500,
      "unit": "pixel"
    }
  }
}

单个标记点实体示例

{
  "id": "marker_meeting_room_a",
  "type": "MapMarker",
  "refCanvas": {
    "type": "Relationship",
    "value": "canvas_office_floorplan_800x500"
  },
  "position": {
    "type": "StructuredValue",
    "value": {
      "x": 150,
      "y": 220,
      "unit": "pixel"
    }
  },
  "markerType": {
    "type": "Text",
    "value": "pin"
  },
  "label": {
    "type": "Text",
    "value": "会议室A"
  }
}

字段说明

  • refCanvas:类型为Relationship,用于关联所属画布实体
  • position:存储标记点像素坐标,类型为StructuredValue
  • 其他属性可根据业务需求自由扩展

注意事项

  1. 坐标原点:默认以画布左上角为原点(x向右递增,y向下递增),需与前端渲染逻辑保持一致
  2. 属性类型:严格遵循NGSI规范,数组用Array、结构化数据用StructuredValue、关联关系用Relationship
  3. NGSI-LD兼容:如需使用NGSI-LD格式,只需添加@context字段并调整实体类型命名规则

内容的提问来源于stack exchange,提问作者pasquy73

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 06:05:20