物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 421|回复: 0

MapXtreme2004GPS小车移动应用程序

[复制链接]
发表于 2013-3-13 21:09:18 | 显示全部楼层 |阅读模式
GPS小车移动应用程序
//用于desktop部署

private void btnInitializeObjects_Click(object sender, System.EventArgs e)
{
Catalog Cat = MapInfo.Engine.Session.Current.Catalog;

//创建临时层
TableInfoMemTable tblInfoTemp = new TableInfoMemTable("Animation");
Table tblTemp = Cat.GetTable("Animation");
if (tblTemp != null) //Table exists close it
{
Cat.CloseTable("Animation");
}

tblInfoTemp.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(mapControl1.Map.GetDisplayCoordSys()));
tblInfoTemp.Columns.Add(ColumnFactory.CreateStyleColumn());
tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Name", 40));
tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Dept", 15));
tblInfoTemp.Columns.Add(ColumnFactory.CreateIntColumn("Level"));

tblTemp = Cat.CreateTable(tblInfoTemp);

FeatureLayer lyr = new FeatureLayer(tblTemp);
mapControl1.Map.Layers.Add(lyr);

//创建点-车
FeatureGeometry pt = new MapInfo.Geometry.Point(lyr.CoordSys, new DPoint(-76, 42)) as FeatureGeometry;
CompositeStyle cs = new CompositeStyle(new SimpleVectorPointStyle(37, System.Drawing.Color.Red, 10));
Feature ftr = new Feature(tblTemp.TableInfo.Columns);
ftr.Geometry = pt;
ftr.Style = cs;
ftr["Name"] = "Kelly";
ftr["Dept"] = "Sales";
ftr["Level"] = 3;
tblTemp.InsertFeature(ftr);

FeatureGeometry pt2 = new MapInfo.Geometry.Point(lyr.CoordSys, new DPoint(-119, 34)) as FeatureGeometry;
CompositeStyle cs2 = new CompositeStyle(new SimpleVectorPointStyle(44, System.Drawing.Color.Purple, 10));
Feature ftr2 = new Feature(tblTemp.TableInfo.Columns);
ftr2.Geometry = pt2;
ftr2.Style = cs2;
ftr2["Name"] = "Greg";
ftr2["Dept"] = "Marketing";
ftr2["Level"] = 2;
tblTemp.InsertFeature(ftr2);
}

// 对于表中所有对象的移动
private void timer1_Tick(object sender, System.EventArgs e)
{
Catalog cat = MapInfo.Engine.Session.Current.Catalog;
Table tbl = cat.GetTable("Animation");
if (tbl != null)
{
//更新点的位置
tbl.BeginAccess (MapInfo.Data.TableAccessMode.Write );
foreach (Feature fcar in tbl)
{
fcar.Geometry.GeometryEditor.OffsetByXY(0.5,0,MapInfo.Geometry.DistanceUnit.Degree,MapInfo.Geometry.DistanceType.Spherical);
fcar.Geometry.EditingComplete();
fcar.Update();
}
tbl.EndAccess ();
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-5-13 13:42 , Processed in 0.059614 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表