summaryAttributes


URI

<spatialanalystJobs_uri>/summaryattributes[.<format>]

 

支持的方法

GETPOSTHEAD

父资源

spatialanalystJobs

子资源

summaryAttributesJob

介绍

属性汇总统计分析作业资源根目录。通过对 summaryAttributes  执行GET 请求,可获取当前系统的属性汇总统计分析作业列表。通过 POST 请求可创建一个分析任务。

支持的方法:

支持的表述格式:RJSON、JSON、HTML、XML。

资源层次

HTTP 请求方法

对如下 URI 执行 HTTP 请求,以 rjson 输出格式为例加以说明,其中,supermapiserver 是服务器名。

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

GET 请求

获取属性汇总统计分析作业列表。

响应结构

对 summaryAttributes 资源执行 GET 请求,在响应消息的实体主体里是一个属性汇总统计分析资源描述集,其中单个资源描述的结构如下:  

字段 类型 说明
id String 应用ID。
state SparkJobState 该任务的状态。包括执行状态、起止时间、耗时等。
setting SparkJobSetting 列举了任务配置的详细信息。

响应示例

对 summaryAttributes 资源执行 GET 请求,返回 rjson 格式的资源描述如下:

{

  "id": "b999e6ba_61c7_4c29_9009_5d876469db33",

  "setting": {

    "DEFAULT_MASTER_ADRESS": "local[*] ",

    "analyst": {

      "attributeField": "",

      "groupField": "",

      "resultField": null,

      "statisticModes": ""

    },

    "appName": "SummaryAttributes",

    "args": [

      "--input",

      "{\"sliceNum\":20,\"type\":\"udb\",\"info\":[{\"server\":\"F:\\\\1.package\\\\20171014\\\\supermap_iserver_901_15413_4668_win64_zip\\\\samples\\\\data\\\\ProcessingData\\\\processing.udb\",\"datasetNames\":[\"newyorkZone_R\"]}]}",

      "--output",

      "{\"server\":\"192.168.120.21\",\"password\":\"supermap\",\"database\":\"supermap2\",\"datasetName\":\"analystResult_1698682527\",\"blockingWrite\":null,\"type\":\"pg\",\"user\":\"postgres\"}"

    ],

    "contextSetting": null,

    "input": {

      "datasetInfo": {

        "available": true,

        "bounds": "Left=-74.25551784310493,Bottom=40.496084221255856,Right=-73.70014827248451,Top=40.91538866049913",

        "datasetName": "newyorkZone_R",

        "datasetType": "REGION",

        "epsgCode": 4326,

        "name": "samples_processing_newyorkZone_R",

        "readOnly": false,

        "type": "UDB",

        "url": "../../samples/data/ProcessingData/processing.udb"

      },

      "datasetName": "samples_processing_newyorkZone_R",

      "numSlices": 0

    },

    "mainClass": "com.supermap.bdt.main.SummaryAttributesMain",

    "output": {

      "datasetName": "analystResult_1698682527",

      "datasourceInfo": {

        "alias": "supermap2_pg",

        "connect": true,

        "dataBase": "supermap2",

        "driver": "PostgreSQL ANSI",

        "engineType": "POSTGRESQL",

        "exclusive": false,

        "openLinkTable": false,

        "password": "supermap",

        "readOnly": false,

        "server": "192.168.120.21",

        "user": "postgres"

      },

      "outputPath": "F:\\1.package\\20171014\\supermap_iserver_901_15413_4668_win64_zip\\webapps\\iserver\\processingResultData\\Analyst\\b999e6ba_61c7_4c29_9009_5d876469db33\\summaryAttributes.smwu",

      "type": "pg"

    },

    "serviceInfo": {

      "targetDataPath": "F:\\1.package\\20171014\\supermap_iserver_901_15413_4668_win64_zip\\webapps\\iserver\\processingResultData\\Analyst\\b999e6ba_61c7_4c29_9009_5d876469db33\\summaryAttributes.smwu",

      "targetServiceInfos": [{

        "serviceAddress": "http://192.168.120.21:8090/iserver/services/data-summaryAttributes/rest",

        "serviceType": "RESTDATA"

      }]

    },

    "serviceRoot": "http://supermapiserver:8090/iserver/services/",

    "sparkLogFile": null

  },

  "state": {

    "elapsedTime": 6177,

    "endState": true,

    "endTime": 1508224183579,

    "errorMsg": null,

    "errorStackTrace": null,

    "publisherelapsedTime": 1823,

    "runState": "FINISHED",

    "startTime": 1508224172840

  }

}

POST 请求

创建一个属性汇总统计分析任务。

请求参数

对 summaryAttributes 资源执行 POST 请求,创建一个属性汇总统计分析任务,请求体需包含参数如下:

名称 类型 含义

input

【必填参数】

DatasetInputDataSetting
  • 数据集输入设置,当输入数据是一个数据目录服务中已存在的数据集时,用该设置。其中包含如下字段
    • datasetName:数据集名称。其中数据集的来源包括通过数据目录服务导入的数据、注册到 iServer 的数据对应的数据集以及 DataStore 中存储的数据集。
  • 数据集信息输入设置,当输入数据集文件路径及信息时,用该设置。其中包含如下字段
    • datasetInfo:数据集信息。其中数据集的来源包括:csv文件、udb文件、空间数据库。详细参数说明请参考:大数据分析输入参数设定
 FileCSVInputDataSetting
  • 文件路径输入设置。 当输入数据集文件路径时,用该设置。其中包含如下字段。
    • filePath:文件所在路径。其中路径包括:csv文件路径、hdfs文件路径。 详细参数说明请参考:大数据分析输入参数设定
    • metaInfo:数据文件的元信息。若该数据存放目录下包含 .meta 文件,则此参数可不填。

analyst

SummaryAttributesAnalystSetting 【非必填参数】分析配置。传入时,需指定:
  • groupField:分组字段,根据属性字段里的属性值进行分组,相同属性值的对象分为一组,将分好的组根据属性字段进行统计。可设置多个字段,使用逗号“,”分离。若不设置该参数,将对所有对象进行属性统计。仅支持系统字段以外的字段。
  • attributeField:属性字段,将分组后的对象根据该字段进行统计。可设置多个字段,使用逗号“,”分离。若不设置该参数,不进行任何统计。若分组字段为空,则把属性表中所有对象视为一组,进行属性字段统计。该长度必须和统计模式保持一致。仅支持系统字段以外的数值型的字段。
  • statisticModes:统计模式,可设置多个字段,使用逗号“,”分离。该长度必须和属性字段保持一致。可选的模式有:max,min,average,sum,variance,stdDeviation。
  • 若以上字段均为空,则对属性表中所有对象个数进行统计

output

【选填参数】

FileSystemOutputSetting
  • 分析结果输出设置。当输出结果到文件时。用该设置。其中包含如下字段
    • type:指定输出类型。
    • datasourcePath :结果数据源的存放路径。其中分析结果可以存放到udb或hdfs中。
    • outputPath:分析结果工作空间输出路径。
DatabaseOutputSetting
  • 分析结果输出设置。当输出结果到数据库(HBase、 PostgreSQL、PostGIS、MongoDB)时。用该设置。其中包含如下字段
    • type:指定输出类型。
    • datasetName:分析结果数据集名称。
    • datasourceInfo:结果数据源的连接信息。详细参数设定请参考:大数据分析输出参数设定

示例1:输入数据集名称

对示例 summaryAttributes 资源:http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/summaryattributes.rjson 执行 POST请求,输入一个已注册到iServer的数据集,传入数据集名称即可。创建一个属性汇总统计分析任务。请求体如下:

{

    "input": {

        "datasetName": "samples_processing_newyorkZone_R"

    },

    "analyst": {

        "groupField": "borough",

        "attributeField": "LocationID",

        "statisticModes": "max"

    }

}

返回 rjson 格式的操作结果表述如下:

{

  "newResourceID": "740e3864_4698_4cf2_aa2a_3e25282bcac7",

  "newResourceLocation":"http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/summaryattributes/740e3864_4698_4cf2_aa2a_3e25282bcac7",

  "postResultType": "CreateChild",

  "succeed": true

}

示例2:输入PostgreSQL存储的数据

对示例 query 资源:http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/summaryattributes.rjson 执行 POST 请求,输入数据为存储于PostgreSQL 数据库的数据。创建一个属性汇总统计任务,请求体中的参数如下:

{

    "input": {

        "datasetInfo": {

            "type": "REGION",

            "name": "newyorkZone_R_657101200",

            "datasourceConnectionInfo": {

                "engineType": "POSTGRESQL",

                "dataBase": "supermap",

                "password": "supermap",

                "user": "postgres",

                "server": "192.168.120.21"

            }

        }

    },

    "analyst": {

        "groupField": "borough",

        "attributeField": "LocationID",

        "statisticModes": "min"

    }

}

返回 rjson 格式的操作结果表述如下:

{

  "newResourceID": "6bb40d00_e89b_493d_b787_e0e82fd4fc57",

  "newResourceLocation":  "http://supermapiserver:8090/iserver/services/distributedanalyst/rest/v1/jobs/spatialanalyst/summaryattributes/6bb40d00_e89b_493d_b787_e0e82fd4fc57",

  "postResultType": "CreateChild",

  "succeed": true

}

HEAD 请求

返回跟 GET 请求一样的 HTTP 响应头,但是没有响应实体。可以在不必传输整个响应内容的情况下,获取包含在响应消息头中的元数据信息。元数据信息包括媒体类型,字符编码,压缩编码,实体内容长度等。

HEAD 请求可以用来判断 summaryAttributes 资源是否存在,或者客户端是否有权限访问 summaryAttributes 资源。通过对加.<format>的 URI 执行 HEAD 请求,还可以快速判断 summaryAttributes 资源是否支持<format>格式的表述。

请参见