/// <summary> /// 在给定的点下,查询所有的活动的shapefile层 /// Queries all of the active shapefile layers for any within the specified tolerance of the given point. /// </summary> /// <param name="ProjX">要查询的相对于地图的x点坐标</param> /// <param name="ProjY">要查询的相对于地图的y点坐标</param> /// <param name="Tolerance">在所查询点坐标周围,允许的距离</param> /// <returns>Returns an <c>IdentifiedLayers</c> object containing query results.</returns> public MapWinGIS.Interfaces.IdentifiedLayers Identify(double ProjX, double ProjY, double Tolerance) { MainProgram.IdentifiedShapes identifyshpfile; MainProgram.IdentifiedLayers ilyr = new MainProgram.IdentifiedLayers(); int i, j; MapWinGIS.Shapefile shpfile; object o, res = null; MapWinGIS.Extents box; int count = Program.frmMain.MapMain.NumLayers; for (i = 0; i < count; i++) //遍历每一个图层 { int lyrHandle = Program.frmMain.MapMain.get_LayerHandle(i); if (Program.frmMain.MapMain.get_LayerVisible(lyrHandle)) //是可见的图层 { o = Program.frmMain.MapMain.get_GetObject(lyrHandle); if (o is MapWinGIS.Shapefile) //获取是shapefile类型的图层 { shpfile = (MapWinGIS.Shapefile)o; o = null; box = new MapWinGIS.Extents(); box.SetBounds(ProjX, ProjY, 0, ProjX, ProjY, 0); if (shpfile.SelectShapes(box, Tolerance, MapWinGIS.SelectMode.INTERSECTION, ref res)) //搜索该点,结果存在res中 { identifyshpfile = new MainProgram.IdentifiedShapes(); Array arr; arr = (Array)res; //得到在该点下的所有shape的索引集合 for (j = 0; j < arr.Length; j++) { identifyshpfile.Add((int)(arr.GetValue(j))); } ilyr.Add(identifyshpfile, lyrHandle); } } } } return(ilyr); }