# 矢量数据集

# 获取矢量数据集列表

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/list

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符,如为 * 则表示不过滤帐户

# 请求参数:

参数名称 类型 是否必须 默认值 说明
search String - 搜索的文本
offset Number 0 返回结果的偏移量,用于分页
limit Number 11 返回结果的数量,用于分页
sortField String createdAt 用于排序的字段
sortType String desc 排序的类型

# 请求示例

GET http://host:port/heycloud/api/data/vdataset/list?search=&offset=0&limit=11

# 正确响应示例:

{
  "result": [
    {
      "id": "e0e3b36d-bbc5-49ec-8a6f-0b7e150d8787",
      "accountId": "",
      "title": "六出祁山8",
      "count": "7",
      "createdAt": "2021-05-14T08:09:18.624Z"
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 获取 vdataset 的元数据

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/meta

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID

# 请求示例

GET http://host:port/heycloud/api/data/vdataset/xxxxx/meta

# 正确响应示例:

{
  "result": {
    "id": "e0e3b36d-bbc5-49ec-8a6f-0b7e150d8787",
    "accountId": "",
    "title": "schools",
    "count": "7",
    "createdAt": "2021-05-14T08:09:18.624Z",
    "idField": "_id",
    "attrFields": [
      { "name": "name", "type": "text" },
      { "name": "lon", "type": "float8" },
      { "name": "lat", "type": "float8" }
    ],
    "geomFields": [
      { "name": "_geom", "type": "geometry" },
      { "name": "_geom_wm", "type": "geometry" }
    ],
    "indexes": []
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件查询记录

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/query

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
vdatasetId - String - 数据集 ID
where - String - 查询的条件,SQL 格式,注意非小写字段名需要以双引号包围
geomField - String - 查询的几何字段
geom - Object - 查询的几何对象,GeoJSON 格式
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略
sortField - String createdAt 排序的字段
sortType desc/asc String desc 排序的类型
offset - Number 0 返回结果的偏移量,用于分页
limit - Number 11 返回结果的数量,用于分页,如小于等于零则表明不作限制,此时需注意数据集大小是否会引起性能问题
returnAttrFields - Array [] 返回的属性字段
returnGeomFields - Array [] 返回的几何字段
toWebMercator - Boolean false 返回转换到 Web Mercator 的几何字段,此时不需要指定 returnGeomFields

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/query

{
  "where": "gdp>10",
  "geomField": "_geom",
  "geom": { type: 'Point', coordinates: [0, 0] },
  "search": "北",
  "searchFields": ["name"],
  "sortField": "gdp",
  "sortType": "asc",
  "offset": 0,
  "limit": 11,
  "returnAttrFields": ["gdp", "city"],
  "toWebMercator": true
}

# 正确响应示例:

{
  "result": [
    {
      "_id": "9a9fa3ea-92e1-4392-9534-4919e17c6cc1",
      "gdp": 24536,
      "city": "153",
      "_geom": { "type": "Polygon", "coordinates": [] }
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 分组聚合统计

请注意在大数据集上通过查询条件过滤不需要的数据,以免引起性能问题

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/group

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
vdatasetId - String - 数据集 ID
groupByFields - Array - 用于分组的字段列表,至少包含一个字段
groupField - String - 需要聚合的字段,如聚合方法为 count 可不指定聚合字段
groupMethod sum/mean/median/mode/min/max/std/count String sum 聚合的方法
where - String - 查询的条件,SQL 格式,注意非小写字段名需要以双引号包围
geomField - String - 查询的几何字段
geom - Object - 查询的几何对象,GeoJSON 格式
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/group

{
  "groupByFields": ["name"],
  "groupField": "gdp",
  "groupMethod": "sum",
  "where": "gdp>10",
  "geomField": "_geom",
  "geom": { type: 'Point', coordinates: [0, 0] },
  "search": "北",
  "searchFields": ["name"]
}

# 正确响应示例:

{
  "result": [
    {
      "gdp_sum": 104588,
      "name": "北京"
    }
  ]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据查询条件获取结果总数

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/count

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 可选值 类型 是否必须 默认值 说明
vdatasetId - String - 数据集 ID
where - String - 查询的条件,SQL 格式,注意非小写字段名需要以双引号包围
geomField - String - 查询的几何字段
geom - Object - 查询的几何对象,GeoJSON 格式
search - String - 搜索的文本,同时可以设置 searchFields 参数,如不设置则搜索所有创建索引的文本字段
searchFields - Array - 进行文本搜索的字段,搜索字段必须是文本类型并创建了索引,未创建索引的字段会被忽略

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/count

{
  "where": "\"ID\">10",
  "geomField": "_geom",
  "geom": { type: 'Point', coordinates: [0, 0] },
  "search": "北",
  "searchFields": ["name"]
}

# 正确响应示例:

{
  "result": 132
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据唯一条件查询一条记录,通常用于根据 ID 直接获取对象

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/get

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
returnAttrFields Array [] 返回的属性字段
returnGeomFields Array [] 返回的几何字段
toWebMercator Boolean false 返回转换到 Web Mercator 的几何字段,此时不需要指定 returnGeomFields

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/get

{
  "findField": "id",
  "findValue": 24536,
  "returnFields": ["city"],
  "toWebMercator": true
}

# 正确响应示例:

{
  "result": {
    "id": 24536,
    "city": "153",
    "_geom": ...
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件删除记录,通常用于根据 ID 直接删除对象,注意对于某些条件有可能存在多条记录匹配

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/delete

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
returnAttrFields Array [] 返回的属性字段
returnGeomFields Array [] 返回的几何字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxxx/delete

{
  "findField": "id",
  "findValue": 24536
  "returnAttrFields": ["city"],
  "returnGeomFields": ["_geom"]
}

# 正确响应示例:

{
  "result": [{
    "id": 24536,
    "city": "153",
    "_geom": ...
  }]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 插入一条记录

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/insert

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
attrs Object - 属性字段值
geoms Object - 几何字段值

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/insert

{
  "attrs": {"id": 1, "createdAt": {"$exp" : "now()"}},
  "geoms": {"_geom": {...}}
}

# 正确响应示例:

{
  "result": {
    "id": 1,
    "createdAt": "xxxxx"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 根据条件更新记录,注意对于某些条件有可能存在多条记录匹配

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/update

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
findField String - 查询的字段
findValue String - 查询的值
attrs Object - 更新的数据
geoms Object - 几何字段值

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/update

{
  "findField": "id",
  "findValue": 1,
  "attrs": {"createdAt": {"$exp" : "now()"}},
  "geoms": {"_geom": {...}}
}

# 正确响应示例:

{
  "result": {
    "id": 1,
    "createdAt": "xxxxx",
    "_geom": ...
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 更新标题

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/updateTitle

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
title String - 更新的标题

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/updateTitle

{
  title: "xxx"
}

# 正确响应示例:

{
  "result": {
    "title": "..."
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 重命名一个字段的名称

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/renameField

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
field String - 旧的的字段名
newName String - 更新的字段名

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/renameField

{
  field: "x",
  newName: "lon"
}

# 正确响应示例:

{
  "result": {
    "x": "lon"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 创建索引

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/createIndex

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
field String - 需要创建索引的字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/createIndex

{
  field: "name",
}

# 正确响应示例:

{
  "result": {
    "vdatasetId": "xxxxx",
    "field": "name",
    "notifyAt": "2021-05-14T08:09:18.624Z"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 删除索引

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/dropIndex

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
field String - 需要删除索引的字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/dropIndex

{
  field: "name",
}

# 正确响应示例:

{
  "result": {
    "vdatasetId": "xxxxx",
    "field": "name",
    "notifyAt": "2021-05-14T08:09:18.624Z"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 更新数据范围

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/updateExtent

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/xxxxx/updateExtent

# 正确响应示例:

{
  "result": {
    "vdatasetId": "xxxxx",
    "notifyAt": "2021-05-14T08:09:18.624Z"
  }
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 等间隔分段法

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/equal-interval

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
breakCount Number 4 分段的数量
where String - 查询的条件
limit Number 100 计算使用的记录数量,如为 <=0 的值则对数量不作限制
field String - 用于分段的字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/equal-interval

{
  "field": "id",
  "breakCount": 8,
  "where": "count>10"
}

# 正确响应示例:

{
  "result": [0, 10, ..., 80]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 分位数分段法

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/equal-count

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
breakCount Number 4 分段的数量
where String - 查询的条件
limit Number 100 计算使用的记录数量,如为 <=0 的值则对数量不作限制
field String - 用于分段的字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/equal-count

{
  "field": "id",
  "breakCount": 8,
  "where": "count>10"
}

# 正确响应示例:

{
  "result": [0, 10, ..., 80]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 自然分段法

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/natural

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
breakCount Number 4 分段的数量
where String - 查询的条件
limit Number 100 计算使用的记录数量,如为 <=0 的值则对数量不作限制
field String - 用于分段的字段

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/:vdatasetId/breaks/natural

{
  "field": "id",
  "breakCount": 8,
  "where": "count>10"
}

# 正确响应示例:

{
  "result": [0, 10, ..., 80]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 列举字段的不同值

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/stats/distinct

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
field String - 用于计算的字段
where String - 查询的条件
limit Number 100 计算使用的记录数量,如为 <=0 的值则对数量不作限制

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/:vdatasetId/stats/distinct

{
  "field": "pop",
  "where": "pop>0"
}

# 正确响应示例:

{
  "result": [1.2, 2.4, 7.2]
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# 对字段进行聚合计算

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/stats/aggregation

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

属性名称 类型 是否必须 默认值 说明
vdatasetId String - 数据集 ID
field String - 用于计算的字段 ,如聚合方法为 count 可不指定聚合字段
where String - 查询的条件
geomField String - 查询的几何字段
geom Object - 查询的几何对象,GeoJSON 格式
method String mean 统计的方法,取值可以为 sum/mean/median/mode/min/max/std/count

# 请求示例

POST http://host:port/heycloud/api/data/vdataset/:vdatasetId/stats/aggregation

{
  "field": "pop",
  "where": "pop>0",
  "method": "sum"
}

# 正确响应示例:

{
  "result": 10.8
}

# 错误响应示例:

{
  "error": "ERROR",
  "message": "错误信息"
}

# WFS 接口

# 请求 URL:

  • http://host:port/heycloud/api/data/vdataset/:vdatasetId/wfs

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

# Params:
字段 类型 说明
vdatasetId String 矢量数据集的唯一标识
# Query:
字段 类型 说明
request String 操作,可选 GetCapabilities/DescribeFeatureType/GetFeature
featureId String 通过 ID 查询对象
bbox String 通过矩形查询对象,注意 WFS 的 bbox 顺序为 ymin,xmin,ymax,xmax
propertyName String 逗号分隔的返回字段列表,不设置返回所有字段
sortBy String 排序,如 id+A
count Number 限制返回数量

# 请求示例:

GET http://host:port/heycloud/api/data/vdataset/:vdatasetId/wfs?request=GetFeature&count=1000