arcengine的一些例子實現(xiàn)

打開mxd文件

OpenFileDialog
axMapControl1.LoadMxFile(pFileName);

打開shp文件

         IWorkspaceFactory pWorkspaceFactory = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(pFilePath, 0);            
         IFeatureWorkspace pFeatureWorkspace= new ShapefileWorkspaceFactory();
        IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName);
        pFeatureLayer = new FeatureLayer();
        pFeatureLayer.FeatureClass = pFeatureClass;
        pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName;
        //ClearAllData();//刪除所有已加載的數(shù)據(jù)
        axMapControl2.Map.AddLayer(pFeatureLayer);

IFeatureWorkspace 接口用于訪問和管理地理數(shù)據(jù)庫中的要素的重要成分 -- 數(shù)據(jù)集
IFeatureWorkspace.OpenFeatureClass 方法打開 workspace 中任何已存在的要素類
IFeatureClass 用于訪問控制要素類行為和屬性的成員
IFeatureClass 接口是獲取和設置要素類屬性的主要接口
IFeatureLayer 接口的第一個屬性 FeatureClass(讀寫,設置或者讀取此 layer 的要素類)
把shp放入Shape工作空間——》通過OpenFeatureClass訪問要素類——》 實例化FeatureLayer添加FeatureClass和Name 最后AddLayer

打開cad文件

把cad放入CadWorkspaceFactory工作空間——》通過OpenFeatureClass訪問要素類——》 實例化FeatureLayer添加FeatureClass和Name 最后AddLayer
IWorkspaceFactory pWorkspaceFactory = new CadWorkspaceFactory();

保存文件

IMapDocument pMapDocument = new MapDocumentClass();
pMapDocument.New(sMxdFileName);
pMapDocument.ReplaceContents(axMapControl1.Map as IMxdContents);
pMapDocument.Save(pMapDocument.UsesRelativePaths, true);

拉框放大

Click事件
pMouseOperate = "ZoomIn"; 和改變鼠標狀態(tài)
OnMouseDown事件
axMapControl1.TrackRectangle(); 創(chuàng)建橡皮條返回IEnvelope
IActiveView 接口的Extent屬性與IEnvelope連接

拉框縮小

拉框范圍為中心,縮小倍數(shù)為:當前視圖范圍/拉框范圍

漫游

axMapControl1.Pan();

拉框選擇

IGeometry geometry = axMapControl1.TrackRectangle();
axMapControl2.Map.SelectByShape(geometry, null, false); Imap接口的SelectByShape方法
formSelection.CurrentMap = axMapControl1.Map; //把地圖對象傳走

距離量算

NewLineFeedbackClass接口
Start //設置起點,開始動態(tài)線繪制
AddPoint //添加當前鼠標點
Display

面積量算

NewPolygonFeedback接口
Display
Start
AddPoint

if (pNewLineFeedback == null)
{
//實例化追蹤線對象
pNewLineFeedback = new NewLineFeedbackClass();
pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay;
//設置起點,開始動態(tài)線繪制
pNewLineFeedback.Start(pPointPt);
dToltalLength = 0;
}
else //如果追蹤線對象不為空,則添加當前鼠標點
{
pNewLineFeedback.AddPoint(pPointPt);
}
//pGeometry = m_PointPt;

放大

IEnvelope接口的Expand
和IActiveView接口的Extent

縮小

IEnvelope接口的Expand
和IActiveView接口的Extent

全圖顯示

axMapControl1.Extent = axMapControl1.FullExtent;

前視圖和后視圖

axMapControl1.ActiveView.ExtentStack;
IExtentStack接口的
Undo();
Redo();

添加圖例

image.png

添加指北針

image.png

添加比例尺

image.png

pGraphicsContainer.AddElement(pElement, 0); //像圖中添加元素

image.png

image.png

顯示網絡的流向

image.png

image.png
image.png

image.png

流向的繪制

image.png

網絡追蹤分析

image.png

爆管分析的 步驟

image.png
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容