获取对象的矩形范围
using MapGIS.GeoObjects.Geometry; using MapGIS.GeoDataBase; Server svr = null; IVectorCls VectorCls = null; Rect _Rect = null; //变量初始化 svr = new Server(); //连接数据源,打开数据库 bool rtn = svr.Connect("MapGISLocal", "", ""); if (rtn) { DataBase gdb = svr.OpenGDB("world"); //打开简单要素类 VectorCls = gdb.GetXClass(XClsType.SFCls) as IVectorCls; VectorCls.Open("水系.WP", 0); //获取ID=2的对象的矩形范围 _Rect = VectorCls.GetRect(2); if (_Rect != null) { MessageBox.Show("获取范围:"+_Rect.XMin+","+_Rect.YMin+"至"+_Rect.XMax+","+_Rect.YMax); } else { MessageBox.Show("获取范围失败"); } //关闭类、数据库、断开数据源 VectorCls.Close(); gdb.Close(); svr.DisConnect(); }
本博有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。