mapinfo开发 >> MapXtreme开发基础教程五:mapxtreme修改图元位置

最后编辑时间:2021年07月23日 18:05:43

【内容简介】mapxtreme修改图元位置代码如下

1.用这种方式
Catalog cat = MapInfo.Engine.Session.Current.Catalog;
            Table tbl = cat.GetTable("机场");
            if (tbl != null)
            {
                //更新点的位置
                tbl.BeginAccess(MapInfo.Data.TableAccessMode.Write);
                foreach (Feature fcar in tbl)
                {
                    fcar.Geometry.GetGeometryEditor().OffsetByXY(0.5, 0, MapInfo.Geometry.DistanceUnit.Degree, MapInfo.Geometry.DistanceType.Spherical);
                    fcar.Geometry.EditingComplete();
                    fcar.Update();
                }
                tbl.EndAccess();
            }

mapxtreme修改图元位置
2.或者用如下方式
 public   void  SetFeatureLocation(Feature fr,  double  x, double  y)
        {
            if(fr!=null)
            {
                DPoint lastP=fr.Geometry.Centroid;
 
                double stepX=x-lastP.x;
                double stepY=y-lastP.y;
                    
                fr.Geometry.GeometryEditor.OffsetByXY(stepX,stepY,DistanceUnit.Degree,DistanceType.Spherical);
                fr.Geometry.EditingComplete();
                fr.Update();
            }
        }
 


分享到: 豆瓣 新浪微博 百度贴吧 QQ空间 QQ好友
复制链接分享给好友或者自己收藏!这里会及时更新中。。。

相关推荐:
 
QQ
QQ:278325424
咨询热线
18191066384