Silverlight调用GP工具实现缓冲分析
目的:
在地图上点击一个点生成一个缓冲区。
1、制作GP工具:
GP工具制作按照http://help.arcgis.com/zh-cn/arcgisdesktop/10.0/help/index.html#//002v00000014000000来做。
2、发布GP工具:
3、分析GP服务:
将发布的GP服务地址在浏览器中输入:http://wade-pc/arcgis/rest/services/BufferService/GPServer/Buffer%20Points
4、在Silverlight中使用GP服务:
前台代码:
<UserControl xmlns:esri="http://schemas.esri.com/arcgis/client/2009" x:Class="GPServiceTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<!--输入点样式-->
<esri:SimpleMarkerSymbol x:Key="DefaultClickSymbol" Size="5" Color="Red"/>
<!--缓冲区样式-->
<esri:SimpleFillSymbol x:Key="DefaultBufferSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" />
</Grid.Resources>
<esri:Map x:Name="MyMap" Background="White"
MouseClick="MyMap_MouseClick" >
<!--底图-->
<esri:ArcGISDynamicMapServiceLayer ID="main"
Url="http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer"/>
<!--存放输入点-->
<esri:GraphicsLayer ID="MyGraphicsLayer">
</esri:GraphicsLayer>
</esri:Map>
<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
<Rectangle Fill="#77919191" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="0,0,0,5" >
<Rectangle.Effect>
<DropShadowEffect/>
</Rectangle.Effect>
</Rectangle>
<Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
<TextBlock x:Name="InformationText" Text="Click on map to set a location. A buffer of 1000 meters will be displayed."
Width="200" Margin="30,20,30,25" HorizontalAlignment="Left" TextWrapping="Wrap" />
</Grid>
</Grid>
</UserControl>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Symbols;
namespace GPServiceTest
{
public partial class MainPage : UserControl
{
Geoprocessor _geoprocessorTask;
public MainPage()
{
InitializeComponent();
_geoprocessorTask = new Geoprocessor("http://wade-pc/arcgis/rest/services/BufferService/GPServer/Buffer%20Points");
_geoprocessorTask.JobCompleted += new EventHandler<JobInfoEventArgs>(_geoprocessorTask_JobCompleted);
_geoprocessorTask.GetResultDataCompleted += new EventHandler<GPParameterEventArgs>(_geoprocessorTask_GetResultDataCompleted);
_geoprocessorTask.Failed += new EventHandler<TaskFailedEventArgs>(_geoprocessorTask_Failed);
}
void _geoprocessorTask_Failed(object sender, TaskFailedEventArgs e)
{//分析失败
MessageBox.Show("失败");
}
void _geoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs e)
{
//将分析结果显示在地图上
GraphicsLayer graphicsLayer = new GraphicsLayer();
GPFeatureRecordSetLayer featureSetLayer = e.Parameter as GPFeatureRecordSetLayer;
foreach (Graphic graphic in featureSetLayer.FeatureSet.Features)
{
graphic.Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as Symbol;
graphicsLayer.Graphics.Add(graphic);
}
MyMap.Layers.Add(graphicsLayer);
}
void _geoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
{
if (e.JobInfo.JobStatus == esriJobStatus.esriJobFailed)
{
MessageBox.Show("服务请求失败:" + e.JobInfo.Messages.ToString());
}
else
{
_geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "OutputPolygons");//异步获取分析结果
}
}
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{//鼠标点击
//清除存放点击点的图层
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
//获取点击的点 并添加到地图中
e.MapPoint.SpatialReference = MyMap.SpatialReference;
Graphic graphic = new Graphic()
{
Geometry = e.MapPoint,
Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as Symbol
};
graphic.SetZIndex(1);
graphicsLayer.Graphics.Add(graphic);
//分析
List<GPParameter> parameters = new List<GPParameter>();
parameters.Add(new GPFeatureRecordSetLayer("Input_Features", e.MapPoint));//设置输入参数
parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMeters, 10000));//设置缓冲半径
_geoprocessorTask.SubmitJobAsync(parameters);//提交异步分析
}
}
}
5、结果展示:
Silverlight调用GP工具实现缓冲分析的更多相关文章
- ArcGIS API for Silverlight 调用GP服务准备---GP模型建立、发布、测试
原文:ArcGIS API for Silverlight 调用GP服务准备---GP模型建立.发布.测试 第一篇.GP降雨量等值线建模.发布及测试 在水利.气象等行业中,要在WebGIS中实现空间分 ...
- ArcGIS API for Silverlight 调用GP服务加载等值线图层
原文:ArcGIS API for Silverlight 调用GP服务加载等值线图层 第二篇.Silverlight客户端调用GP服务 利用ArcGIS API for Silverlight实现G ...
- AE调用GP工具的方法(转)
第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第二,按照需求看看在arctoolbox工具中是怎么实现功能的,然后确定需要的数据源. 第三,编写command或t ...
- ArcGIS API for Silverlight 调用GP服务绘制等值面
原文:ArcGIS API for Silverlight 调用GP服务绘制等值面 GP服务模型如下图: 示例效果图片如下:
- 利用C#与AE调用GP工具
转自原文 利用C#与AE调用GP工具 第一,首先要明确自己需要调用arctoolbox里面的什么工具,实现什么样的功能. 第三,编写command或tool工具,编写自己要的功能工具. 1)首先创建一 ...
- AE调用GP工具(创建缓冲区和相交为例)
引用 Geoprocessing是ArcGIS提供的一个非常实用的工具,借由Geoprocessing工具可以方便的调用ArcToolBox中提供的各类工具,本文在ArcEngine9.2平台环境下总 ...
- c# 调用ArcEngine的GP工具
转自原文c# 调用ArcEngine的GP工具,AE调用GP工具 IAoInitialize m_AoInitialize = new AoInitializeClass(); esriLicense ...
- ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能
原文:ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能 昨天一QQ好友问了一个关于裁剪的问题,感觉自己也没有帮上什么忙,之后自己做了一个裁剪的例子,不过在做这个例子的 ...
- AE开发实现GP工具IDW
IDW——空间插值 IDW(Inverse Distance Weighted)是一种常用而简便的空间插值方法,它以插值点与样本点间的距离为权重进行加权平均,离插值点越近的样本点赋予的权重越大. 设平 ...
随机推荐
- Python基础之collection
collection-系列 cellection是作为字典.元组(列表与元组可互相转换)的扩充,在此需要导入cellection 一.计数器(counter) counter是对字典类型的补充,用户获 ...
- 【转】微信小程序原理
微信小程序原理 kamidox 关注 2016.11.05 09:42* 字数 2356 阅读 14621评论 5喜欢 75赞赏 1 微信小程序使用了前端技术栈 JavaScript/WXML/WXS ...
- eureka集群环境搭建
一:集群环境搭建 第一步:我们新建两个注册中心工程一个叫eureka_register_service_master.另外一个叫eureka_register_service_backup eurek ...
- CF739B
深搜的过程中保存路径,二分路径中满足要求的区段.不必将每个节点的ans加1,只需将合法区段末尾加1同时将开头减1来表示并保存在一个“前缀”数组中即可.最后再dfs一次累加得到答案. #include ...
- 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} 解决方法
Tomcat启动时出现红色警告内容 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'sour ...
- Spark中Java函数的使用方法笔记
1: map 函数map是对RDD中的每个元素都执行一个指定的函数来产生一个新的RDD. 任何原RDD中的元素在新RDD中都有且只有一个元素与之对应. 2: mapPartitions函数</p ...
- Linux中yum、rpm、configure使用介绍
安装程序命令介绍 安装包选择策略:能上外网:yum方式.绿色方式->不能上外网:rpm方式.configure方式 1.yum命令yum安装包时,会包所依赖的包也会安装到系统,将源换成163的源 ...
- saltstack-day1
一.远程执行命令 1.指定一个ipv4地址或者一个子网 salt -S 172.16.7.19 test.ping salt -S test.ping 2. 正则表达式 salt -E "j ...
- 用dfs求联通块(UVa572)
一.题目 输入一个m行n列的字符矩阵,统计字符“@”组成多少个八连块.如果两个字符所在的格子相邻(横.竖.或者对角线方向),就说它们属于同一个八连块. 二.解题思路 和前面的二叉树遍历类似,图也有DF ...
- selenium+chrome浏览器驱动-爬取百度图片
百度图片网页中中,当页面滚动到底部,页面会加载新的内容. 我们通过selenium和谷歌浏览器驱动,执行js,是浏览器不断加载页面,通过抓取页面的图片路径来下载图片. from selenium im ...