您的位置:首页 > 运维架构

GP(Geoprocessing)服务的发布与调用

2011-01-06 14:41 344 查看
1、什么是GP服务

GP服务是Geoprocessing服务的简称,Geoprocessing包含了一系列地理数据处理的功能,像做缓冲区分析、叠加分析、以及对栅格数据制作阴影图等等。在桌面软件中可以通过ArcToolbox中的工具直接调用Geoprocessing的功能,而如果期望通过web来调用GP的功能,就必须借助于GP服务了。Esri的帮助文档中介绍了发布GP服务的两种方式:

l Publish a geoprocessing toolbox. Each tool in the toolbox becomes a task in the geoprocessing service.

l Publish an ArcMap document containing geoprocessing tool layers. Each tool layer becomes a task in the geoprocessing service.

也就是说我们既可以将某个工具单独发布为一个服务,也可以将该工具作为一个工具图层(tool layer)和地图文档一起发布,这样会同时得到同名的一个地图服务和一个GP服务。这里地图服务中的图层可以当做GP任务的数据源,也可以利用工具图层得到的结果来控制最后输出图层的符号。

2、如何发布GP服务——buffer为例

2.1 案例介绍

这里我们使用ArcTutor\Using_ArcGIS_Desktop\MexicoPopulationDensity.mxd【已经安装ArcTutor练习数据】作为地图服务,并且调用GP中的Buffer工具来进行缓冲区的创建。这里我们采用地图文档和工具一起发布的方式,GP服务的输入为通过和地图交互得到的点(即feature set),而直接使用buffer工具的话输入参数只能是要素类或图层,所以需要通过ModelBuilder制作模型来让GP服务正确读取输入参数。

2.2 准备模型

在ArcTutor\GP Service Examples\BufferPoints目录下,会看到已经制作好的示例模型。在这里截图展示:

代码

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:esri="http://www.esri.com/2008/ags">
<esri:Map id="map" mapClick="mapClick(event)">
<esri:ArcGISDynamicMapServiceLayer url="http://localhost/arcgis/rest/services/BufferPoint/MapServer"/>
<esri:GraphicsLayer id="graphicsLayer"/>
</esri:Map>
<esri:Geoprocessor id="gp" url="http://localhost/arcgis/rest/services/BufferPoint/GPServer/Buffer%20Points"
executeComplete="gpExecuteCompleteHandler(event)"
fault="Alert.show(event.fault.message)"/>

<mx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.tasks.BufferParameters;
import com.esri.ags.events.MapEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.tasks.ParameterValue;
import com.esri.ags.tasks.FeatureSet;
import com.esri.ags.events.GeoprocessorEvent;
import mx.controls.Alert;

private function gpExecuteCompleteHandler(event:GeoprocessorEvent):void
{
//绘制buffer graphicsLayer.graphicProvider=gp.executeLastResult.parameterValues[0].value.features;
}

private function mapClick(event:MapMouseEvent):void
{
graphicsLayer.clear();
var graphic:Graphic=new Graphic(event.mapPoint);
graphicsLayer.add(graphic);
gp.execute({"Input_Points": new FeatureSet([graphic]),"Distance":{"distance":100,"units":"esriKilometers"}}); }
]]>
</mx:Script>
</mx:Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐