目标:
根据查询语句实现图层信息查询
准备工作:
1.Windows XP sp2中/英文版
2.Visual Studio 2005中/英文版
3.ArcGIS Server 9.2(我打上了sp2补丁),创建一个ArcGIS Server服务,Map Server属性中更改Pooling,使用池化连接方式,Progresses选择“In a seperate process for each instance(high isolation)”,我的服务为“World”
4.利用vs2005创建一个模板server应用--Web Mapping Application,并更改MapResourceManager属性
![](/Article/UploadFiles/200901/20090113102702691.gif)
![](/Article/UploadFiles/200901/20090113102702165.gif)
这样我们可以测试程序看是否能够正常运行,启动调试看到如下结果:
![](/Article/UploadFiles/200901/20090113102702643.gif)
代码实现:
我们要完成的工作是对图层属性信息的查询,首先在页面左侧添加一个新的panel,左侧的Tasks、Results等都是放置在panel之中,在这个新的panel中分别添加TreeViewPlus、TextBox、Button三个控件,TextBox输入查询条件,Button确定查询, TreeViewPlus显示结果,在设计试图中浏览效果如下:
![](/Article/UploadFiles/200901/20090113102702771.gif)
双击“Query”Button,编写点击事件。
![](/Article/UploadFiles/200901/20090113102702212.gif)
protected
void cmdQuery_Click(object sender, EventArgs e)
![](/Article/UploadFiles/200901/20090113102702164.gif)
![](/Article/UploadFiles/200901/20090113102702460.gif)
![](/Article/UploadFiles/200901/20090113102702300.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702109.gif)
Query方法实现了对图层属性信息的查询。
![](/Article/UploadFiles/200901/20090113102702212.gif)
void Query(ESRI.ArcGIS.ADF.Web.Geometry.Geometry geometry)
![](/Article/UploadFiles/200901/20090113102702164.gif)
![](/Article/UploadFiles/200901/20090113102702460.gif)
![](/Article/UploadFiles/200901/20090113102702300.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisfunctionality in func_enum)
![](/Article/UploadFiles/200901/20090113102702451.gif)
![](/Article/UploadFiles/200901/20090113102702326.gif)
![](/Article/UploadFiles/200901/20090113102702300.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
bool supported = false;
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702451.gif)
![](/Article/UploadFiles/200901/20090113102702326.gif)
![](/Article/UploadFiles/200901/20090113102702300.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702451.gif)
![](/Article/UploadFiles/200901/20090113102702326.gif)
![](/Article/UploadFiles/200901/20090113102702300.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
new System.Data.DataSet();
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702958.gif)
![](/Article/UploadFiles/200901/20090113102702458.gif)
![](/Article/UploadFiles/200901/20090113102702458.gif)
![](/Article/UploadFiles/200901/20090113102702458.gif)
![](/Article/UploadFiles/200901/20090113102702109.gif)
运行程序,text box中输入“CNTRY_NAME LIKE 'A%'”,查询结果:
![](/Article/UploadFiles/200901/20090113102702901.gif)
这样这个小程序就完成了,在server中实现了对图层属性信息的查询,现在我们需要进行更多的考虑:
第一,考虑web控件、 functionality、datasource、resource、resourcemamager之间的关系,代码中多次对它们的关系进行了描述,用文档中的一幅图可以概括整个框架,这篇文章对此进行了阐述--《ArcGIS Server .Net Web ADF体系结构》。
![](/Article/UploadFiles/200901/20090113102702275.gif)
第二,程序中使用的mxd仅仅包含一个world图层,因此对图层进行遍历的过程中只需获得第一图层的ID,如果指定图层名,可以在lnames得到所需的图层进行查询。
第三,程序实现的查询方式相当简单,在text box中输入原始的sql来完成where语句,只仅仅是一个测试,一般我们会屏蔽掉sql相关的关键字,提供多个text box或dropdownlist供用户选择进行字段查询。
第四,如果查询信息量不大,返回结果数量不多,完全可以考虑ajax来完成页面请求,不论是速度还是用户体验都会得到提高。
第五,通过程序可以看到,查询结果保存在一个datatable中,这极大的方便了server查询和.net的无缝连接,直接将结果和TreeViewPlus绑定,换成其他的visual studio控件也没问题。
只要整个框架思路清晰了,查询功能的实现其实很简单,这也是途径2开发方式的一个例子,可以看出ArcGIS Server ADF给开发提供了很多便利,和ArcIMS相比开发难度相当,多看看文档和ADF OMD图可以让我们对ArcGIS Server ADF开发有更多的了解,记住,这只是server开发的起步。