读书人

地图Info表操作,地图Xtreme2008 VS c

发布时间: 2012-09-07 10:38:15 作者: rapoo

mapInfo表操作,mapXtreme2008 VS c#
查询oracle数据表

建立临时表存储筛选后的数据

建立专题图

private void OpenOrclTab(string tabname)
{
try
{
TableInfoServer ti = new TableInfoServer(tabname);
ti.ConnectString = mapconstr;
ti.Query = "Select * From " + tabname;
ti.Toolkit = ServerToolkit.Oci;
ti.CacheSettings.CacheType = CacheOption.Off;
Table tbl = connection.Catalog.OpenTable(ti);
FeatureLayer MyLayer = new FeatureLayer(tbl);
int wz = MainMap.Map.Layers.Add(MyLayer);
//MainMap.Map.Layers.Insert(0, MyLayer);




//据管理公司不同渲染专题图
if ("MANAGEAREA".Equals(tabname))
{
//hj
MapInfo.Data.TableInfoMemTable tb2 = new MapInfo.Data.TableInfoMemTable("tempTable");//构建新的内存表pathTable
//复制表结构
TableInfo tInfo = MyLayer.Table.TableInfo;
int count = tInfo.Columns.Count;

//CODE Decimal (14, 0) ;
//ALIAS Char (128) ;
//MANAGER_ID Decimal (14, 0) ;
//MANAGE Char (50) ;
//MODI Char (50) ;
// MI_PRINX Decimal (12, 0) ;

tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateDecimalColumn(tInfo.Columns[0].ToString(), 14, 0));
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn(tInfo.Columns[1].ToString(), 128));
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateDecimalColumn(tInfo.Columns[2].ToString(), 14, 0));
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn(tInfo.Columns[3].ToString(), 50));
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn(tInfo.Columns[4].ToString(), 50));
//style
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
//id
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateDecimalColumn(tInfo.Columns[6].ToString(), 12, 0));
//geo
tb2.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(tInfo.Columns[7].ToString(), MyLayer.Map.GetDisplayCoordSys()));
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(tb2);




MIDataReader mr = MyLayer.Table.ExecuteReader();
int i, n = mr.FieldCount;
while (mr.Read())
{
object o = mr.GetValue(3);
if (o.ToString().Equals(DBConnection.key))
{
table.InsertFeature(mr.Current);
}
else
{
}
}
FeatureLayer newMyLayer = new FeatureLayer(table);
wz = MainMap.Map.Layers.Add(newMyLayer);
mr.Close();
IndividualValueTheme thm = new IndividualValueTheme(newMyLayer, "MANAGE", "管理单位");
// thm.ModelStyle.AreaStyle;

// Add the theme to the FeatureStyleModifiers list
newMyLayer.Modifiers.Append(thm);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

读书人网 >VSTS

热点推荐