query


URI

<spatialanalystJobs_uri>/query[.<format>]

Supported methods

GET, POST, HEAD

Parent resource

spatialanalystJobs

Child resources

queryJob

Introduction

The resource root directory of single object query. Gets the list of the single object query job of current system through sending GET request to query . Through the POST request, you can create a analysis task.

The root directory of the single object query job resource. By sending a GET request to query, you can get the list of the single object query jobs of the current system. By sending a POST request, you can create a query task.

Supported Methods:

Supported output formats: RJSON, JSON, HTML, XML.

Resource hierarchy

 

HTTP request methods

Execute HTTP request on the following URI, here we take rjosn as the output format as an example. Where, supermapiserver is the server name.

http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query.rjson

GET request

Gets the job list of single object query jobs.

Response structure

After executing a GET request on the resource, the response entity is a set of single object query resource descriptions, and the response fields of single resource are as follows:

Field Type Description
id String Application ID.
state Jobstate The status of the task. Including execution status, start time, time consuming, and so on.
setting SparkJobSetting Lists the detail information of task configuration.

Response example

By executing a GET request on this resource, the returned response result in rjosn format is as follows:

[{

  "id": "cae72c2d_3550_4996_8bb1_682bc7d36533",

  "setting": {

    "DEFAULT_MASTER_ADRESS": "local[*] ",

    "analyst": {

      "datasetQuery": "Line",

      "inputQuery": "F:\\20170527_bsp.jar\\test\\data_toIserver.udb",

      "mode": "CONTAIN",

      "numSlices": "20"

    },

    "appName": "query",

    "args": [

      "--inputSource",

      "F:\\20170527_bsp.jar\\test\\data_toIserver.udb",

      "--datasetSource",

      "Region",

      "--numSlices",

      "20",

      "--inputQuery",

      "F:\\20170527_bsp.jar\\test\\data_toIserver.udb",

      "--datasetQuery",

      "Line",

      "--mode",

      "CONTAIN",

      "--outputResult",

      "F:\\20170621\\supermap_iserver_win64_zip\\webapps\\iserver\\processingResultData\\Analyst\\udbs\\586d0266-1a29-43c9-9775-9f4436fcaa5e",

      "--datasetResult",

      "analystResult"

    ],

    "contextSetting": null,

    "input": {

      "datasetSource": "Region",

      "inputSource": "F:\\20170527_bsp.jar\\test\\data_toIserver.udb"

    },

    "mainClass": "com.supermap.bsp.main.SpatialQueryGeoMain",

    "output": {

      "cacheName": null,

      "cacheType": null,

      "datasetResult": "analystResult",

      "outputResult": "F:\\20170621\\supermap_iserver_win64_zip\\webapps\\iserver\\processingResultData\\Analyst\\udbs\\586d0266-1a29-43c9-9775-9f4436fcaa5e"

    },

    "serviceInfo": {

      "targetDataPath": "F:\\20170621\\supermap_iserver_win64_zip\\webapps\\iserver\\processingResultData\\Analyst\\cae72c2d_3550_4996_8bb1_682bc7d36533",

      "targetServiceInfos": [

        {

          "serviceAddress": "http://localhost:8090/iserver/services/data-spatialQueryGeo4/rest",

          "serviceType": "RESTDATA"

        },

        {

          "serviceAddress": "http://localhost:8090/iserver/services/map-spatialQueryGeo4/rest",

          "serviceType": "RESTMAP"

        }

      ]

    },

    "serviceRoot": "http://localhost:8090/iserver/services/"

  },

  "state": {

    "elapsedTime": 6096,

    "endState": true,

    "endTime": 1498026621517,

    "errorMsg": null,

    "errorStackTrace": null,

    "publisherelapsedTime": 2273,

    "runState": "FINISHED",

    "startTime": 1498026611242

  }

}]

POST request

Creates a single object query job.

Request parameter

Parameters passed in the request body should contain:

Name Type Description
input FileCSVInputDataSetting
DatasetInputDataSetting

[Required] Supports two input ways:

 1.  datasetName: datasetName: dataset name. Used when the data to be analyzed is the dataset provided by the Data Catalog Service, including data imported through Data Catalog Service, registered data in iServer and datasets stored in DataStore.

 

 2. Input file path and the related information. When the data to be analyzed does not belong to Data Catalog Service, you need use this method.
      Supported file formats: csv file, udb file, pg database, index file stored in hdfs. For detailed parameters' description, see: Big data analysis input parameter settings.
analyst SpatialQueryGeoAnalystSetting

[Required] Analysis settings. You need to specify:

  • Query dataset (Currently doesn't support index files stored in hdfs)
    • datasetQuery: If the query dataset has been already registered in iServer, you need to specify the name of the query dataset by this parameter, ie., SpatialQueryGeoAnalystSetting.datasetQuery.
    • inputQuery: If the query dataset is not registered in iServer, you need to specify the datasource path and dataset name by this parameter. The query object is specified with the attributeFilter parameter since the query operation only concerns one object. Defaults to read from Spark driver directly, ie., SpatialQueryGeoAnalystSetting.inputQuery.
    • geometryQuery: If you want to pass in a geometry, you need to use this parameter to specify its geometry type and specific coordinates. At the same time, it supports generating buffer for the input geometry by setting these parameters through SpatialQueryGeoAnalystSetting.buffterAnalystParameter: 
      • endType: buffer endpoint type. Including: ROUND type and FLAT type.
      • leftDistance: left buffer distance.
      • rightDistance: right buffer distance.
      • semicircleLineSegment: Used to set the number of segments at the arc of the round buffer, ie., how many segments are used to simulate a semicircle.
      • radiusUnit: buffer radius unit. 
  • mode: spatial query mode. Different spatial query modes have different requirements for the type of source and query datasets.
  • IDENTITY: Indicates that the spatial objects in the source dataset and query object (ie., the spatial object with SMID is 0)in the query object dataset are completely coincident; the source dataset and the query object dataset must be of the same type.
  • DISJOINT: Indicates the spatial objects in the source dataset share no points in common with the query object (ie., the spatial object with SMID is 0) in the query object dataset, ie., not having any intersection; the source dataset is not related to the type of the query object dataset.
  • CONTAIN: Indicates the query object (ie., the spatial object with SMID is 0) in the query object dataset contains the spatial objects in the source dataset; supports to query point via point/line/polygon, query line via line/polygon, query polygon via polygon.
  • INTERSECT: Indicates the query object (ie., the spatial object with SMID is 0) in the query object dataset intersects with the spatial objects of the source dataset; the source dataset is not related to the type of the query object dataset.
  • TOUCH: Indicates the boundary of the query object (ie., the spatial object with SMID is 0) in the query object dataset intersects with the boundaries of the spatial objects of the source dataset, ie., the two geometries not having any internal intersection. There are the following situations:
    • The source point falls on the boundary of the query polygon
    • The source point falls on the start point or the end point of the query line
    • The query point falls on the start point or the end point of the source line
    • The start point or end point of the source line falls anywhere on the query line
    • There are adjacent area between the source lind and query polygon
    • There are adjacent one or more edges between the source polygon and the query polygon
  • WITHIN: Contrary to CONTAIN
  • CROSS: Indicates the intersection of the source spatial object and the query object (ie., the spatial object with SMID is 0) cannot be null; the query object dataset only can be line type; supports to find line/polygon via line.
  • OVERLAP: Indicates the intersection of the source spatial object and the query object (ie., the spatial object with SMID is 0) has the same dimension as one of them. Including: source line is a part of query line, the start point or end point of the source line falls on the query line. Supports to find line via line, find polygon via polyson.

output FileSystemOutputSetting DatabaseOutputSetting

[Optional] The output of analysis result. Supported output formats: local udb file, database (pg, mongodb). For detailed parameter settings, see: Big data analysis output parameter settings.

Example 1: Input the registered dataset name

Execute a POST request on query resource to create a single object query job: http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query.rjson with the following request body inputs registered dataset name:

{

  "input":{

         "datasetName":"test_data_toIserver_Region"

    },

  "analyst":{

        "datasetQuery":"test_data_toIserver_Line",

        "mode":"CONTAIN",

   }

}

then the returned resource in rjson format is as follows:

{

  "newResourceID": "b604dfb0_fa16_44ff_b79f_426638ce34ca",

  "newResourceLocation":"http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query/b604dfb0_fa16_44ff_b79f_426638ce34ca",

  "postResultType": "CreateChild",

  "succeed": true

}

Example 2: Input data stored in PostgreSQL

Execute a POST request on query resource to create a single object query job: http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query.rjson with the following request body which specifies data stored in PostgreSQL database:

{

    "input": {

        "datasetInfo": {

            "type": "REGION",

            "name": "newyorkZone_R_1359289148",

            "dataSourceName": "supermap_pg",

            "datasourceConnectionInfo": {

                "engineType": "POSTGRESQL",

                "dataBase": "supermap",

                "password": "supermap",

                "user": "postgres",

                "server": "192.168.112.100"

            }

        }

    },

    "analyst": {

       "inputQuery":"{\"type\":\"pg\",\"info\":[{\"server\":\"192.168.120.49\",\"datasetNames\":[\"singleRegion_R_1359289148\"],\"database\":\"supermap4\",\"user\":\"postgres\",\"password\":\"supermap\"}]}",

        "mode": "CONTAIN"

    }

}

then the returned resource in rjson format is as follows:

{

  "newResourceID": "7b106d77_eb46_4b82_93c7_c0367824123f",

  "newResourceLocation":"http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query/7b106d77_eb46_4b82_93c7_c0367824123f",

  "postResultType": "CreateChild",

  "succeed": true

}

Example 3: Input a geometry as the query dataset

Execute a POST request on query resource to create a single object query job: http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query.rjson with the following request body which contains a geometry and its buffer as the query dataset:

{

    "input": {

        "datasetName": "samples_processing_newyorkZone_R"

    },

    "analyst": {

        "geometryQuery": "{\"type\":\"REGION\",\"points\":[{\"x\":-73.96,\"y\":40.78},{\"x\":-73.90,\"y\":40.78},{\"x\":-73.95,\"y\":40.742},{\"x\":-73.90,\"y\":40.747}]}",

        "bufferAnalystParameter": {

            "endType": "ROUND",

            "leftDistance": {

                "value": "10"

            },

            "rightDistance": {

                "value": "10"

            },

            "semicircleLineSegment": "10",

            "radiusUnit": "METER"

        },

        "mode": "CONTAIN"

    }

}

then the returned resource in rjson format is as follows:

{

  "newResourceID": "c5a6ee10_36ea_4431_9251_21d7a71eb80b",

  "newResourceLocation":"http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/query/c5a6ee10_36ea_4431_9251_21d7a71eb80b",

  "postResultType": "CreateChild",

  "succeed": True

}

HEAD request

Returns the same HTTP response header as the GET request, but no response entity, which can be used to retrieve the meta data contained in response message header without having to transmit the entire response content. Meta data information includes media type, character coding, compression coding, entity content length, etc.

HEAD request is used to determine whether the query resource exists, or if the user has the authority to access it. By executing an HEAD request with a .<format> URI, you can quickly determine whether the query resource supports the <format> representation.

See