MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();
Selection isf=MapInfo.Engine.Session.Current.Selections[0];
SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("siteId like '%" + test + "%'");
MapInfo.Data.IResultSetFeatureCollection result=MapInfo.Engine.Session.Current.Catalog.Search(this.tableName,si);
既然是Collection,那就是可以枚举的
foreach(Feature f in table)
{
...
}
string sef = "";//字段值
string strTable = "";//表名
MapInfo.Data.QueryFilter filter = new MapInfo.Data.SqlExpressionFilter(sef);
MapInfo.Data.QueryDefinition qd = new MapInfo.Data.QueryDefinition(filter, "*");
MapInfo.Data.SearchInfo si = new MapInfo.Data.SearchInfo(null, qd);
MapInfo.Data.IResultSetFeatureCollection fc = null;
if (MapInfo.Engine.Session.Current.Catalog.GetTable(strTable) != null)
{
fc=MapInfo.Engine.Session.Current.Catalog.Search(strTable,si);
}
if (fc != null)
{
if (fc.Envelope != null)//Envelope 类 表示与坐标系封装的矩形。从 Geometry 派生。Envelope 类从 Geometry 派生,表示封装在坐标系的矩形。Envelope 类的一项主要作用就是封装作为 Geometry 的 Bounds (Minimum Bounding Rectangle)。Envelope 从 Geometry.Envelope 属性返回。
{
this.GetMapObj().SetView(fc.Envelope);
int kil = Convert.ToInt32(this.DropDownList_Dis.SelectedItem.Text);
this.GetMapObj().Zoom = new MapInfo.Geometry.Distance(kil, DistanceUnit.Kilometer);
Map map = GetMapObj();
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Style.LineStyle = new MapInfo.Styles.SimpleLineStyle(new MapInfo.Styles.LineWidth(7, MapInfo.Styles.LineWidthUnit.Pixel), 2, System.Drawing.Color.Red);
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Add(fc);
MapInfo.Geometry.DPoint dpt1 = fc.Envelope.GeometricCentroid;
}
}