ArcObjects GIS应用开发-基于C#chap.7
- 格式:ppt
- 大小:1.25 MB
- 文档页数:124


ArcGlobe10+C#开发基础Wrote by Neil 2011-11-151、建立基本3D场景打开VS开发工具,新建一个窗体项目,打开工具箱中ArcGIS工具栏。
将TOCControl、ToolbarControl、GlobeControl、及LicenseControl四个控件拖放到同一个窗体Form1中。
设置控件关联。
右键单击toolbarcontrol工具条控件,在弹出的菜单中选择“属性”,弹出窗口在Buddy下拉框中选择axGlobeControl1,其它默认。
选中Items标签单击Add按钮,添加需要用到的菜单按钮,如打开、平移、飞行等。
添加完成后单击“确认”退出。
右键单击toc控件,在弹出的菜单中选择“属性”,弹出属性窗口。
在Buddy下拉框中选择axGlobeControl1,其它默认。
右键单击globe控件,在弹出菜单中选择“属性”弹出属性窗口。
在Globe Document 框中选择准备好的3D数据*.3dd。
这样,一个基本的Arcglobe三维场景就实现了。
2、实现标签定位功能添加一个listbox、textbox及button控件标签定位的基本思路是,点击“添加标签”按钮,将当前场景状态保存到一个*.3mk文件中,同时将标签的名字也保存到一个*.xml文件,查询*.xml文件数据,添加到listbox,通过选择listbox的记录来查找对应的场景;private string str_BookMarkFileDocName;private string XMLpath = Application.StartupPath + "\\bookstore.xml";private void MainForm_Load(object sender, EventArgs e){m_globeControl = axGlobeControl1.Object as IGlobeControl;//cast the GlobeViewUtil from the GlobeCameram_globeViewUtil = m_globeControl.GlobeCamera as IGlobeViewUtil;//加¨®载?标À¨º签?保À¡ê存ä?文?件tstr_BookMarkFileDocName = Application.StartupPath + "\\GISGlobe.3mk";ReXML();}//将?记?录?保À¡ê存ä?到Ì?xml文?件tprivate void WrXML(string mark) {//string XMLpath = Application.StartupPath + "\\bookstore.xml";XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(XMLpath);XmlNode root = xmlDoc.SelectSingleNode("bookMark");XmlElement son = xmlDoc.CreateElement("rootMark");son.InnerText = mark;//XmlElement xesub1 = xmlDoc.CreateElement("title");//xesub1.InnerText =mark;root.AppendChild(son);xmlDoc.Save(XMLpath);}//读¨¢取¨?xml文?件tprivate void ReXML() {listBox2.Items.Clear();XmlDocument document = new XmlDocument();document.Load(XMLpath);XmlNode xmlroot = document.DocumentElement;//添¬¨ª加¨®根¨´节¨²点Ì?//listBox2.Items.Add(.ToString());recursiveLoadXml(xmlroot);}private void recursiveLoadXml(XmlNode xnode){foreach (XmlNode childNode in xnode.ChildNodes){if (childNode.NodeType == XmlNodeType.Element){string strList = ;if (childNode.Attributes.Count > 0){strList += ":" + childNode.Attributes[0].Value;}//this.listBox2.Items.Add(strList);recursiveLoadXml(childNode);}else if (childNode.NodeType == XmlNodeType.Text){this.listBox2.Items.Add(childNode.Value);}}}private void listBox2_SelectedIndexChanged(object sender, EventArgs e){string mark = listBox2.SelectedItem.ToString();ZoomTo3DBookmark(mark, str_BookMarkFileDocName);}单击图层,获取属性信息//添加引用using ESRI.ArcGIS.Geodatabase,using ESRI.ArcGIS.Cartoprivate IFeature FindFeature(IPoint pPoint, IFeatureLayer pFeatureLayer, IGlobe pGlobe) { IEnvelope pEnvelope;ISpatialFilter pSpatialFilter;//IEnumLayer pEnumLayer;IFeatureClass pFeatureClass;IFeatureCursor pFeatureCursor;IFeature pFeature;IFeature pFFeature = null;string ShapeFieldName;if(pFeatureLayer.FeatureClass==null)return null;pEnvelope = pPoint.Envelope;pEnvelope.Expand(0.01,0.01,false);pSpatialFilter = new SpatialFilter();pSpatialFilter.Geometry = pEnvelope;pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIndexIntersects;ShapeFieldName = pFeatureLayer.FeatureClass.ShapeFieldName;pSpatialFilter.GeometryField = pFeatureLayer.FeatureClass.ShapeFieldName;pFeatureClass = pFeatureLayer.FeatureClass;pFeatureCursor = pFeatureClass.Search(pSpatialFilter,true);pFeature = pFeatureCursor.NextFeature();if (pFeature != null){pFFeature = pFeature;}return pFFeature;}frmIdentify m_frmIdentify = new frmIdentify();private void axGlobeControl1_OnDoubleClick(object sender,IGlobeControlEvents_OnDoubleClickEvent e){axGlobeControl1.GlobeDisplay.IsNavigating = false;IHit3DSet pHit3DSet;axGlobeControl1.GlobeDisplay.LocateMultiple(axGlobeControl1.GlobeDisplay.ActiveViewer,e.x,e.y,true,f alse,true,false,out pHit3DSet);pHit3DSet.OnePerLayer();if (pHit3DSet.Hits.Count == 0) {MessageBox.Show("当前没有选择任何要素?");return;}IDisplay3D pDisplay3D = (IDisplay3D)axGlobeControl1.Globe.GlobeDisplay;m_frmIdentify.pHit3DSet = pHit3DSet;m_frmIdentify.pDisplay3D = pDisplay3D;m_frmIdentify.InitData();m_frmIdentify.Location = System.Windows.Forms.Cursor.Position;m_frmIdentify.ShowDialog();m_frmIdentify.Focus();}在弹出窗口(frmIdentify)中的代码为:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Analyst3D;using ESRI.ArcGIS.GlobeCore;namespace GlobeControlApplication1{public partial class frmIdentify : Form{public IHit3DSet pHit3DSet;public IDisplay3D pDisplay3D;public frmIdentify(){InitializeComponent();}private void frmIdentify_Load(object sender, EventArgs e){}public void InitData(){listBox1.Items.Clear(); //清?除y listBox1 的Ì?内¨²容¨YlistView1.Items.Clear(); //清?除y listView1 的Ì?内¨²容¨Yif (pHit3DSet == null)return;for (int i = 0; i < pHit3DSet.Hits.Count; ){IHit3D pHit3D = (IHit3D)pHit3DSet.Hits.get_Element(i);IPoint pPoint = pHit3D.Point;ILayer pLayer = (ILayer)pHit3D.Owner;//判D断?是º?否¤?为a要°a素?图ª?层?if (pLayer is IFeatureLayer){IFeature pFeature = (IFeature)pHit3D.Object;listBox1.Items.Add();//在¨²列¢D表À¨ª中D添¬¨ª加¨®图ª?层?名?//for (int j = 0; j < pFeature.Fields.FieldCount; j++)// strHits += "\n :êo" + pFeature.Fields.get_Field(j).Name + pFeature.get_Value(j).ToString();pDisplay3D.AddFlashFeature(pFeature.Shape);i++; //计?数ºyi加¨®1}else{pHit3DSet.Hits.Remove(i);}}pDisplay3D.FlashFeatures();}private void listBox1_SelectedIndexChanged(object sender, EventArgs e){listView1.Items.Clear();//消?除y listView1 的Ì?内¨²容¨YIHit3D pHit3D = (IHit3D)pHit3DSet.Hits.get_Element(listBox1.SelectedIndex);IFeature pFeature = (IFeature)pHit3D.Object;for (int j = 0; j < pFeature.Fields.FieldCount; j++){ListViewItem li = new ListViewItem();li.SubItems.Clear();li.SubItems[0].Text = pFeature.Fields.get_Field(j).Name;li.SubItems.Add(pFeature.get_Value(j).ToString());listView1.Items.Add(li);}pDisplay3D.AddFlashFeature(pFeature.Shape);pDisplay3D.FlashGeometry(pHit3D.Owner, pHit3D.Object);}}}单击按钮,实现定位到图层public void ZoomToGlobeLayer(ESRI.ArcGIS.GlobeCore.IGlobe globe, System.Int32 layerIndex) {ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay;ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = globeDisplay.ActiveViewer;ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera;ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera =(ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; // Explicit CastESRI.ArcGIS.Analyst3D.IScene scene = (ESRI.ArcGIS.Analyst3D.IScene)globe; // Explicit CastESRI.ArcGIS.Carto.ILayer layer = scene.get_Layer(layerIndex);ESRI.ArcGIS.Geometry.IEnvelope envelope = layer.AreaOfInterest.Envelope;globeCamera.SetToZoomToExtents(envelope, globe, sceneViewer);private void button2_Click(object sender, EventArgs e){ESRI.ArcGIS.GlobeCore.IGlobe globe = this.axGlobeControl1.Globe;ZoomToGlobeLayer(globe, 0);//第二个参数为图层索引编号}。
ArcGIS Engine开发GIS应用 VCarcgisengine开发gis应用-vc利用arcgisengine、和windows控件开发gis应用此过程表明适宜那些采用.net创建和部署应用领域的开发者,它叙述了采用arcgis控件创建和部署应用领域的方法和步骤。
你可以在下面的目录下找到相应的样例程序:\\developerkit\\samples\\developer_guide_scenarios\\arcgis_engine\\building_an_arcgis_control_application\\map_viewer注:arcgis样例程序不包含在arcgisengine开发工具包“典型”安装方式中。
如果你没有安装它们,则可以重新运行开发工具包安装向导,选择“定制”或“修改”方式,并选择软件开发包下的样例项进行安装。
一、项目描述在谷歌中读取和内嵌arcgis控件。
?向pagelayoutcontrol和mapcontrol中读取图形文档。
?设置toolbarcontrol和toccontrol的存取控件。
?处置窗口翻转。
向toolbarcontrol添加arcgisengine命令和工具。
?创建弹出式菜单在toccontrol中管理标签编辑?在mapcontrol中绘制图形。
为mapcontrol、pagelayoutcontrol和toolbarcontrol创建定制工具。
?用户化toolbarcontrol。
在windows操作系统中部署应用领域。
二、详述体)访问。
每个控件对象及其功能可以与其他esriarcobjects和自定义控件组合使用,创建用户化的客户应用程序。
此方案就是采用了c#和两种语言建立,但以下技术同时实现分散女性主义于c#方案。
许多开发者可能会感觉用更难受,那是因为他们已经比较熟识visualbasic6.0代码,然而,对于java和c++程序员来说,他们将可以真的对c#程序语言的语法更熟识。