获取对象的矩形范围

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();
}

 

posted @ 2022-03-02 15:16  恋上微笑的天使  阅读(46)  评论(0编辑  收藏  举报