URI
<layer_uri>/query[.<format>]
支持的方法
父资源
介绍
查询指定图层中包含的要素信息 。该查询操作是在要素服务的图层资源上进行的。此操作的结果是要素集或要素 ID 数组(如果 returnIdsOnly 设置为 true)和/或 结果范围(如果 returnExtentOnly 设置为 true)。
支持的方法:
资源层次
HTTP 请求方法
对如下 URI 执行 HTTP 请求,以 json 输出格式为例加以说明,其中,supermapiserver 是服务器名,{component}是服务组件名,{datasourceName}是数据源名,{layerID} 是图层 ID 号。
http://supermapiserver:8090/iserver/services/{component}/arcgisrest/{datasourceName}/FeatureServer/{layerID}/query.json
GET 请求
请求参数
名称 | 类型 | 含义 |
f | String | 响应格式,支持 json、pjson |
where | String |
查询过滤器的 WHERE 子句。如: where=CITY_NAME = 'Barrington'。 |
objectIds | int |
要查询的层的对象ID。如: objectIds=37, 462 |
geometry | String |
用作空间过滤器的几何对象。几何的结构与 ArcGIS REST API 返回的 JSON 几何对象的结构相同。除了 JSON 结构外,对于 envelope 和 point,还可以使用逗号分隔语法来指定几何对象。如: geometry={xmin: -112, ymin: 32.6, xmax: -91.11, ymax: 41}
geometry=-112,32.6,-91.11,41
geometry=-112,32.6 |
geometryType | ArcGISGeometryType | 由 geometry 参数指定的几何类型。几何类型可以是esriGeometryPoint 、esriGeometryMultipoint 、esriGeometryPolyline、 esriGeometryPolygon、esriGeometryEnvelope。默认几何类型是 esriGeometryEnvelope。 |
inSR | String | 输入几何对象的空间参考。 |
spatialRel | String |
执行查询时要应用于输入几何对象的空间关系。支持的空间关系包括 esriSpatialRelIntersects、esriSpatialRelContains、esriSpatialRelCrosses、esriSpatialRelEnvelopeIntersects、esriSpatialRelIndexIntersects、esriSpatialRelOverlaps、esriSpatialRelTouches、esriSpatialRelWithin、esriSpatialRelRelation。默认的空间关系是 esriSpatialRelIntersects。 |
outSR | String | 返回的几何对象的坐标参考系统。 |
outFields | String |
要包含在返回结果集中的字段列表。此列表中的字段名称用逗号分隔。 如: outFields=AREANAME,AREA,POP2000 |
returnGeometry | boolean | 如果为true,则返回结果将包括每个与结果关联的几何对象。默认值为true |
returnIdsOnly | boolean | 如果为true,则返回结果仅包含对象 ID 的数组。否则,响应结果是要素集。默认值为 false。 |
returnCountOnly | boolean | 如果为true,则返回结果仅包括查询到的要素数或记录数。否则,响应是要素集。默认值为false。此选项取代 returnIdsOnly 参数,如果 returnCountOnly = true,则响应将同时返回计数和范围。 |
returnExtentOnly | boolean |
如果为true,则返回结果仅包括查询到的要素的范围。如果 returnCountOnly = true,则将同时返回计数和范围。默认值为false。 |
orderByFields | String | 用于要素/记录排序的一个或多个字段名/表达式。如:
orderByFields=HELLO, NEW, WORLD orderByFields=POPULATION / SHAPE_AREA |
resultOffset | int | 用于跳过指定数量的记录并从下一条记录(即 resultOffset + 1)开始获取查询结果。当supportsPagination为true时,此参数适用。默认值为 0。 |
resultRecordCount | int | 用于定义查询结果中期望返回的结果记录数,该值大于0。当supportsPagination为true时,此参数适用。默认值为最大查询结果记录数(maxRecordCount)。 |
groupByFieldsForStatistics | String | 需要对值进行分组以计算统计信息的一个或多个字段名称。仅当使用 groupByFieldsForStatistics 时 outStatistics 有效。如: groupByFieldsForStatistics=STATE_NAME, GENDER |
outStatistics | String | 要计算的一个或多个基于字段的统计信息的定义。如:
[ { "statisticType": "avg", "onStatisticField": "AREA", "outStatisticFieldName": "AverageArea" }, { "statisticType": "avg", "onStatisticField": "INCOME", "outStatisticFieldName": "AverageIncome" } ] |
响应结构
对 query 资源执行 GET 请求得到的是指定图层的要素信息,集合中的每一个元素的结构如下:
字段 | 类型 | 说明 |
id | int | 图层id |
objectIdFieldName | String | 图层objectId的字段名 |
globalFieldName | String | 图层globaId的字段名 |
geometryType | ArcGISGeometryType | 几何对象类型 |
spatialReference | ArcGISSpatialReference | 空间参考系 |
hasZ | boolean | 是否包含Z值 |
hasM | boolean | 是否包含M值 |
fields | ArcGISFieldInfo[] | 要素字段信息集合 |
features | Feature[] | 要素集合 |
响应示例
对 query 资源:http://localhost:8090/iserver/services/data-BeijingAddress/arcgisrest/BeijingAddress/FeatureServer/0/query?where=SMID > 0 AND SMID <= 1&outFields=*&returnGeometry=true&returnIdsOnly=false&f=pjson 执行 GET 请求,返回 pjson 格式的资源表述如下:
{
"hasZ": false,
"features": [{
"attributes": {
"序号": 100,
"一级分类": "企业",
"法人代码": "10110166-0",
"名称": "京东方科技集团股份有限公司",
"SMLIBTILEID": "1",
"二级分类": "电子与信息",
"区县": "朝阳区",
"NAME": "京东方科技集团股份有限公司",
"SMID": "1",
"CITY": "北京市",
"园区名称": "电子城",
"ADDRESS": "北京市朝阳区酒仙桥路10号",
"SMGEOPOSITION": "269740",
"地址": "北京市朝阳区酒仙桥路10号",
"ID": 1240,
"SMGEOMETRYSIZE": "20",
"SMY": "4862514.842817815",
"城市": "北京市",
"SMX": "1.2967731461281551E7",
"SMUSERID": "0",
"COUNTY": "朝阳区"
},
"geometry": {
"x": 1.2967731461281551E7,
"y": 4862514.842817815,
"spatialReference": null
}
}],
"hasM": false,
"globalFieldName": null,
"objectIdFieldName": null,
"id": 0,
"spatialReference": {"wkt": "PCS_NON_EARTH"},
"fields": [
{
"nullable": true,
"editable": false,
"name": "SmID",
"alias": "SmID",
"type": "esriFieldTypeOID"
},
{
"nullable": true,
"editable": false,
"name": "SmX",
"alias": "SmX",
"type": "esriFieldTypeDouble"
},
{
"nullable": true,
"editable": false,
"name": "SmY",
"alias": "SmY",
"type": "esriFieldTypeDouble"
},
{
"nullable": true,
"editable": false,
"name": "SmLibTileID",
"alias": "SmLibTileID",
"type": "esriFieldTypeInteger"
},
{
"nullable": true,
"editable": true,
"name": "SmUserID",
"alias": "SmUserID",
"type": "esriFieldTypeInteger"
},
{
"nullable": true,
"editable": false,
"name": "SmGeometrySize",
"alias": "SmGeometrySize",
"type": "esriFieldTypeInteger"
},
{
"nullable": true,
"editable": false,
"name": "SmGeoPosition",
"alias": "SmGeoPosition",
"type": "esriFieldTypeInteger"
},
{
"nullable": true,
"editable": true,
"name": "ID",
"alias": "ID",
"type": "esriFieldTypeDouble"
},
{
"nullable": true,
"editable": true,
"name": "序号",
"alias": "序号",
"type": "esriFieldTypeDouble"
},
{
"nullable": true,
"editable": true,
"name": "法人代码",
"alias": "法人代码",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "园区名称",
"alias": "园区名称",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "一级分类",
"alias": "一级分类",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "二级分类",
"alias": "二级分类",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "区县",
"alias": "区县",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "名称",
"alias": "名称",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "地址",
"alias": "地址",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "城市",
"alias": "城市",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "city",
"alias": "city",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "county",
"alias": "county",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "ADDRESS",
"alias": "ADDRESS",
"type": "esriFieldTypeString"
},
{
"nullable": true,
"editable": true,
"name": "NAME",
"alias": "NAME",
"type": "esriFieldTypeString"
}
],
"geometryType": "esriGeometryPoint"
}
POST 请求
跟 GET 请求结构类似。
HEAD 请求
返回跟 GET 请求一样的 HTTP 响应头,但是没有响应实体。可以在不必传输整个响应内容的情况下,获取包含在响应消息头中的元数据信息。元数据信息包括媒体类型,字符编码,压缩编码,实体内容长度等。
HEAD 请求可以用来判断 query 资源是否存在,或者客户端是否有权限访问 query 资源。通过对加.<format>的 URI 执行 HEAD 请求,还可以快速判断 query 资源是否支持<format>格式的表述。
请参见