版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、【051】 ArcEngine實(shí)現(xiàn)空間分析 1熟悉ITopologicalOperator接口(用于空間拓?fù)溥\(yùn)算)的使用 2熟悉IRelationalOperator接口(用于空間關(guān)聯(lián)運(yùn)算)的使用 3熟悉IProximityOperator接口(用于空間距離運(yùn)算)的使用 錄:A1ITopologicalOperator5 接口公共方法:Buffer 方法:Boundary 方法Clip方法ConvexHull 方法Cut方法Union方法:Intersect 方法Difference 方法A2IRelationalOperator 接口公共方法Contains 方法Overlaps 方法A3I
2、Point接口A4ICurve3接口A5ISegment接口A6ICircularArc 接口寫在前面:使用空間分析的時(shí)候,會(huì)提示這樣的錯(cuò)誤異常來自HRESULT:0 x80040215,其原 因就是:在使用ITopologicalOperator求交集等操作的時(shí)候,有時(shí)會(huì)出現(xiàn)“ HRESULT: 0 x8 004 0215”這個(gè)異常,原來是空間參考不一樣所致。因此只要SpatialReference屬性設(shè)為同一空間參考就不會(huì)出現(xiàn)“ HRESULT: 0 x8004 0215”異常。所以在進(jìn)行空間分析之前,要保證所建立的shapefile文件具有相同的 SpatialRefere nee!II
3、第A1個(gè)II TopologicalOperator5 接口:1. Provides additional information on non-simple geometries.【拓扌卜操作】MembersDescriptionBoundary返回值:IGeometryThe bounda ry of this geomet ry. A polygons bounda ry is a polyline A polylines bounda ry is a multipoint. A point or multipoints bounda ry is an empty point or mu
4、ltipoint.Buffer(double distance) 返回值:IGeometryConst ructs a polygon that is the locus of points at a distance less than or equal to a specified distance from this geomet ry.通過給定距離,得到操作圖形的緩沖區(qū),返回得到緩沖區(qū)幾何圖形! 但是這里面的距離很是蹊蹺,同時(shí)實(shí)驗(yàn)發(fā)現(xiàn),我寫入0.01的時(shí)候,大約表 示1km,所以大約是1:100 000的關(guān)系!JClip(IEnvelope clippeEnvelope)Const r
5、ucts the intesection of this geomet ry and the specified envelope.返回矩形部分的要素,直接作用在要素上面!ClipDenseConst ructs the intesection of this geomet ry and the specified envelope; densifies lines in output contributed by the clipping envelope.ClipExConst ructs the intesection of this geomet ry and the specifie
6、d envelope.ClipToDomainClips the geomet ry to the domain of the spatial refer ence. Useful for ens ur ing that buffe rs can be fit within the spatial domain of the feat ure class to which they are being added.ConstructUnionDefines this geomet ry to be the union of the inputs. More efficient for unio
7、ning multiple geomet ries than calling Union r epeatedly.ConvexHullConst ructs the convex hull of this geomet ry.CutSplits this geomet ry into a part left of the cutting polyline, and a part right of it.JCut2Divides a geomet ry into multiple partsJDifferenceConst ructs the geometry containing points
8、 from this geomet ry but not the othe r geomet ry.JGeoNormalizeExShifts longitudes, if need be, into a continuous r ange of 360 deg rees.JIntersectConst ructs the geometry that is the set-the or etic intesection of the input geomet ries. Use diffe rent r esultDimension values to gene rate r esults o
9、f diffe rent dimensions.IntersectMultidimensionConst ructs the set-the or etic intesection of the inputs. The r esults are retur ned in a geomet ry bag with one element per r esult dimension.IsKnownSimpleIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect.IsKnownSimp
10、leIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect.IsSimpleIndicates whethe r this geomet ry is known (or assumed) to be topologically corr ect, after explicitly dete rmining this if the geomet ry is not al ready known (or assumed) to be simple.IsSimpleExDete rmin
11、es why a geomet ry is not simple. Curr ently only implemented for polygons.QueryClippedRedefines clippedGeometry to be the intesection of this geometry and the clipping envelope.QueryClippedDenseRedefines clippedGeometry to be the intesection of this geometry and the clipping envelope; densifies lin
12、es in the output cont ributed by the clipping envelope.SimplifyMakes this geomet ry topologically corr ect.SymmetricDifferenceConst ructs the geometry that contains points from eithe r but not both input geomet ries.UnionConst ructs the geometry that is the set-the or etic union of the inpu geomet r
13、ies.CoClasses that implement ITopologicalOperatorCoClasses and ClassesDescriptionGeoEllipse (esriDefenseSolutions)Its a sphe ro idal ellipse.GeometryBagAn ordered collection of objects that supp ort the IGeomet ry inte rfaceGeoPolygonIts a sphe ro idal polygon.(esriDefenseSolutions)GeoPolyline (esri
14、DefenseSolutions)This is a sphe ro idal polyline.MultiPatchA collection of sur face patches.MultipointAn ordered collection of points; optionally has meas ure, height and ID att ributes.PointA two dimensional point, optionally with meas ure, height, and ID att ributes.PolygonA collection of rings or
15、dered by thei r containment r elationship; optionally has meas ure, height and ID att ributes.PolylineAn ordered collection of paths; optionally has meas ure, height and ID att ributes.探I公共代碼部分:公共變量! IMap pMap;IActiveView pActiveView;IEnvelope pEnv;ISelectionEnvironment pSelectionEnv; IEnumFeature p
16、EnumFeature;IGraphicsContainer pGraphicsContainer; IFeature pFeature;IGeometry pGeometry;IEnvelope pEnvClip;IPolyline pLineCut;IPolygon pFirstPolygon;鼠標(biāo)點(diǎn)擊事件!private void axMapControl1_OnMouseDown(object sender,IMapControlEvents2_OnMouseDownEvent e)axMapControl1.MousePointer =esriControlsMousePointer
17、.esriPointerCrosshair;if (isClip) /此時(shí)要拉 Clip 框pEnvClip = axMapControl1.TrackRectangle(); isClip =false;else if (isCut)pLineCut = axMapControl1.TrackLine() as IPolyline; isCut =false;else if (isFirstIn)pMap = axMapControl1.Map;pActiveView = pMapas IActiveView;pEnv = axMapControl1.TrackRectangle();pSe
18、lectionEnv =new SelectionEnvironment();IEnumFeature;IEnumFeature;pSelectionEnv.Defaultcolor = GetColor0, 255, 0 ); pMap.SelectByShape(pEnv, pSelectionEnv,false); pActiveView.Refresh();IEnumFeature;IEnumFeature;pEnumFeature = axMapControl1.Map.FeatureSelectionas elsepMap = axMapControl1.Map;pActiveVi
19、ew = pMapas IActiveView;pEnv = axMapControl1.TrackRectangle();pSelectionEnv =new SelectionEnvironment();pSelectionEnv.DefaultColor = GetColor255, 0, 0); pMap.SelectByShape(pEnv, pSelectionEnv,false); pActiveView.Refresh();pEnumFeature = axMapControl1.Map.FeatureSelectionas /RGB 顏色! private IRgbColor
20、 GetColor(int r, int g, int b) IRgbColor pColor = new RgbColor(); pColor.Red = r;pColor.Green = g; pColor.Blue = b;return pColor;探 | 探 f Buffer:private void button1_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定義容器pFeature = pEnumFeature.Next();/遍歷要素if
21、 (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;/獲取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓?fù)洳僮鱅Geometry pBufferGeo = pTopoOperator.Buffer2();/緩沖區(qū)分析IElement pElement =new PolygonElement();pElement.Geometry = pBufferGeo;/獲取得到的緩沖區(qū)pGraphicsCo
22、ntainer.AddElement(pElement,0); /顯示緩沖區(qū) pActiveView.Refresh();探 | 探Boundary:private void button2_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定義容器pFeature = pEnumFeature.Next();/遍歷要素if (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;/獲取要素
23、的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓?fù)洳僮鱅Geometry pBoundary = pTopoOperator.Boundary; /獲取邊界ILineElement pLineEle =new LineElementClass();ISimpleLineSymbol pSLS =new SimpleLineSymbol(); IRgbColor pColor = GetColorO, 255, 0);pSLS.Color = pColor; pSLS.Widt
24、h =5;pLineEle.Symbol = pSLS;IElement pElement = pLineEleas IElement; pElement.Geometry = pBoundary;pGraphicsContainer AddElement(pElement,0 ); /顯示邊界 pActiveView.Refresh();探 | 探 f Clip:bool isClip = false;private void button3_Click(object sender, EventArgs e) isClip = true;while (true)pGraphicsContai
25、ner = pMapas IGraphicsContainer;/定義容器pFeature = pEnumFeature.Next();/遍歷要素if (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;/獲取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓?fù)洳僮鱬TopoOperator.Clip(pEnvClip);IElement pElement =new PolygonElement();
26、pElement.Geometry = pGeometry;/獲取得到的緩沖區(qū)pGraphicsContainer.AddElement(pElement,0 ); /顯示緩沖區(qū) pActiveView.Refresh();| 探ConvexHull:while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定義容器pFeature = pEnumFeature.Next();/遍歷要素if (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;/獲取要素的 G
27、eometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓?fù)洳僮鱅Geometry pBufferGeo = pTopoOperator.ConvexHull();IElement pElement =new PolygonElement();pElement.Geometry = pBufferGeo;/獲取得到的緩沖區(qū)pGraphicsContainer.AddElement(pElement,0 ); /顯示緩沖區(qū) pActiveView.Refresh();探|Cut:bool is
28、Cut = false;private void button6_Click(object sender, EventArgs e)isCut = true;private void button7_Click(object sender, EventArgs e)while (true)pGraphicsContainer = pMapas IGraphicsContainer;/定義容器pFeature = pEnumFeature.Next();/遍歷要素if (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;
29、/獲取要素的 GeometryITopologicalOperator pTopoOperator = pGeometras ITopologicalOperator;/QI到拓?fù)洳僮鱮yIGeometry pGeoRight =new PolygonClass();IGeometry pGeoLeft =new PolygonClass();pTopoOperator Cut(pLineCut,out pGeoLeft, out pGeoRight);IElement pElement =new PolygonElement();IFillShapeElement pFillEle = pE
30、lementas IFillShapeElement;ISimpleFillSymbol pSFS =new SimpleFillSymbol();pSFS.Color = GetColor255, 255, 0);pFillEle.Symbol = pSFS;pElement.Geometry = pGeoLeft;/獲取得到的緩沖區(qū)pGraphicsContainer.AddElement(pElement, 0 ); /顯示緩沖區(qū)pSFS =new SimpleFillSymbol();pSFS.Color = GetColor255, 0, 255);pFillEle.Symbol =
31、 pSFS;pElement =new PolygonElement();pElement.Geometry = pGeoRight;/獲取得到的緩沖區(qū)pGraphicsContainer.AddElement(pElement, 0 ); /顯示緩沖區(qū) pActiveView.Refresh();探 | 探 f Union:private void button8_Click(object sender, EventArgs e)IGeometry pUnionGeo = new PolygonClass();pGraphicsContainer = pMap as IGraphicsCon
32、tainer;/定義容器while (true)pFeature = pEnumFeature.Next();/遍歷要素if (pFeature = null)/若不存在要素,則推出循環(huán)break;pGeometry = pFeature.Shape;/獲取要素的 GeometryITopologicalOperator pTopoOperator = pUnionGeas ITopologicalOperator;/QI到拓?fù)洳僮鱮ypUnionGeo = pTopoOperator.Union(pGeometry);IElement pElement = new PolygonElemen
33、t();IFillShapeElement pFillEle = pElement as IFillShapeElement;ISimpleFillSymbol pSFS = new SimpleFillSymbol();pSFS.Color = GetColor 255, 255, 0);pFillEle.Symbol = pSFS;pElement .Geometry = pUnionGeo; /獲取得到的緩沖區(qū) pGraphicsContainer AddElement(pElement, 0 ); /顯示緩沖區(qū) pActiveView.Refresh();探 | Intersect:b
34、ool isFirstIn = false;private void button10_Click(object sender, EventArgs e)isFirstIn = true;private void button11_Click(object sender, EventArgs e)isFirstIn = false;pFirstPolygon = new PolygonClass();while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;IT
35、opologicalOperator pTopoOperator = pFirstPolygon as ITopologicalOperator;pFirstPolygon = pTopoOperator.Union(pGeometry) as IPolygon; private void button12_Click(object sender, EventArgs e)IGeometry pIntersectGeo = new PolygonClass();IGeometry pSecondPolygon = new PolygonClass();pGraphicsContainer =
36、pMap as IGraphicsContainer;while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;ITopologicalOperator pTopoOperator = pSecondPolygonas ITopologicalOperator;pSecondPolygon = pTopoOperator Union(pGeometry) as IPolygon;ITopologicalOperator pTopo = pSecondPolygo
37、n as ITopologicalOperator; pIntersectGeo = pTopo.Intersect(pFirstPolygon, esriGeometryDimension.esriGeometry2Dimension) as IPolygon;IElement pElement = new PolygonElementClass(); pElement.Geometry = pIntersectGeo;pGraphicsContainer.AddElement(pElement, 0);IFeatureLayer pFeatureLayer = pMap.get_Layer
38、 0) as IFeatureLayer; pFeatureLayer Visible = false;pFeatureLayer = pMap.get_Layer1) as IFeatureLayer;pFeatureLayer Visible = false; pActiveView.Refresh();探|探f Difference:(需要前面兩部分)private void button13_Click(object sender, EventArgs e)IGeometry pIntersectGeo = new PolygonClass();IGeometry pSecondPol
39、ygon = new PolygonClass(); pGraphicsContainer = pMap as IGraphicsContainer;while (true)pFeature = pEnumFeature.Next();if (pFeature = null)break;pGeometry = pFeature.Shape;ITopologicalOperator pTopoOperator = pSecondPolygonas ITopologicalOperator;pSecondPolygon = pTopoOperator Union(pGeometry) as IPo
40、lygon;ITopologicalOperator pTopo = pSecondPolygon as ITopologicalOperator; pIntersectGeo = pTopo.Difference(pFirstPolygon) as IPolygon;IElement pElement = new PolygonElementClass(); pElement.Geometry = pIntersectGeo;pGraphicsContainer.AddElement(pElement, 0);IFeatureLayer pFeatureLayer = pMap get_La
41、yer 0) as IFeatureLayer; pFeatureLayer Visible = false;pFeatureLayer = pMap.get_Layer1) as IFeatureLayer;pFeatureLayer Visible = false;pActiveView.Refresh();iiiII第A2個(gè)II elationalOperator 接口:1. Provides access to members that determine if a certain spatial relatio nship exists betwee n two geometries
42、.MembersDescriptionContainsIndicates if this geomet ry contains the othe r geomet ry. 前者是否包含后者!CrossesIndicates if the two geomet ries inte rsect in a geomet ry of lesse r dimension.DisjointIndicates if the two geomet ries sha re no points in common. Negat this r esult to compute the Inte rsect r el
43、ation.EqualsIndicates if the two geomet ries are of the same type and define th same set of points in the plane.OverlapsIndicates if the intesection of the two geomet ries has the same dimension as one of the input geomet ries.前者和后者是否有重疊!不包括包含關(guān)系!RelationIndicates if the defined r elationship exists.
44、TouchesIndicates if the boundaries of the geometries intersect.WithinIndicates if this geomet ry is contained (is within) anothe r geomet ry.前者是否在后者內(nèi)部!CoClasses that implement IRelationalOperatorCoClasses and ClassesDescriptionEnvelopeA r ectangle with sides par allel to a coor dinate system definin
45、g the extent of anothe r geomet ry; optionally has min and max meas ure, height and ID att ributes.GeometryBagAn ordered collection of objects that supp ort the IGeomet ry inte rfaceMultiPatchA collection of sur face patches.MultipointAn ordered collection of points; optionally has meas ure, height
46、and ID att ributes.PointA two dimensional point, optionally with meas ure, height, and ID att ributes.PolygonA collection of rings ordered by thei r containment r elationship; optionally has meas ure, height and ID att ributes.PolylineAn ordered collection of paths; optionally has meas ure, height a
47、nd ID att ributes.探I公共代碼部分:IMap pMap;IActiveView pActiveView;IEnvelope pEnv;ISelectionEnvironment pSelectionEnv;IEnumFeature pEnumFeature;IFeature pFeature;IGeometry pGeometry;IGeometry pBasicGeo;private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_0nMouseDownEvent e)axMapControl
48、1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;pMap = axMapControl1.Map;pActiveView = pMap as IActiveView;pEnv = axMapControl1.TrackRectangle(); pSelectionEnv = new SelectionEnvironment(); pSelectionEnv.Defaultcolor = GetColor 255, 0, 0);pMap.SelectByShape(pEnv, pSelectionEnv, false); pActiveView.Refresh();pEnumFeature = pMap.FeatureSelection as IEnumFeature; private IRgbColor GetColor(int r, int g, int b) IRgbColor pColor = new RgbColor(); pColor.Red = r;pColor.Green = g;pColor.Blue = b;return pColor;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 承辦宴席合同范例
- 專利設(shè)計(jì)代理合同范例
- 畫展展廳布置合同范例
- 眼科學(xué)題庫(kù)含參考答案
- 深圳勞務(wù)糾紛合同范例
- 用電促銷合同范例
- 房屋合同范例每漲
- 2025年寧夏貨運(yùn)上崗證考試題答案
- 沙采購(gòu)合同合同范例
- 黨員活動(dòng)策劃合同范例
- 2024年煤礦探放水考試題庫(kù)附答案
- 《會(huì)展英語(yǔ)》課程教學(xué)大綱
- 礦山安全生產(chǎn)管理經(jīng)驗(yàn)分享
- 初識(shí)旅游智慧樹知到期末考試答案2024年
- 2023年中國(guó)電動(dòng)工具行業(yè)發(fā)展白皮書
- 2022-2023學(xué)年北京市豐臺(tái)區(qū)八年級(jí)(上)期末歷史試題(含答案)
- 江蘇省南京市玄武區(qū)2023年數(shù)學(xué)七上期末統(tǒng)考試題含解析
- 生物安全教學(xué)課件
- 漢語(yǔ)言文學(xué)生涯發(fā)展展示
- 盆底功能障礙問卷(PFDI20)
- 期末綜合復(fù)習(xí)(試題)-2023-2024學(xué)年五年級(jí)上冊(cè)數(shù)學(xué)人教版
評(píng)論
0/150
提交評(píng)論