ArcGIS Explorer SDK开发(二)——空间查询

如过想用ArcGIS Explorer实现空间查询的功能,需要对ArcGIS Explorer所支持的图层有所了解。下面想大家介绍一下ArcGIG Explorer所支持的图层。

        图层大致分为两种:

        一、FeatureLayer,支持所有可以从本地加载的数据,例如:ShapefilePersonal GeoDatabaseArcSDE GeoDatebase……

        二、ServiceLayer,支持从服务器发布的地图服务,例如:GlobeServerImageServerMapServerImsStreetMapWms

        下面就想大家介绍一下如何根据这两种类型的图层进行查询。

       FeatureLayer的查询分为两种:一种是基于Table的查询,也就是属性查询。另一种是基于图形,也就是范围查询。

        实现FeatureLayerTable查询的代码:

{

  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.”);
               }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值