API列表

设备数据API

获取设备详情

请求方式: GET

URL: http(s)://localhost:8844/api/v1/device/{deviceId}/_detail

说明:{deviceId}需要替换为设备实例的id。

返回参数:

名称类型描述
resultDeviceDetail返回值
statusint状态码
codeString业务编码

DeviceDetail参数如下:

名称类型描述
idString设备ID
nameString设备名称
protocolString消息协议标识
transportString通信协议
orgIdString所属机构ID
orgNameString所属机构名称
productIdString型号ID
productNameString型号名称
deviceTypeDeviceType设备类型
stateDeviceState设备状态
addressString客户端地址
onlineTimelong上线时间
offlineTimelong离线时间
registerTimelong注册时间
createTimelong创建时间
metadataString设备元数据(在设备型号功能定义中定义)
configurationMap<String,Object>设备配置信息
tagsList<DeviceTagEntity>标签

标签(DeviceTagEntity)参数说明:

名称类型描述
deviceIdString设备ID
keyString
nameString标签名
valueString
typeString标签类型
createTimeDate创建时间
descriptionString描述

请求示例:

RequestUrl: http(s)://localhost:8844/api/v1/device/1236859833832701952/_detail

RequestMethod: GET

RequestHeader: X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ

说明:

X-Sign为签名,param+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

HttpResponse:

  1. {
  2. "result": {
  3. "id": "test001",
  4. "name": "温控设备0309",
  5. "protocol": "demo-v1",
  6. "transport": "MQTT",
  7. "productId": "1236859833832701952",
  8. "productName": "智能温控",
  9. "deviceType": {
  10. "text": "网关设备",
  11. "value": "gateway"
  12. },
  13. "state": {
  14. "text": "离线",
  15. "value": "offline"
  16. },
  17. "address": "/127.0.0.1:46360",
  18. "onlineTime": 1586422112901,
  19. "offlineTime": 1586424932209,
  20. "createTime": 1585809343175,
  21. "registerTime": 1583805253659,
  22. "metadata": "{\"events\":[{\"id\":\"fire_alarm\",\"name\":\"火警报警\",\"expands\":{\"eventType\":\"reportData\",\"level\":\"urgent\"},\"valueType\":{\"type\":\"object\",\"properties\":[{\"id\":\"a_name\",\"name\":\"区域名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"b_name\",\"name\":\"建筑名称\",\"valueType\":{\"type\":\"string\"}},{\"id\":\"l_name\",\"name\":\"位置名称\",\"valueType\":{\"type\":\"string\"}}]}}],\"properties\":[{\"id\":\"temperature\",\"name\":\"温度\",\"valueType\":{\"type\":\"float\",\"min\":\"0\",\"max\":\"100\",\"step\":\"0.1\",\"unit\":\"celsiusDegrees\"},\"expands\":{\"readOnly\":\"true\"}}],\"functions\":[{\"id\":\"get-log\",\"name\":\"获取日志\",\"isAsync\":true,\"output\":{\"type\":\"string\",\"expands\":{\"maxLength\":\"2048\"}},\"inputs\":[{\"id\":\"start_date\",\"name\":\"开始日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"end_data\",\"name\":\"结束日期\",\"valueType\":{\"type\":\"date\",\"dateFormat\":\"yyyy-MM-dd HH:mm:ss\"}},{\"id\":\"time\",\"name\":\"分组\",\"valueType\":{\"type\":\"string\"}}]}]}",//在设备型号功能定义中定义
  23. "configuration": {
  24. "username": "test",
  25. "password": "test"
  26. },
  27. "tags": []
  28. },
  29. "status": 200,
  30. "code": "success"
  31. }

批量保存设备

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device

http body 请求参数为DeviceSaveDetail集合:

DeviceSaveDetail 参数如下:

名称类型是否必选示例值描述
idStringtest002设备实例ID
nameString温控设备002设备实例名称
productIdString1236859833832701952型号ID
productNameString智能温控型号名称
configurationMap<String,Object>设备配置信息,根据不同的协议配置不同,如果MQTT用户名密码等
creatorIdString1199596756811550720创建人ID
creatorNameString管理员创建人名称
tagsList<DeviceTagEntity>标签

标签(DeviceTagEntity)参数说明:

名称类型描述
deviceIdString设备ID
keyString
nameString标签名
valueString
typeString标签类型
createTimeDate创建时间
descriptionString描述

返回参数:

名称类型描述
resultint保存数量
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/device

RequestMethod: POST

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. [{
  2. "id": "test002",
  3. "name": "设备002",
  4. "productId": "1236859833832701952",
  5. "configuration": {
  6. "username": "test002",
  7. "password": "test002"
  8. },
  9. "tags": [{
  10. "deviceId": "test002",
  11. "key": "area",
  12. "name": "地区",
  13. "value": "chongqing"
  14. }]
  15. },
  16. {
  17. "id": "test003",
  18. "name": "设备名称",
  19. "productId": "1236859833832701952",
  20. "configuration": {}
  21. },
  22. {
  23. "id": "test004",
  24. "name": "设备名称",
  25. "productId": "1236859833832701952",
  26. "configuration": {}
  27. }
  28. ]

HttpResponse:

  1. {"result":3,"status":200,"code":"success"}

批量激活设备

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/_deploy

http body 请求参数为设备id集合,List

返回参数:

名称类型描述
resultint激活数量
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/\_deploy

RequestMethod: POST

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. ["test002","test003", "test004"]

HttpResponse:

  1. {"result":3,"status":200,"code":"success"}

批量注销设备

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/_unDeploy

http body 请求参数为设备id集合,List

返回参数:

名称类型描述
resultint注销成功数量
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/\_unDeploy

RequestMethod: POST

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. ["test002","test003", "test004"]

HttpResponse:

  1. {"result":3,"status":200,"code":"success"}

批量删除设备

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/_delete

http body 请求参数为设备id集合,List

返回参数:

名称类型描述
resultint注销成功数量
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/\_delete

RequestMethod: POST

RequestHeader:
X-Sign: 67ed4ec***********c6edabad75
X-Timestamp: 1587609804558
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. ["test002","test003", "test004"]

HttpResponse:

  1. {"result":3,"status":200,"code":"success"}

查询设备列表

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/_query

http body 请求参数:

公共查询参数:请参考公共查询参数

根据设备实例(DeviceInstanceEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备实例(DeviceInstanceEntity)参数如下:

名称类型是否必选示例值描述
idStringtest001设备实例ID
nameString温控设备001设备实例名称
describeString说明
productIdString1236859833832701952型号ID
productNameString智能温控型号名称
configurationMap<String,Object>其他配置
deriveMetadataString派生元数据,有的设备的属性,功能,事件可能会动态的添加
stateDeviceStateonline状态
creatorIdString1199596756811550720创建人ID
creatorNameString管理员创建人名称
createTimeLong1584586676863创建时间
registryTimeLongonline激活时间
orgIdStringdepartment机构ID
parentIdString父级设备ID

返回参数:

名称类型描述
resultPagerResult<DeviceInfo>分页结果
statusint状态码
codeString业务编码

PagerResult参数如下:

名称类型描述
pageIndexint页码
pageSizeint每页数量
totalint返回数据总数
dataList<DeviceInfo>返回数据集合

DeviceInfo参数如下:

名称类型描述
idString设备ID
nameString设备名称
productIdString型号ID
productNameString型号名称
stateDeviceState设备状态
registerTimelong注册时间
createTimelong创建时间
parentIdString父级设备ID

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/\_query

RequestMethod: POST

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "pageSize": 25,
  3. "pageIndex": 0,
  4. "terms": [{
  5. "column": "productId",
  6. "value": "1236859833832701952"
  7. }]
  8. }

HttpResponse:

  1. {
  2. "result": {
  3. "pageIndex": 0,
  4. "pageSize": 1000,
  5. "total": 3,
  6. "data": [{
  7. "id": "test0312",
  8. "name": "设备0312",
  9. "productId": "1236859833832701952",
  10. "productName": "智能温控",
  11. "state": {
  12. "text": "未激活",
  13. "value": "notActive"
  14. },
  15. "registerTime": 0,
  16. "createTime": 1583997946670
  17. }, {
  18. "id": "test001",
  19. "name": "温控设备0309",
  20. "productId": "1236859833832701952",
  21. "productName": "智能温控",
  22. "state": {
  23. "text": "离线",
  24. "value": "offline"
  25. },
  26. "registerTime": 1583805253659,
  27. "createTime": 1585809343175
  28. }, {
  29. "id": "MQTT_FX_Client",
  30. "name": "mqttfx",
  31. "productId": "1236859833832701952",
  32. "productName": "智能温控",
  33. "state": {
  34. "text": "离线",
  35. "value": "offline"
  36. },
  37. "registerTime": 1584330967254,
  38. "createTime": 1584330960918
  39. }]
  40. },
  41. "status": 200,
  42. "code": "success"
  43. }

根据设备ID类型和动态查询参数查询设备相关数据

请求方式: POST

URL: http(s)://localhost:8844/api/v1/{deviceId}/log/_query

说明:{deviceId}需要替换为设备实例的id。

http body 请求参数:

公共查询参数:请参考公共查询参数

根据设备操作日志(DeviceOperationLogEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备操作日志(DeviceOperationLogEntity)参数如下:

名称类型是否必选示例值描述
idStringLoymU3EBCTcV5s5DbSn7设备实例ID
productIdString1236859833832701952型号ID
typeDeviceLogTypereadProperty类型
createTimeLong1584586676863创建时间
orgIdStringdepartment机构ID

返回参数:

名称类型描述
resultPagerResult<DeviceInfo>分页结果
statusint状态码
codeString业务编码

PagerResult参数如下:

名称类型描述
pageIndexint页码
pageSizeint每页数量
totalint返回数据总数
dataList<DeviceInfo>返回数据集合

DeviceInfo参数如下:

名称类型描述
idString设备ID
nameString设备名称
productIdString型号ID
productNameString型号名称
stateDeviceLogType设备状态
registerTimelong注册时间
createTimelong创建时间
parentIdString父级设备ID

请求示例
RequestUrl: http://localhost:8844/api/v1/device/test001/log/\_query

RequestMethod: POST

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "pageSize": 25,
  3. "pageIndex": 0,
  4. "terms": [{
  5. "column": "productId",
  6. "value": "1236859833832701952"
  7. }]
  8. }

HttpResponse:

  1. {
  2. "result": {
  3. "pageIndex": 0,
  4. "pageSize": 25,
  5. "total": 4,
  6. "data": [{
  7. "id": "fa1528090a464e3f0bf3839ce0c1315",
  8. "deviceId": "test001",
  9. "productId": "1236859833832701952",
  10. "type": {
  11. "text": "上线",
  12. "value": "online"
  13. },
  14. "createTime": 1586422112000,
  15. "content": "设备上线"
  16. }, {
  17. "id": "eb7d05c8dda18bc37434bf7f98799ba7",
  18. "deviceId": "test001",
  19. "productId": "1236859833832701952",
  20. "type": {
  21. "text": "离线",
  22. "value": "offline"
  23. },
  24. "createTime": 1586419084000,
  25. "content": "设备离线"
  26. }, {
  27. "id": "34a89eb7b89646bd98fc5ab6617b370e",
  28. "deviceId": "test001",
  29. "productId": "1236859833832701952",
  30. "type": {
  31. "text": "上线",
  32. "value": "online"
  33. },
  34. "createTime": 1586413536000,
  35. "content": "设备上线"
  36. }, {
  37. "id": "2f1aaa63865afb3cdcec4aa72771ab9",
  38. "deviceId": "test001",
  39. "productId": "1236859833832701952",
  40. "type": {
  41. "text": "读取属性回复",
  42. "value": "readPropertyReply"
  43. },
  44. "createTime": 1583809148000,
  45. "content": "{\"temperature\":\"50\"}"
  46. }]
  47. },
  48. "status": 200,
  49. "code": "success"
  50. }

分页查询设备属性

请求方式: POST

URL: http(s)://localhost:8844/api/v1/{deviceId}/properties/_query

说明:{deviceId}需要替换为设备实例的id。

http body 请求参数:

公共查询参数:请参考公共查询参数

根据设备属性(DevicePropertiesEntity)条件查询,字段名和值分别对应查询参数Term中的column和value。
设备属性(DevicePropertiesEntity)参数如下:

名称类型是否必选示例值描述
idString属性ID
productIdString1236859833832701952型号ID
propertyStringtemperature属性标识
propertyNameString温度属性名称
stringValueString字符串值
formatValueString格式化值
numberValueString数字值
geoValueGeoPoint坐标值
timestamplong时间戳
objectValueString结构体值
valueString
timeValueDate时间值
orgIdString机构ID

GeoPoint参数如下:

名称类型是否必选示例值描述
latdouble106.57经度
londouble29.52纬度

返回参数:

名称类型描述
resultPagerResult<DevicePropertiesEntity>分页结果
statusint状态码
codeString业务编码

PagerResult参数如下:

名称类型描述
pageIndexint页码
pageSizeint每页数量
totalint返回数据总数
dataList<DevicePropertiesEntity>返回数据集合

DeviceInfo参数如下:

名称类型描述
idString属性ID
productIdString型号ID
propertyString属性标识
propertyNameString属性名称
stringValueString字符串值
formatValueString格式化值
numberValueString数字值
geoValueGeoPoint坐标值
timestamplong否 时间戳
objectValueString结构体值
valueString
timeValueDate时间值
orgIdString机构ID

请求示例
RequestUrl: http://localhost:8844/api/v1/device/test001/properties/\_query

RequestMethod: POST

RequestHeader: X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "pageSize": 25,
  3. "pageIndex": 0,
  4. "terms": [{
  5. "column": "property",
  6. "value": "temperature"
  7. }]
  8. }

HttpResponse:

  1. {
  2. "result": {
  3. "pageIndex": 0,
  4. "pageSize": 25,
  5. "total": 3,
  6. "data": [{
  7. "id": "amugXXEBQZKUd4flBbDN",
  8. "deviceId": "test001",
  9. "property": "temperature",
  10. "propertyName": "温度",
  11. "formatValue": "50.00℃",
  12. "numberValue": 50.0,
  13. "timestamp": 1583809148000,
  14. "value": "50",
  15. "productId": "1236859833832701952"
  16. }]
  17. },
  18. "status": 200,
  19. "code": "success"
  20. }

获取设备最新的全部属性

请求方式: GET

URL: http(s)://localhost:8844/api/v1/device/{deviceId}/properties/_latest

说明:{deviceId}需要替换为设备实例的id。

返回参数:

名称类型描述
resultDevicePropertiesEntity返回值
statusint状态码
codeString业务编码

DeviceDetail参数如下:

名称类型描述
idString
productIdString
propertyString
propertyNameString
stringValueString
formatValueString
numberValueString
geoValueGeoPoint
timestamplong
objectValueString
valueString
timeValueDate
orgIdString

请求示例:

RequestUrl: http(s)😕/localhost:8844/api/v1/device/test001/properties/_latest

RequestMethod: GET

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ

说明:

X-Sign为签名,param+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

HttpResponse:

  1. {
  2. "result": [{
  3. "id": "amugXXEBQZKUd4flBbDN",
  4. "deviceId": "test001",
  5. "property": "temperature",
  6. "propertyName": "温度",
  7. "formatValue": "50.00℃",
  8. "numberValue": 50.0,
  9. "timestamp": 1583809148000,
  10. "value": "50",
  11. "productId": "1236859833832701952"
  12. }],
  13. "status": 200,
  14. "code": "success"
  15. }

查询设备事件

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/{deviceId}/event/{eventId}/_query

说明:{deviceId}需要替换为设备实例的id,{eventId}需替换为设备型号中事件标识。

http body 请求参数:

公共查询参数:请参考公共查询参数

注意

此处的参数中Term为设备型号功能定义中的事件内容

返回参数:

名称类型描述
resultPagerResult<Map<String,Object>>分页结果
statusint状态码
codeString业务编码

PagerResult>参数如下:

名称类型描述
pageIndexint页码
pageSizeint每页数量
totalint返回数据总数
dataList<Map<String,Object>>返回数据集合

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/test001/event/fire\_alarm/\_query

RequestMethod: POST

RequestHeader:
X-Sign: fd9cf3f*************48f373d
X-Timestamp: 1586702227360
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "pageSize": 25,
  3. "pageIndex": 0,
  4. "terms": [{
  5. "column": "a_name",//型号事件定义中的结构体值属性
  6. "value": "未来科技城"
  7. }]
  8. }

HttpResponse:

  1. {
  2. "result": {
  3. "pageIndex": 0,
  4. "pageSize": 25,
  5. "total": 1,
  6. "data": [{
  7. "b_name": "C2 栋",
  8. "productId": "1236859833832701952",
  9. "pname": "智能温控",
  10. "event_count": 1,
  11. "l_name": "12-05-201",
  12. "alarm_describe": "火灾报警",
  13. "deviceId": "test001",
  14. "event_id": 1,
  15. "alarm_type": 1,
  16. "createTime": 1586701932647,
  17. "id": "Pn_ObnEBbNs2V4rRJb4F",
  18. "aid": 105,
  19. "a_name": "未来科技城",
  20. "timestamp": 1586701932647
  21. }]
  22. },
  23. "status": 200,
  24. "code": "success"
  25. }

设备操作API

获取设备属性

请求方式: GET

URL: `http(s)😕/localhost:8844/api/v1/device/{deviceId}/property/{propertyId}

说明:{deviceId}需要替换为设备实例的id,{propertyId}需要替换成属性标识。

返回参数:

名称类型描述
resultMap<String, Object>返回值
statusint状态码
codeString业务编码

请求示例:

RequestUrl: http://localhost:8844/api/v1/device/test001/property/temperature

RequestMethod: GET

RequestHeader:
X-Sign: f4823a*********e76eb1d
X-Timestamp: 1586511766004
X-Client-Id: kF**********HRZ

说明:

X-Sign为签名,param+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

HttpResponse:

  1. {
  2. "result": {
  3. "temperature": "50"
  4. },
  5. "status": 200,
  6. "code": "success"
  7. }

设置设备属性

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/{deviceId}/properties

说明:{deviceId}需要替换为设备实例的id。

http body 请求参数: 此处的参数为设备型号功能定义中的属性,如:

  1. {"temperature": 50.0}//temperature为属性标识

返回参数:

名称类型描述
resultMap<String, Object>返回数据
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/device/test001/properties

RequestMethod: POST

RequestHeader:
X-Sign: 7e5f****************087bc5
X-Timestamp: 1586694341284
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {"temperature": 50.0}

HttpResponse:

  1. {
  2. "result": {
  3. "temperature": "50"
  4. },
  5. "status": 200,
  6. "code": "success"
  7. }

设备功能调用

请求方式: POST

URL: http(s)://localhost:8844/api/v1/device/{deviceId}/function/{functionId}

说明:{deviceId}需要替换为设备实例的id,{functionId}需要替换为设备型号中功能定义的功能标识。

http body 请求参数: 此处的参数为设备型号功能定义中的功能定义内容,如:

  1. {"start_date": "2020-04-12"}

返回参数:

名称类型描述
resultMap<String, Object>返回数据
statusint状态码
codeString业务编码

请求示例
RequestUrl: http://localhost:8844/api/v1/device/test001/function/get-log

RequestMethod: POST

RequestHeader:
X-Sign: 8c5107***************eda4d
X-Timestamp: 1586704534250
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "start_date": "2020-04-12"
  3. }

HttpResponse:

  1. {
  2. "result": [{
  3. "start_date": "2020-04-12"
  4. }],
  5. "status": 200,
  6. "code": "success"
  7. }

地理信息管理

根据geojson保存数据

请求方式: POST

URL: http(s)://localhost:8844/api/v1/geo/object/geo.json

http body 请求参数:

GeoJson(参考GeoJSONAPI列表 - 图1) 参数如下:

名称类型是否必选示例值描述
typeStringFeatureCollection类型,固定为FeatureCollection
featuresList<GeoJsonFeature>geo集合

GeoJsonFeature 参数如下:

名称类型是否必选示例值描述
typeStringFeature类型,固定为Feature
propertiesMap<String,Object>拓展属性
geometryGeoShape图形

properties 参数如下:

名称类型是否必选示例值描述
objectIdStringchongqing
idStringchongqing
objectTypeStringcity

GeoShape 参数如下:

名称类型是否必选示例值描述
typeTypePolygon类型
coordinatesList<Object>坐标集合

返回参数:

名称类型描述
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/geo/object/geo.json

RequestMethod: POST

RequestHeader:
X-Sign: 7d825f4************5724949
X-Timestamp: 1587460645733
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. {
  2. "type": "FeatureCollection",
  3. "features": [{
  4. "type": "Feature",
  5. "properties": {//拓展属性
  6. //必须的配置
  7. "id": "500242",
  8. "objectId": "youyang",
  9. "objectType": "city",
  10. //其他配置,将设置到 GeoObject.tags中,在查询时可通过filter进行搜索
  11. "name": "酉阳土家族苗族自治县",
  12. "group": "china"
  13. },
  14. "geometry": {
  15. "type": "Polygon",
  16. "coordinates": [//坐标列表
  17. [
  18. [108.3142, 28.9984],
  19. [108.3252, 29.0039],
  20. [108.3252, 28.96],
  21. [108.3142, 28.9984]
  22. ]
  23. ]
  24. }
  25. }]
  26. }

注意:

可使用 http://geojson.io/#map=4/32.18/105.38API列表 - 图2 生成json

HttpResponse:

  1. {"status":200,"code":"success"}

查询geo对象

请求方式: POST

URL: http(s)://localhost:8844/api/v1/geo/object/_search

http body 请求参数:

名称类型是否必选示例值描述
shapeObject图形,如重庆市行政区域边界(扩展属性objectId为该边界的标识)
filterQueryParamEntity可根据GeoObject.tags中的属性进行查询

返回参数:

名称类型描述
resultGeoObject返回数据
statusint状态码
codeString业务编码

GeoObject 参数如下:

名称类型描述
idString唯一标识
objectTypeString类型
shapeTypeString图形类型
objectIdString图形唯一标识
propertyString属性标识
pointGeoPoint坐标
shapeGeoShape图形
tagsString拓展信息
timestamplong时间戳: 数据更新的时间

GeoPoint 参数如下:

名称类型描述
londouble经度
latdouble纬度

GeoShape 参数如下:

名称类型是否必选示例值描述
typeTypePolygon类型
coordinatesList<Object>坐标集合度

请求示例:
RequestUrl: http://localhost:8844/api/v1/geo/object/\_search

RequestMethod: POST

RequestHeader:
X-Sign: 7d825f4************5724949
X-Timestamp: 1587460645733
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:

  1. 使用shape中的objectId查询:

    1. {
    2. "shape":{
    3. "objectId":"youyang" //查询objectId为youyang的所有geo信息
    4. },
    5. "filter":{
    6. }
    7. }

    注意:

    objectId为平台对geojson进行拓展的属性,为geo对象的唯一标识,如:设备id,区域id等。
    当物模型里面配置了地理位置,objectId则为该设备id,可通过objectId查询该设备的地理位置信息。

  2. 使用shape的多边形的坐标集进行查询

    1. {
    2. "shape": {
    3. "type": "Polygon",//请参考Type
    4. "coordinates": [
    5. [
    6. [108.3142, 28.9984],
    7. [108.3252, 29.0039],
    8. [108.3252, 28.96],
    9. [108.3142, 28.9984]
    10. ]
    11. ]
    12. },
    13. "filter": {
    14. }
    15. }

    注意:

    shape中的type请参考Type

  3. filter的使用

    1. {
    2. "shape": {
    3. "objectId": "youyang"
    4. },
    5. "filter": {
    6. "where": "tags.name=酉阳土家族苗族自治县 and tags.group=china"
    7. }
    8. }

    注意:

    filter查询的条件来自于根据geojson保存数据接口提交的数据中properties中设置到GeoObject.tags的属性,如:name、group;
    filter可以单独进行查询,不需要传入shape

HttpResponse:

  1. {
  2. "result": [{
  3. "id": "youyang",
  4. "objectType": "city",
  5. "shapeType": "Polygon",
  6. "objectId": "youyang",
  7. "shape": {
  8. "type": "Polygon",
  9. "coordinates": [
  10. [
  11. [108.3142, 28.9984],
  12. [108.3252, 29.0039],
  13. [108.3252, 28.96],
  14. [108.3142, 28.9984]
  15. ]
  16. ]
  17. },
  18. "tags": {
  19. "name": "酉阳土家族苗族自治县",
  20. "group": "china"
  21. },
  22. "timestamp": 0
  23. }],
  24. "status": 200,
  25. "code": "success"
  26. }

查询geo对象并转为geoJson

请求方式: POST

URL: http(s)://localhost:8844/api/v1/geo/object/_search/geo.json

http body 请求参数:

名称类型是否必选示例值描述
shapeObject图形,如重庆市行政区域边界(扩展属性objectId为该边界的标识)
filterQueryParamEntity可根据GeoObject.tags中的属性进行查询

返回参数:

名称类型描述
resultGeoJson返回数据,请参考GeoJson标准
statusint状态码
codeString业务编码

请求示例:
RequestUrl: http://localhost:8844/api/v1/geo/object/\_search

RequestMethod: POST

RequestHeader:
X-Sign: f9f297a****************acf288a
X-Timestamp: 1587542185752
X-Client-Id: kF**********HRZ
Content-Type: application/json

说明:

X-Sign为签名,body+X-Timestamp+SecuryeKeyMD5加密
X-Timestamp为时间戳
X-Client-Id为平台openApi客户端id

RequestBody:
查询参数请参考查询geo对象接口

  1. {
  2. "shape":{
  3. "objectId":"youyang" //查询objectId为youyang geo对象内的所有geo信息
  4. },
  5. "filter":{
  6. }
  7. }

HttpResponse:

  1. {
  2. "result": {
  3. "type": "FeatureCollection",
  4. "features": [{
  5. "type": "Feature",
  6. "properties": {
  7. "name": "酉阳土家族苗族自治县",
  8. "id": "youyang",
  9. "objectId": "youyang",
  10. "group": "china",
  11. "objectType": "city"
  12. },
  13. "geometry": {
  14. "type": "Polygon",
  15. "coordinates": [
  16. [
  17. [108.3142, 28.9984],
  18. [108.3252, 29.0039],
  19. [108.3252, 28.96],
  20. [108.3142, 28.9984]
  21. ]
  22. ]
  23. }
  24. }]
  25. },
  26. "status": 200,
  27. "code": "success"
  28. }