《GIS二次开发-几何对象与空间参考》由会员分享,可在线阅读,更多相关《GIS二次开发-几何对象与空间参考(123页珍藏版)》请在金锄头文库上搜索。
1、第5章 几何对象与空间参考几何对象概述使用几何对象空间参考几何对象与桥接模式国土信息工程系5.1 几何对象概述Geometry对象用于表达要素或元素的几何形状 。 ArcGIS的几何对象被分为两个层次一是构成要素形状的几何图形,称为“ 高级几何对象”另一种是组成这些高级几何对象的构 件国土信息工程系GEOMETRY模型图国土信息工程系国土信息工程系国土信息工程系高级几何对象包括以下类型:Point:具有X、Y坐标值,以及可选的属性, 如高程(Z值),测量值(M)和ID号。Multipoint:是无序点的群集,它用于表示具 有相同属性设置的同一组点。Polyline:是一个有序路径(Path)的
2、集合,这 些路径既可以是连续的,也可以是离散的。Polygon:是环(Ring)的集合,环是一种封闭 的路径。Polygon可以由一个或者多个环组成,甚至 环内套环,形成岛环的情况,但是内外环之间不能 重叠。Envelope:是一个矩形,它用于表示要素的 空间范围。它覆盖了几何对象的最小坐标和最大坐 标、Z值和M值的变化范围。国土信息工程系几何构件:Paths, Rings and Segments用于构建 polylines 和polygons. Polylines contain paths and polygons contain rings. Paths and Rings are s
3、equences of vertices connected by segments. Polyline(多义线)对象是相连或不相连的路径对象的有序集 合,它可以分别是单个路径、多个不相连的路径和多个相 连路径的集合。国土信息工程系路径是连续Segment对象的集合,除了路径的第一个和最 后一个Segment外,每一个Segment的起始点都是前一个 片断的终止点,即路径对象中的Segment不能出现分离的 情况。路径可以是任意数目的Line、CircularArc、 EllipticArc和BezierCurve的组合。一个或多个路径对象组成 一个Polyline对象。国土信息工程系Geom
4、etryCurvePaths PolyCurveBezierCurveCircularArcEllipticArcLinePolylineIs composed of PathsAre composed of SegmentsSegments can be of 4 different TypesSegments图 Polyline及相关对象结构图Points are used to build Segments or PolylinePoints 国土信息工程系Polygon对象Polygon(多边形)对象是一个有序环对象的集合 ,这些环可以是一个或者多个。多边形对象通常 可以用于描述具有面
5、积的多边形离散矢量对象。国土信息工程系一个几何对象的每个顶点,除了有XY坐标 值外,还可以有其它可选属性,如Z值、M值 和ID。IZAwareIMAware IPointIDAware国土信息工程系画单个点IPoint pnt = new PointClass() as IPoint; pnt.PutCoords(100, 100); IZAware zAware = pnt as IZAware; zAware.ZAware = true;pnt.Z = 11.1;axMapControl1.DrawShape(pnt); 国土信息工程系5.1.1 Point 与 Multipoint 对象
6、国土信息工程系5.1.2 Point对象可参看组件对象模型图国土信息工程系国土信息工程系沿线构造法国土信息工程系角平分线构造法国土信息工程系构造角度交点国土信息工程系构造角度距离点国土信息工程系构造角度偏转交点国土信息工程系5.1.3 Multipoint 对象国土信息工程系国土信息工程系画两个单独的点 object Missing = Type.Missing; IPoint pP1, pP2; pP1 = new PointClass(); pP2 = new PointClass(); pP1.PutCoords(100, 100); pP2.PutCoords(150, 150); I
7、PointCollection lp; lp = new MultipointClass() ; lp.AddPoint(pP1, ref Missing, ref Missing); lp.AddPoint(pP2, ref Missing, ref Missing); axMapControl1.DrawShape(lp as IGeometry);国土信息工程系构造圆弧点国土信息工程系构造等长度点国土信息工程系构造交点国土信息工程系产生一个点的曲线两个切点国土信息工程系5.1.4 包络线 Envelope 国土信息工程系几何图形的包络线国土信息工程系国土信息工程系交集国土信息工程系并集国
8、土信息工程系IEnvelope运算 object Missing = Type.Missing; IEnvelope penv, penv2, penv3; penv = (IEnvelope)g1.Envelope; penv2 = (IEnvelope)g2.Envelope; MessageBox.Show(penv2.XMax.ToString(); penv2.Intersect(penv); MessageBox.Show(penv2.XMax.ToString();国土信息工程系5.1.5 曲线(Curve)国土信息工程系5.1.5 Segment 国土信息工程系5.1.5.1
9、CircularArc国土信息工程系国土信息工程系国土信息工程系国土信息工程系5.1.5.2 Line 对象国土信息工程系构造线段pLine1.FromPoint = pPoint1; pLine1.ToPoint = pPoint2; pLine2.FromPoint = pPoint2; pLine2.ToPoint = pPoint3; ISegmentCollection pPath; pPath = new PathClass(); pPath.AddSegment(pLinel); pPath.AddSegment(pLine2);国土信息工程系5.1.5.3 EllipticAr
10、c对象国土信息工程系国土信息工程系5.1.5.4 BezierCurve 对象国土信息工程系国土信息工程系产生BezierCurve 曲线Dim pBezier As IBezierCurve pBezier = New BezierCurveClass() Dim pPoint As IPoint pPoint = New PointClass() pPoint.PutCoords(20, 30) pBezier.PutCoord(2, pPoint) 国土信息工程系5.1.6 路径(Path)对象国土信息工程系产生PathpLine1.FromPoint = pPoint1; pLine1
11、.ToPoint = pPoint2; pLine2.FromPoint = pPoint2; pLine2.ToPoint = pPoint3; ISegmentCollection pPath; pPath = new PathClass(); pPath.AddSegment(pLinel); pPath.AddSegment(pLine2);国土信息工程系国土信息工程系5.1.7 环(Ring)对象国土信息工程系环的几个重要属性国土信息工程系产生环(Ring)对象ISegmentCollection pSegments; ILine pLine; IRing pRing;/产生一个段然
12、后加入段集合 pSegments = new RingClass(); pLine = new LineClass(); pLine.PutCoords(pPoint1, pPoint2); object Missing = Type.Missing; object val = 1; pSegments.AddSegment(pLine as ISegment, ref Missing, ref val); pLine = new LineClass(); pLine.PutCoords(pPoint2, pPoint3); pSegments.AddSegment(pLine as ISeg
13、ment, ref Missing, ref val); pRing = pSegments as IRing; pRing.Close();/环封闭国土信息工程系5.1.8 PolyCurve对象国土信息工程系5.1.9 Polyline对象国土信息工程系/产生构造线段的点 IPoint pPoint1;IPoint pPoint2; pPoint1 = new PointClass(); pPoint1.PutCoords(100, 20); pPoint2 = new PointClass(); pPoint2.PutCoords(20, 310); IGeometryCollectio
14、n pPolyline; pPolyline = new PolylineClass(); ISegmentCollection pPath; pPath = new PathClass(); /产生线段对象将其添加到段 ILinepLine; object Missing1 = Type.Missing; object Missing2 = Type.Missing; pLine = new LineClass(); pLine.PutCoords(pPoint1, pPoint2); pPath.AddSegment(pLine as ISegment,ref Missing, ref M
15、issing2); 将路径对象添加到多义线对象 pPolyline.AddGeometry(pPath as IGeometry,ref Missing, ref Missing2);国土信息工程系5.1.10 Polygon对象国土信息工程系国土信息工程系国土信息工程系使用段来构造多边形/产生一个环,向其添加段对象 ISegmentCollection pSegCol; pSegCol = new RingClass(); object Missing1 = Type.Missing; object Missing2 = Type.Missing; pSegCol.AddSegment(pSegmentA,ref Missing1, ref Missing2); pSegCol.AddSegment(pSegmentB,ref Missing1, ref Missing2 /封闭环对象,使其有效 IRing pRing ; pRing = pSegCol as IRing;