posts - 77, comments - 54, trackbacks - 0, articles - 0
  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

向地图中加入点程序代码

Posted on 2006-06-01 11:46 东人EP 阅读(839) 评论(3)  编辑 收藏 引用 所属分类: MapInfo


向地图中加入点程序代码
// 由桌面坐标转换为地理坐标 
System.Drawing.PointF DisplayPoint = new PointF(e.X,e.Y);
MapInfo.Geometry.DPoint MapPoint = new MapInfo.Geometry.DPoint();
MapInfo.Geometry.DisplayTransform converter = this.mapControl1.Map.DisplayTransform;
converter.FromDisplay(DisplayPoint, out MapPoint);
this.statusBar1.Text = "Cursor Location: " + MapPoint.x.ToString() + ", " + MapPoint.y.ToString();
MapInfo.Geometry.Point pnt = new MapInfo.Geometry.Point(this.mapControl1.Map.GetDisplayCoordSys(), MapPoint);
Table table = Session.Current.Catalog.OpenTable(@"C:\Map\CHCTY_2K.tab");      

MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle();
MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(null, null, null, vs);      
Feature f = new Feature(pnt, cs);      
//MapInfo.Data.Key k = table.InsertFeature(f);


// 打开需要编辑的表
Table table = Session.Current.Catalog.OpenTable(@"C:\Map\CHCTY_2K.tab");
// 定义列集合 
Columns cols = new Columns();
cols.Add(ColumnFactory.CreateFeatureGeometryColumn(mapControl1.Map.GetDisplayCoordSys()));
cols.Add(ColumnFactory.CreateStringColumn("Place_Name", 40));
cols.Add(ColumnFactory.CreateStringColumn("Country", 40));
cols.Add(ColumnFactory.CreateStringColumn("Latitude", 20));
cols.Add(ColumnFactory.CreateStringColumn("Longitude", 20));
cols.Add(ColumnFactory.CreateStyleColumn());
// 定义图形特征
MapInfo.Geometry.FeatureGeometry fg = new MapInfo.Geometry.Point(mapControl1.Map.GetDisplayCoordSys(), new DPoint(pnt.X, pnt.Y)) as FeatureGeometry;
// 定义图形特征类型
MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle(35, Color.Chocolate, 15);
MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(null, null, null, vs); 
string strLatitude;
string strLongitude;
this.TransformCoordSysToDMS(pnt.X, pnt.Y, out strLongitude, out strLatitude);
// 写入其他信息窗体
InformationForm infoForm = new InformationForm(strLongitude, strLatitude);
infoForm.ShowDialog();
// 为插入的记录付值
object[] sValue = new object[6]{fg, infoForm.Place_Name, infoForm.Country, infoForm.Latitude, infoForm.Longitude, cs};
Feature fe = new Feature(cols, sValue);
table.InsertFeature(fe); 

Feedback

# re: 向地图中加入点程序代码  回复  更多评论   

2006-06-01 21:25 by gyn_tadao
mapinfo是个好东西,不过除了些专业的论坛,的确难得一见。

# re: 向地图中加入点程序代码  回复  更多评论   

2006-06-05 15:18 by yuxon
ding

# re: 向地图中加入点程序代码  回复  更多评论   

2006-06-15 16:59 by 东人EP
大家有啥问题,都可以拿出来讨论呀!!!
只有注册用户登录后才能发表评论。