queryResults


URI

<map_uri>/queryresults[.<format>]

Supported methods

GET, POST, HEAD

Parent resource

ERROR: Variable (map_link) is undefined.

Child resources

queryResult

Introduction

The queryResults resource represents a set of query results. It can be used to perform SQL query, distance query, spatial query, closest feature query, bounds query and nautical chart query on map ({mapName}).

For usage example for this resource, please refer to SQL Query, LInkItem SQL Query, Distance Query.

Supported Methods:

Supported output formats: rjson, json, html, xml.

Resource hierarchy

根资源 maps 资源 map 资源 queryResults 资源

HTTP request methods

Implement the HTTP request on the following URI, with rjson as the output format. In the URI, supermapiserver is the server name, WorldMap is the map name ({mapName}), and URI is a query collection for WorldMap.

http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/queryResults.rjson

GET request

Gets the query result collection, that is, the representation collection of the established queryResutl resources.

Request parameter

Name Type Description
_cache boolean [Optional parameter]
Whether to use cache, the default is True. False means close all the caches.

Response structure

If you implement the GET request on the queryResults resource, the information collection of the queryResult resources will be returned. The structure of each element in the collection is as follows:

Field Type Description
name String The name of the queryResult resource.
path String The access path of the queryResult resource.
resourceConfigID String The configuration item ID of the resource.
resourceType String The resource type.
supportedMediaTypes String[] The media-type of the representation supported by the datasource resource.

 

Example usage

After a successful query (or implementation of POST request on the queryResults resource), there will be query result information in the queryResults resource. If you implement the GET request on the queryResults resource, the response in rjson format will be as follows:

[{

    "name": "1",

    "path": "http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/queryResults/1.rjson",

    "resourceConfigID": null,

    "resourceType": "ArithResultResource",

    "supportedMediaTypes": [

        "application/xml",

        "text/xml",

        "application/json",

        "application/rjson",

        "text/html"

    ]

}]

POST request

Creates a queryResult resource based on the given parameters.

Request parameter

By implementing the POST request on the queryResults resource, users can perform SQL query, distance query, spatial query, closest feature query, bounds query, etc. The query mode is determined by the queryMode parameter. Parameters vary for different query modes. Parameters in the URI are optional.

Parameters in the URI:

Name Type Description
returnContent boolean Whether to return the representation of the newly established resource or the URI of the resource.
If true, the representation of the new resource will be returned. If false, the URI of the query result will be returned. The default is false.
returnCustomResult boolean Whether to return the bounds information of the query result. Valid when returnContent is false.
If true, the bounds information will be returned (the customResult field in the response).
If false, the bounds information will not be returned. The default is false.

While performing the POST request on queryResults, representation of the queryResult resource will be acquired if returnContent is true; URI of the queryResult resource will be acquired if returnContent is false, and needed result will be got if performing the GET operation on the result resource.

The parameters in request body are as follows:

Name Type Description

queryMode

QueryMode [Required parameter]
Query modes include SQL query, distance query, spatial query, closest facility finding, bounds query, chart query, etc.
  1. If perform query on 3D point, line, region dataset, the query modes supported are SQL query and bounds query.
  2. For CAD layers, only SQL query and bounds query are currently supported.
  3. For nautical charts, only chart attribute query and chart bounds query are currently supported. Please refer to Nautical Chart Query Parameters.
  4. EPS data currently only supports SQL query and Bounds query.
  5. When the query mode is the nearest geometries search, the queried results will be sorted in ascending order according to the distance.
queryParameters QueryParameterSet

[Required parameter]

The query parameters set. Include queryParams, expectCount, startRecord, queryOption, etc.

Among the arraies, queryParams includes the name of the dataset or layer to query, query field array (fields), SQL query attribute filter (attributeFilter), groupBy, query ID array (ids), joinItems, linkItems, orderBy, etc.

Note:
  • If the the query condition is distance query, bounds query and nearest feature query, only attributeFilter is supported. Not supported for other query conditions such as groupBy, orderBy, joinItems, linkItems.
  • If the query condition is closest facility finding, startRecord is not supported.
  • When set the linkItems parameter, if the field in the linkItem does not exist, there might be no query result.
  • Spatial query does not support the GroupBy field. Setting this property may lead to errors.
  • For the SQL query, if you set the masked string in the SQL expression (see iServer Configuration File Instruction), once attributeFilter detects this string, then the system will consider this query expression is illegal and return a 400 exception to prevent the injection of SQL. If no masked string is set in the SQL expression, then attributeFilter will screen out the semicolon by default.
  • For the distance query, if the number of records of query result is greater than the expected number (expectCount), the result of the distance query has expectCount features which are extracted randomly from the total query records.
  • For the "finding the most nearest feature" query, if the number of records of query result is greater than the expected number (expectCount), the query result has expectCount features nearest the center point, which are extracted from the total query records.
geometry Geometry Required if queryMode is distance query or spatial query.
The spatial object information. The projected coordinate system of geometry is identical to the map coordinate system.
bounds Rectangle2D Required when queryMode is bounds query.
Queries records that fall in the specified bounds in the specified layer. The projected coordinate system of bounds is identical to the map coordinate system.
spatialQueryMode SpatialQueryMode Required if queryMode is spatial query.
The operation mode of the spatial query .
The spatial query modes include contain, cross, disjoint, identity, intersect, overlap, touch, within, etc.
distance double Required if queryMode is closest feature query. The unit of distance is identical to that of the map coordinates.
It is the distance to the feature when performing distance query. The distance tolerance when finding the closest feature.

Table Chart query parameters

Name Type Description
queryMode QueryMode Chart query has two modes: ChartAttributeQuery and ChartBoundsQuery.
chartLayerNames String The name of the layer to be queried.
chartQueryParameters ChartQueryParameterSet Chart Query Parameter set (array).
bounds Rectangle2D The specified query extent, which is required when the query mode is ChartBoundsQuery.

 

Response structure

Perform a POST request on a queryResults to query and then create the query result resource.

Return the representation of the operation result when returnContent=false as follows:

Field Type Description
succeed boolean Whether the query is successful.
newResourceID String The ID for the query result resource.
postResultType postResultType

The POST request result types.

Describes the influence of the POST request on the target resource, namely, what the handling result is like.

newResourceLocation String The URI of the newly created resource.
customResult Object Return the Bounds information of the query result.
If the map is set up with the dynamic projection, the projection coordinate system of Bounds returned from QueryResult is identical to that of map.
If the map is not set up with the dynamic projection, the projection coordinate system of Bounds returned from QueryResult is identical to that of dataset where the query results exist.

If returnContent is true, the newResourceLocation field will be absent in the representation returned, replaced by the queryResult resource identified by newResourceLocation. Please see the representation structure of the queryResult resource.

Note: The field information of the query recordset is recorded via the fields field of Recordset. The value of the fieldNames field for each Feature is null.

Example 1: SQL Query

Implement the POST request on the queryResults resource with http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/queryResults.rjson?returnCustomResult=true to perform SQL query on WorldMap.

{

    "queryMode": "SqlQuery",

    "bounds": {

        "leftBottom": {

            "x": 0,

            "y": 0

        },

        "rightTop": {

            "x": 100,

            "y": 100

        }

    },

    "distance": 1,

    "queryParameters": {

        "queryParams": [{

            "attributeFilter": "SMID %26gt; 0",

            "name": "ContinentLabel@World"

        }],

        "startRecord": 0,

        "expectCount": 20,

        "networkType": "LINE",

        "queryOption": "ATTRIBUTEANDGEOMETRY"

    },

    "spatialQueryMode": "INTERSECT"

}

The returned resource description in rjson format is shown below:

{

    "succeed": true,

    "newResourceID": "iypwfdzf_91c24c622e9641e18a808ae8a89f698b",

    "postResultType": "CreateChild",

    "customResult": {

        "rightTop": {

            "y": 55.98430295074347,

            "x": 140.7362260537166

        },

        "leftBottom": {

            "y": -82.49592439558907,

            "x": -119.53556537446983

        },

        "bottom": -82.49592439558907,

        "left": -119.53556537446983,

        "right": 140.7362260537166,

        "top": 55.98430295074347

    },

    "newResourceLocation": "http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/queryResults/iypwfdzf_91c24c622e9641e18a808ae8a89f698b.json"

}

To get the query result, implement the GET request on http://supermapiserver:8090/iserver/services/map-world/rest/maps/WorldMap/queryResults/1.rjson Please seethe GET request of queryResult.

Example 2: Perform Bounds Query on CAD Layer

Request body example:

{

    "queryMode": "BoundsQuery",

    "bounds": {

        "leftBottom": {

            "x": 112.35,

            "y": 34.6

        },

        "rightTop": {

            "x": 112.4,

            "y": 34.62

        }

    },

    "distance": 1,

    "queryParameters": {

        "queryParams": [{

            "attributeFilter": "SMID > 0",

            "name": "testCAD@test1"

        }],

        "startRecord": 0,

        "expectCount": 20,

        "networkType": "LINE",

        "queryOption": "ATTRIBUTEANDGEOMETRY"

    },

    "keywords": "",

    "spatialQueryMode": "INTERSECT"

}

Response result example:

{

    "customResult": {

        "bottom": 34.54666099978054,

        "left": 112.26249133678498,

        "leftBottom": {

            "x": 112.26249133678498,

            "y": 34.54666099978054

        },

        "right": 112.48668999981291,

        "rightTop": {

            "x": 112.48668999981291,

            "y": 34.72305325426654

        },

        "top": 34.72305325426654

    },

    "newResourceID": "62599fc42ee044c7acea57b5e8d9bc87_9bfbea897ac3473fa75728ed0880f8fb",

    "newResourceLocation": "http://server:8090/iserver/services/map-henan/rest/maps/luoyang/queryResults/62599fc42ee044c7acea57b5e8d9bc87_9bfbea897ac3473fa75728ed0880f8fb.rjson",

    "postResultType": "CreateChild",

    "succeed": true

}

HEAD request

Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. The meta-information includes the media-type, content-encoding, transfer-encoding, content-length, etc.

The HEAD request helps check the existence of the queryResults resource and whether it can be accessed by the client. By implementing the HEAD request on the URI, with .<format> appended to the end, we can quickly get to know whether the layer resource supports the representation in <format> or not.

See