如过想用ArcGIS Explorer实现空间查询的功能,需要对ArcGIS Explorer所支持的图层有所了解。下面想大家介绍一下ArcGIG Explorer所支持的图层。
图层大致分为两种:
一、FeatureLayer,支持所有可以从本地加载的数据,例如:Shapefile、Personal GeoDatabase、ArcSDE GeoDatebase……。
二、ServiceLayer,支持从服务器发布的地图服务,例如:GlobeServer、ImageServer、MapServer、Ims、StreetMap、Wms。
下面就想大家介绍一下如何根据这两种类型的图层进行查询。
FeatureLayer的查询分为两种:一种是基于Table的查询,也就是属性查询。另一种是基于图形,也就是范围查询。
实现FeatureLayer的Table查询的代码:
{
MapDisplay mapDisplay =ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
FeatureLayer fl =mapDisplay.Map.FindByName(“E.G. 1: Mountains”) as FeatureLayer;
int currentRowCount =fl.Table.GetRows().Count; //(562)
fl.QueryDefinition = “Type = “Munro”";
int newRowCount = fl.Table.GetRows().Count;//(285)
FeatureLayer flOriginal =mapDisplay.Map.FindByName(“E.G. 2: Mountains”) as FeatureLayer;
FeatureLayer flNew = flOriginal.Clone();
datasource
if (!flNew.Connect())
return;
flNew.QueryDefinition = “Type =“Munro”";
flNew.Name = flOriginal.Name + ” (Type =“Munro”)”;
mapDisplay.Map.ChildItems.Add(flNew)
}
实现FeatureLayer范围查询的代码:
ReadOnlyCollection<FeatureLayer>layers = _map.GetMapItems<FeatureLayer>();
foreach (FeatureLayer fl in layers)
{
layer = fl;
}
Polygon polygon = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.TrackPolygon();
try
{
RowCollection rowCollection = layer.Table.Search(new Filter(polygon,FilterSearchOptions.Intersects));
TableBindingAdapter tableBindingAdapter = newTableBindingAdapter(rowCollection);
tableBindingAdapter.UseColumnAliasNames = true;
tableBindingAdapter.UseCodedValueDomains = true;
tableBindingAdapter.Fill();
ResultForm. resultsForm. = new ResultForm(tableBindingAdapter);
resultsForm.ShowDialog();
}
catch (NullReferenceException)
{
System.Windows.Forms.MessageBox.Show(“No features were selected. Please tryagain.”);
}