第8课矩形和多边形查询.ppt

上传人:本田雅阁 文档编号:2980835 上传时间:2019-06-17 格式:PPT 页数:49 大小:298.01KB
返回 下载 相关 举报
第8课矩形和多边形查询.ppt_第1页
第1页 / 共49页
第8课矩形和多边形查询.ppt_第2页
第2页 / 共49页
第8课矩形和多边形查询.ppt_第3页
第3页 / 共49页
第8课矩形和多边形查询.ppt_第4页
第4页 / 共49页
第8课矩形和多边形查询.ppt_第5页
第5页 / 共49页
点击查看更多>>
资源描述

《第8课矩形和多边形查询.ppt》由会员分享,可在线阅读,更多相关《第8课矩形和多边形查询.ppt(49页珍藏版)》请在三一文库上搜索。

1、矩形和多边形查询,2013年10月,主要内容,自定义矩形查询 自定义多边形查询 弥补自定义点查询编程实现,自定义矩形,用户自行指定的矩形区域,和自定义点有何不同?,点所在的区域 和矩形有所重叠的区域,是哪一个矩形?,是哪一个矩形?,从屏幕上的矩形到地图层面的矩形 思路: (1)得到屏幕上的矩形; (2)得到对角线上的顶点; (3)把屏幕上的顶点转换成地图上的顶点; (4)由地图上顶点构成地图上的矩形。,得到屏幕上的矩形,把屏幕上的矩形转换成地图上的矩形,Point 点对象,由(x, y)确定位置 矩形对象的创建包络对象的创建 Envelope env1=new Envelope(); Enve

2、lope env1=new Envelope(左上角,右下角);,空间查询,和矩形有所重叠的区域,空间查询,使用查询功能对象,以及空间过滤对象 查询功能对象 IQueryFuncitionality func=资源对象.CreateFunctionality();,如何查询使用空间过滤对象,空间过滤对象SpatialFilter对象,在ESRI.ArcGIS.ADF.Web命名空间中 SpatialFilter 对象名=new SpatialFilter(); 设置其属性 对象名.Geometry=地图上指定的图形 对象名.MaxRecords=结果集中能容纳的数量,主要编程步骤,地图控件地图

3、资源对象功能对象(查询)查询功能经过空间过滤对象空间要素集转换成htm标记并在地图上高亮度显示。,编程结构,一个对事件的响应类IdentifyRectangle 一个辅助类IdentifyHelper,用于作为类库,具体实现,得到地图服务项目的功能 得到查询功能,具体实现,创建空间过滤对象,并设置其,具体实现,得到图层对象 在各个图层中进行空间查询,结果放在一个dataTable对象中,具体实现,把表转换成html标记,并在地图上显示出,主要步骤,1增加ToolBar上面的按钮,设置其属性 2增加必要的类IdenfifyRectangle,实现IMapServerToolAction.Serv

4、erAction方法。 用于把矩形对角的两个点坐标从屏幕转换到地图坐标。再利用Envelope类的构造函数构造一个地图坐标的矩形对象。 3在IdentifyHelper中增加相应的方法Identify,用来实现矩形的查询。 31 获取控件对象 32 得到目标对象的空间矩形,主要步骤,4在IdentifyHelper中增加相应的方法 41 判别资源是否可用,是否具有查询功能 42 若资源具有查询功能,则得到其查询功能。 43 依据原有的矩形,构造一个空间查询矩形对象。 44 取出可查询图层,到一个查询结果图层数组。 45 从可查询图层中,查询每个图层中的对象。 46 送到网页上显示。,主要步骤,

5、5其他辅助函数 51 编写一个函数,利用GridView将数据表中内容显示到表格中,其中借助HtmlTextWriter类,将表格的内容转换成html格式的字符串。 52 编写另一个函数,将数据表转换成html表格格式的字符串,并把该字符串赋值给地图网页上的一个隐藏的文本框控件,调用open方法,弹出“属性查询页面”。 53 通过地图控件的CallBackResults属性中设定事件响应机制,设定响应的事件,以及事件响应函数。 6编写一个弹出信息属性窗口的网页,课堂实践,自定义矩形查询:P93-P96 补:自定义点查询编程实现,课堂实践,自定义矩形查询:P93-P96,自定义多边型查询,实现步

6、骤,1. 给自定义Tool增加一个地图关联事件,设定关联的响应。 2. 响应之处实现一个IMapServerToolAction接口的ServerAction函数: (1)得到地图控件 (2)得到地图控件上被指定的图形。 (3)得到图形所对应或覆盖到的对象。 (4)把屏幕对象映射到地图对象。 (5)得到地图对象位置所对应的图层的各个对象。 (6)把结果送给网页窗口显示。 (7)接收并把结果转换成html格式的字符串,通过地图控件的回传处理函数,把字符串显示在弹出的网页上。,自定义,自定义多边形的获取 从屏幕上的多边形得到地图上的多边形 以多边形为过滤条件进行空间查询 ,自定义多边形的获取,从屏

7、幕上的多边形得到地图上的多边形,从屏幕上的多边形得到各个拐点(点的集合) 把屏幕上各点转换成地图上的对应点 把地图上的各点形成地图上的多边形,多边形转换,从屏幕上的多边形得到各个拐点(点的集合),把屏幕上各点转换成地图上的对应点,多边形转换,把地图上的各点形成地图上的多边形 知识:从地图上的点集合,形成到地图上的环,到地图上的多边形 Ring是ESRI. ArcGIS. ADF. Web. Geometry. Ring RingCollection是ESRI.ArcGIS.ADF.Web.Geometry.RingCollection,后续任务,空间查询,得到查询结果集 查询结果集转换、显示,

8、自定义多边形查询属性的实现,仍然需要一个响应类,和支持类的辅助。 对于自定义多变形查询来说 ,需要增加一个函数,实现多边形坐标系统的转换。,响应类,public class IdentifyPolygon : IMapServerToolAction void IMapServerToolAction.ServerAction(ToolEventArgs args) Map map = args.Control as Map; PolygonEventArgs polyArgs = (PolygonEventArgs)args; Polygon mapPoly = GeometryHelper

9、.GetMapPolygon(map, polyArgs); IdentifyHelper.Identify(map, mapPoly); ,自定义多边形查询属性的实现,仍然需要一个响应类,和支持类(共2个IdentifyHelpe、GeometryHelper)的辅助。 对于自定义多变形查询来说 ,需要增加一个函数,实现多边形坐标系统的转换。,响应类,public class IdentifyPolygon : IMapServerToolAction void IMapServerToolAction.ServerAction(ToolEventArgs args) Map map = a

10、rgs.Control as Map; PolygonEventArgs polyArgs = (PolygonEventArgs)args; Polygon mapPoly = GeometryHelper.GetMapPolygon(map, polyArgs); IdentifyHelper.Identify(map, mapPoly); ,支持类的成员,public static void Identify(Map map, ESRI.ArcGIS.ADF.Web.Geometry.Geometry mapGeometry) public static void ShowIdentif

11、yResult(Map map, DataTableCollection dtc) public static string GetHtmlFromDataTable(DataTable dt) public static void AddJavaScriptCallback(Map map, string executeString),Identify()方法的作用及组成步骤,IdentifyHelper.Identify(mapCtrl, mapGeometry) ,接受传递而来的参量数值。 判别资源是否可用,是否具有查询功能,若资源具有查询功能,则得到其查询功能。 依据原有的形状对象,构

12、造一个空间查询对象。 利用该查询对象从可查询图层中过滤出查询结果图层数组。 从可查询图层数组中查询每个图层中的对象(遍历),送到一个dataSet中。 再把dataSet的Table送到DataTableCollection对象中。 形成Html字符串,送给浏览器显示。,对比在响应类中的处理部分,Map map = args.Control as Map; 点查询: PointEventArgs pea = (PointEventArgs)args; System.Drawing.Point screen_point = pea.ScreenPoint; Point point = Point

13、.ToMapPoint(); 矩形查询 RectangleEventArgs rectargs = (RectangleEventArgs)args; System.Drawing.Rectangle myrect = rectargs.ScreenExtent; 顶点坐标转换;形成地图上的矩形; IdentifyHelper.Identify(mapCtrl, mapGeometry); 多边形查询 PolygonEventArgs polyArgs = (PolygonEventArgs)args; Polygon mapPoly = GeometryHelper.GetMapPolygo

14、n(map, polyArgs); IdentifyHelper.Identify(map, mapPoly); 圆查询 CircleEventArgs circleArgs = (CircleEventArgs)args; Polygon mapPoly = GeometryHelper.GetMapPolygon(map, circleArgs); IdentifyHelper.Identify(map, map mapGeometry);,课堂实践,自定义多边形查询:P96-P97 补:自定义点查询编程实现 自定义矩形查询编程实现,课堂实践,自定义矩形查询:P93-P96 自定义多边形查

15、询:P96-P97 程序录入: 建立一个类库GisFunctionality,在其中输入函数P103(2)、P104(2)、P105(5),自定义圆查询的实现,程序实现机制和自定义多边形查询属性一致。 程序结构是:响应类、支持类、图形转换类、弹出网页。,响应类,IdentifyCircle类 public class IdentifyCircle : IMapServerToolAction void IMapServerToolAction.ServerAction(ToolEventArgs args) Map map = args.Control as Map; CircleEventA

16、rgs circleArgs = (CircleEventArgs)args; Polygon mapPoly = GeometryHelper.GetMapPolygon(map, circleArgs); IdentifyHelper.Identify(map, mapPoly); ,需要使用类的介绍,GraphicsPath类,表示一系列相互连接的直线和曲线。 GraphicsPath. Flatten(),将此路径中的各段曲线转换成相连的线段序列。 Matrix类,是一个矩阵类, Matrix .Translate()方法用于实现一个矩阵转换。,public static ESRI.A

17、rcGIS.ADF.Web.Geometry.Polygon GetMapPolygon( Map map, CircleEventArgs circleArgs) System.Drawing.Point screenPointCenter = new System.Drawing.Point( (int)circleArgs.CenterPoint.X,(int)circleArgs.CenterPoint.Y); System.Drawing.Point screenPointBrink = new System.Drawing.Point( (int)circleArgs.Center

18、Point.X, (int)circleArgs.CenterPoint.Y + (int)circleArgs.Radius); ,从屏幕坐标转换到地图坐标 Point mapPointCenter = Point.ToMapPoint(screenPointCenter, map.Extent, (int)map.Width.Value, (int)map.Height.Value); Point mapPointBrink = Point.ToMapPoint(screenPointBrink, map.Extent, (int)map.Width.Value, (int)map.Hei

19、ght.Value); 得到地图坐标中的半径 double radius = Math.Sqrt( (mapPointCenter.X - mapPointBrink.X) * (mapPointCenter.X - mapPointBrink.X) +(mapPointCenter.Y - mapPointBrink.Y)*(mapPointCenter.Y - mapPointBrink.Y);,思路:以圆心为中心画一个椭圆,椭圆边上分为若干段,再将地图上的点集合,集中到地图上的线,再到地图上的多边形。,GraphicsPath gpath = new GraphicsPath(); gp

20、ath.AddEllipse(float)(mapPointCenter.X - radius), (float)(mapPointCenter.Y - radius), (float)(2 * radius), (float)(2 * radius); Matrix translateMatrix = new Matrix(); translateMatrix.Translate(0, 0); float flattening = (float)(radius / 1000); gpath.Flatten(translateMatrix, flattening);,PointCollecti

21、on pc = new PointCollection(); foreach (System.Drawing.PointF dpnt in gpath.PathPoints) pc.Add(new ESRI.ArcGIS.ADF.Web.Geometry.Point(dpnt.X, dpnt.Y); Ring ring = new Ring(); ring.Points = pc; RingCollection rings = new RingCollection(); rings.Add(ring); Polygon mapPoly = new Polygon(); mapPoly.Rings = rings; return mapPoly;,课堂实践,自定义矩形查询:P93-P96 自定义多边形查询:P96-P97 程序录入: 建立一个类库GisFunctionality,在其中输入函数P103(2)、P104(2)、P105(5),

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1