MapXtreme 2005 基础代码
2008-06-18 11:23
309 查看
1、遍历所有要素
foreach(MapInfo.Data.Feature f in _FeatureLayer.Table)
{
// do something with the Feature
}
2、点查询
MapInfo.Geometry.DPoint point = new MapInfo.Geometry.DPoint(-100, 40);
MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
connection.Open();
MapInfo.Data.MICommand command = connection.CreateCommand();
command.CommandText = "Select * from USA where MI_Point(@x, @y, @cs) within obj";
command.Parameters.Add("@x", point.x);
command.Parameters.Add("@y", point.y);
command.Parameters.Add("@cs", this.mapControl1.Map.GetDisplayCoordSys());
command.Prepare();
MapInfo.Data.IResultSetFeatureCollection irfc = command.ExecuteFeatureCollection();
command.Dispose();
connection.Close();
3.返回所有列
MapInfo.Data.Table USATable= MapInfo.Engine.Session.Current.Catalog.GetTable("usa");
string[] s = new string[1];
s[0] = "*";
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("State = 'NY'");
si.QueryDefinition.Columns = s;
MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(USATable.Alias, si);
int count = 0;
int ColCount = USATable.TableInfo.Columns.Count;
foreach (MapInfo.Data.Feature f in irfc)
{
count = 0;
while (count < ColCount)
{
MapInfo.Data.Column c = irfc.Columns[count];
this.listBox1.Items.Add(f[c.ToString()]).ToString();
count++;
}
}
4、返回查询结果
MapInfo.Data.Table USATable= MapInfo.Engine.Session.Current.Catalog.GetTable("usa");
string[] s = new string[1];
s[0] = "*";
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("State = 'NY'");
si.QueryDefinition.Columns = s;
MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(USATable.Alias, si);
int count = 0;
int ColCount = USATable.TableInfo.Columns.Count;
foreach (MapInfo.Data.Feature f in irfc)
{
count = 0;
while (count < ColCount)
{
MapInfo.Data.Column c = irfc.Columns[count];
this.listBox1.Items.Add(f[c.ToString()]).ToString();
count++;
}
}
foreach(MapInfo.Data.Feature f in _FeatureLayer.Table)
{
// do something with the Feature
}
2、点查询
MapInfo.Geometry.DPoint point = new MapInfo.Geometry.DPoint(-100, 40);
MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
connection.Open();
MapInfo.Data.MICommand command = connection.CreateCommand();
command.CommandText = "Select * from USA where MI_Point(@x, @y, @cs) within obj";
command.Parameters.Add("@x", point.x);
command.Parameters.Add("@y", point.y);
command.Parameters.Add("@cs", this.mapControl1.Map.GetDisplayCoordSys());
command.Prepare();
MapInfo.Data.IResultSetFeatureCollection irfc = command.ExecuteFeatureCollection();
command.Dispose();
connection.Close();
3.返回所有列
MapInfo.Data.Table USATable= MapInfo.Engine.Session.Current.Catalog.GetTable("usa");
string[] s = new string[1];
s[0] = "*";
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("State = 'NY'");
si.QueryDefinition.Columns = s;
MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(USATable.Alias, si);
int count = 0;
int ColCount = USATable.TableInfo.Columns.Count;
foreach (MapInfo.Data.Feature f in irfc)
{
count = 0;
while (count < ColCount)
{
MapInfo.Data.Column c = irfc.Columns[count];
this.listBox1.Items.Add(f[c.ToString()]).ToString();
count++;
}
}
4、返回查询结果
MapInfo.Data.Table USATable= MapInfo.Engine.Session.Current.Catalog.GetTable("usa");
string[] s = new string[1];
s[0] = "*";
MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("State = 'NY'");
si.QueryDefinition.Columns = s;
MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(USATable.Alias, si);
int count = 0;
int ColCount = USATable.TableInfo.Columns.Count;
foreach (MapInfo.Data.Feature f in irfc)
{
count = 0;
while (count < ColCount)
{
MapInfo.Data.Column c = irfc.Columns[count];
this.listBox1.Items.Add(f[c.ToString()]).ToString();
count++;
}
}
相关文章推荐
- MapXtreme 2005 学习心得 一些基础函数代码(四)
- MapXtreme 2005 一些基础函数代码(四)
- MapXtreme 2005 学习心得 一些基础函数代码(四)
- MapXtreme 2005 学习心得 一些基础函数代码(四)
- MapXtreme 2005 学习心得 相关代码知识(三)
- MapXtreme 2005 相关代码知识(三)
- MapXtreme 2005 学习心得 相关代码知识(三)
- MapXtreme2005 自带的文件夹MapXtremeWebResources中的Interaction.js中的缺陷代码
- WEB代码的一些基础知识(一)
- jni使用基础(六)之在c代码中使用logcat
- Unreal4 基础代码Link错误
- greenDao基础代码
- WEB代码的一些基础知识(四)
- Java 定时器(Timer,TimerTask)基础入门实例代码
- java基础35 天敲敲代码
- MapXtreme 2005 开发经验和技巧总结
- 代码干货 | Javascript基础学习之基本语法
- 常用IPHONE 编程 基础代码
- SQL Server 2005基础教程
- 编程珠玑 - 代码调优法则 - 基础篇