• 2010年8月21日周六_GeoprocessingTasks_6.7


    /*****************************************************************************************************************/

    //2010821周六

    //InsideTheAPI_GroprocessingTask_6.7

    /*****************************************************************************************************************/

    Geoprocessing allows you to automate your GIS analyses by creating custom tools and linking them within ArcGIS. You can arrange these tools in a logical way to accomplish a multistep task in a single operation rather than a series of manually run tools.

    The Geoprocessor class in the ArcGIS API for Flex gives you access to various geoprocessing tasks, which are exposed through services in the ArcGIS Server Services Directory.

    To use the geoprocessing services, obtain the following information from the Services Directory:

    The URL of the geoprocessing task

    The required inputs and outputs of the task

    The task type synchronous or asynchronous

    Obtaining the URL

    The Services Directory links to all available services. The image below shows a sample geoprocessing service:

    Geoprocessingw能够让你通过创建自定义工具并将他们连接到ArcGIS来自动化进行你的GIS分析。你可以用一个逻辑的方式来组织这些工具在一个操作中完成一个多步的任务而不是一系列的手工的操纵。

    ArcGIS API for Flex 中的Geoprocessor 类给了你访问多种geoprocessing任务的权限,Geoprocessor类是在ArcGIS Server Services目录下通过服务发布的

    为了使用geoprocessing服务,从Services 的目录中获取下列信息。

    Geoprocessing task URL

    任务输入和输出的内容。

    任务的类型:同步(synchronous)的还是异步(asynchronous)的。

    获取URL

    From this page, you can see that the geoprocessing service ESRI_Elevation_World   is located in the Elevation folder and runs on sampleserver1.arcgisonline.com.

    The following appears when you click the Viewshed geoprocessing model:

    从这个页面你可以看到geoprocessing服务ESRI_Elevation_World保存在sampleserver1.arcgisonline.com Elevation文件夹下面

    单击Viewshed geoprocessing模型你可以看到下面的界面,

     

    To execute this geoprocessing task, copy and paste this MXML code into your application:

    为了执行geoprocessing任务,拷贝并黏贴下面的MXML代码到你的应用程序中

    <esri:Geoprocessor

        id="gp"

        url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed"

    />

    The equivalent code with ActionScript:

    //脚本表示相应的代码

    var gp:Geoprocessor = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed");

     

    Supplying the parameters

    The parameters in the Services Directory show the required inputs and outputs of the task. In the example above, you need to supply all parameters whose Direction is esriGPParameterDirectionInput and whose Parameter Type is esriGPParameterTypeRequired.

    You do not have to supply the output parameters because the output is always returned as an array of ParameterValue  .

    For instance, the input parameters might look like:

    var params:Object = "Input_Observation_Point":featureSet, "Viewshed_Distance":vsDistance );

    提供参数

    Services目录下的参数显示了任务需要的输入和输出。在上面例子中。 你需要提供所有的参数,他们的目标是esriGPParameterDirectionInput,他们的Parameter Type esriGPParameterTypeRequired.

    你不需要提供输出参数,因为输出总是以一个ParameterValue数组的形式返回。

    比如:输入的参数可能和下面的类似

    var params:Object = "Input_Observation_Point":featureSet, "Viewshed_Distance":vsDistance

    Running the task

    The way you run the task depends on whether the geoprocessing task is synchronous or asynchronous.

    In the case of synchronous execution, the client executes the task and waits for a response before proceeding. The Supported Operations section of the Services Directory displays "Execute Task" for synchronous tasks.

    In an asynchronous execution, the client submits a job, then verifies that it was successful using a unique job ID. When the task completes, the client can retrieve the results. The Supported Operations section of the Services Directory displays "Submit Job" for asynchronous tasks.

    运行任务

     

    你执行task的方式基于geoprocessing任务是同步还是异步的。

    如果是synchronous(同步),客户端执行这个任务,在进行下一步之前她必须等待。Services Directory中的支持操作的部分为同步的任务展示的“Execute Task”。

    在一个异步的解决方案里面,客户单提交了一个工作,然后核实它成功的使用了一个唯一的工作ID 当任务结束后,客户端会重新获取结果。Services Directory中的支持操作的部分展示了为异步任务提交工作

     

    Synchronous tasks

    To run a synchronous task, call Geoprocessor.execute(). Supply the input parameters for the task and optionally include a callback function that tells the application how to handle the results.

    gp.execute(params, myFunction);

     

    The results of the task are returned to the callback function as an array of ParameterValue  . If messages are enabled, you also get an array of GPMessage  objects.

    You can loop through each item in the results array and add it to the map. For instance:

    为了运行synchronous任务,调用Geoprocessor.execute(),支持为为任务输入参数并可选择性的包含一个callback函数,它告诉应用层序如何去处理结果。

    gp.execute(params, myFunction);

    任务的结果以一个ParameterValue数组的形式返回给callback函数, 如果消息启动,那么还可以获取一个GPMessage对象数组。

    你可以循环遍历结果数组里面的每一个item,并将他们添加到地图,比如:

    private function displayResult(event:GeoprocessorEvent):void

    {

        for each ( var myGraphic:Graphic in event.parameterValues[0].value.features )

        {

            myGraphic.symbol = viewshedSimpleFill;

            myGraphicsLayer.add( myGraphic );

        }

    }

    //

    where viewshedSimpleFill has been defined in MXML as:

    viewshedSimpleFill已经在MXML中定义,如下所示:

    <esri:SimpleFillSymbol id="viewshedSimpleFill" color="0xFF0000" alpha="0.5">

        <esri:SimpleLineSymbol color="0x000000" width="1"/>

    </esri:SimpleFillSymbol>

    Asynchronous tasks

    To run an asynchronous task, call Geoprocessor.submitJob(). Supply the input parameters and optionally specify (1) a complete callback function to be called when the job is successful and (2) a status callback function when the geoprocessor checks the job status.

    gp.submitJob(params, MyCompleteCallback, myStatusCallback);

      

    The status callback receives a JobInfo object containing the job ID, the job status, and any GPMessage objects returned by the geoprocessor.

    异步任务

    为了运行一个task,调用Geoprocessor.summitJob(). 提供输入参数并可选择性的指定一个结束回调函数,当job成功完成后就调用,和一个状态回调函数,当geoprocessor 检查状态的时候调用这个函数。

    gp.submitJob(params, MyCompleteCallback, myStatusCallback);

    status回调接受到一个JobInfo对象,她包含了jobIDjob的状态和任何由geoprocessor返回的GPMessage对象。

    /*********************************************************************/

    //后记:

    这个服务我也不知道该怎么使用,我也没有看懂。

    这里仅仅是对API的文档进行范围,以后如果对这个理解了,

    我们在对这个服务的使用个方法进行补充

    /*********************************************************************/

  • 相关阅读:
    MongoDB ‘conn’Mongo 对象远程代码执行漏洞
    Linux Kernel 本地拒绝服务漏洞
    Linux Kernel ‘skbuff.c’本地拒绝服务漏洞
    WordPress Citizen Space插件跨站请求伪造漏洞
    OpenSSH远程拒绝服务漏洞
    Bug之王花落谁家:四大最危险编程语言,PHP竟然不是bug最多的语言!
    《出Bug表》假如诸葛亮是程序员!写Bug测Bug,不宜异同!
    关于程序员的段子,有没有get到你的点?单身的程序员才是完整的程序员!
    关于程序员的段子,有没有get到你的点?单身的程序员才是完整的程序员!
    socket 通信 入门3 android 客户端 C# 服务端
  • 原文地址:https://www.cnblogs.com/xingchen/p/1805304.html
Copyright © 2020-2023  润新知