MapXtreme的各种查找

// Using SQL

command.CommandText = "Select Obj From States Where state = ‘NY’;

FeatureGeometry nyGeom = command.ExecuteScalar() as FeatureGeometry;

command.CommandText =

"SELECT * FROM Cities WHERE Obj within @newyork";

command.Parameters.Add("@newyork", nyGeom);

MIDataReader reader = command.ExecuteReader();

// or… to get a FeatureCollection

IFeatureCollection fc = command.ExecuteFeatureCollection();

// Using Features

Feature fNY = catalog.SearchForFeature("States",

SearchInfoFactory.SearchWhere("state='NY'"));

SearchInfo si = SearchInfoFactory.SearchWithinFeature(fNY,

ContainsFilter.ContainsType.Centroid);

IDynamicFeatureCollection dfc =

catalog.Search("Cities", si) as IDynamicFeatureCollection;

Console.Out.WriteLine(

"There are {0} cities whose centroid is within NewYork."

dfc.Count);

 

Feature fDEU = _catalog.SearchForFeature

("europe", MapInfo.Data.SearchInfoFactory.SearchWhere

("Country='DEU'"));

SearchInfo si =

MapInfo.Data.SearchInfoFactory.SearchIntersectsFeature

(fDEU, IntersectType.Geometry);

IResultSetFeatureCollection fc =

_catalog.Search("europe", si);

 

IResultSetFeatureCollection fc =

_catalog.Search("europe", si);

MapInfo.FeatureProcessing.FeatureProcessor fp =

new MapInfo.FeatureProcessing.FeatureProcessor();

Feature f = fp.Combine(fc);

si = MapInfo.Data.SearchInfoFactory.SearchWithinFeature

(f, ContainsType.Centroid);

MultiResultSetFeatureCollection mfc =

_catalog.Search(_catalog.EnumerateTables

(TableFilterFactory.FilterMappableTables()), si);

 

Distance d =

MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance

(_map, 3);

SearchInfo si =

MapInfo.Data.SearchInfoFactory.SearchNearest

(dpt1, _map.GetDisplayCoordSys(), d);

IResultSetFeatureCollection fc =

_catalog.Search("uscty_1k", si);

 

Feature fFlorida = _catalog.SearchForFeature("usa",

MapInfo.Data.SearchInfoFactory.SearchWhere("State='FL'"));

SearchInfo si =

MapInfo.Data.SearchInfoFactory.SearchWithinGeometry

(fFlorida, ContainsType.Centroid);

IResultSetFeatureCollection fc =

MapInfo.Engine.Session.Current.Catalog.Search

("uscty_1k", si);

 

 

加点的一般方法:
   Catalog _catalog=MapInfo.Engine.Session.Current.Catalog;

   MapInfo.Geometry.Point pt = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(),dp);
   MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle();
   vs.PointSize = 8;
   vs.Color = Color.DarkMagenta;
   
   Feature ft2=new Feature(tb.TableInfo.Columns);
   string strID=DateTime.Now.ToString("hhmmss");
   ft2.Geometry=pt;
   ft2["f_name"]=PointName;
   ft2["ID"]=strID;
   ft2["MI_Style"]=vs;

   tb.InsertFeature(ft2);

   Feature ft3=MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tb.Alias,MapInfo.Data.SearchInfoFactory.SearchWhere("ID="+strID+" and f_name='"+PointName+"'"));

   return ft3.Key.Value;

posted on 2005-09-08 11:51  海边拾贝  阅读(715)  评论(0)    收藏  举报