Segment,Path,Ring和Polyline对象
Segment幾何對象
? Segment對象是一個有起點和終點的“線“,也就是說Segement只有兩個點,至于兩點之間的線是直的,
還是曲的,需要其余的參數定義。所以Segment是由起點,終點和參數三個方面決定的。Segment有4個
子類,它的4個子類如下圖:
Path幾何對象
Path是連續的Segment的集合,除了路徑的第一個Segment和最后一個Segment外其余的Segment的起始
點都是前一個Segment的終止點,即Path對象的中的Segment不能出現分離,Path可以是任意數的Segment
子類的組合。
?
Ring幾何對象
Ring是一個封閉的Path即起始和終止點有相同的坐標值。它有內部和外部屬性。
?
Polyline幾何對象
Polyline對象是由一個或多個相連或者不相連的path對象的有序集合,它可以是單個Path對象組成,也
可以是多個相連的Path對象組成,或者是多個分離的Path組成,如下圖所示。Polyline通常用來代表線
狀地物如道路,河流,管線等等。
?????? Polylines是有序path組成的集合,可以擁有M、Z和ID屬性值。Polyline對象的IPointCollection
接口包含了所有節點的復制,IGeometryCollection接口可以獲取polyline的paths,ISegmentCollection
接口可以獲取 polyline的segments。
一個Polyline對象必須滿足以下準則:
1.組成Polyline對象的所有Path對象必須是有效的。
2.組成Polyline對象的所有Path對象不能重合,相交或自相交。
3.組成Polyline對象的多個Path對象可以連接與某一點,也可以分離。
4.Path對象的長度不能為0.
IPolyline是Polyline類的主要接口,IPolyline的Reshape方法可以使用一個Path對象為一個
Polyline對象整形,IPolyline的SimplifyNetwork方法用于簡化網絡。
Polyline對象可以使用IGeometryCollection接口添加Path對象的方法來創建,使用該接口需注意
以下情況:
1.每一個Path對象必須是有效的,或使用IPath::Simplify方法后有效。
2.由于Polyline是Path對象的有序集合,所以添加Path對象時必須注意順序和方向。
3.為了保證Polyline是有效的,可以創建完Polyline對象后使用ITopologicalOperator接口的
Simplify方法。
? 下面代碼片段演示了一個Polyline的構成:
?????
??????? private? object pMissing = Type.Missing;
?
??????? public? IGeometry GetPolylineGeometry()
??????? {
??????????? const double PathCount = 3;
??????????? const double PathVertexCount = 3;
??????????? IGeometryCollection pGeometryCollection = new PolylineClass();
?
??????????? for (int i = 0; i < PathCount; i++)
??????????? {
??????????????? IPointCollection pPointCollection = new PathClass();
?
??????????????? for (int j = 0; j < PathVertexCount; j++)
??????????????? {
??????????????????? pPointCollection.AddPoint(GetPoint(), ref pMissing, ref pMissing);
??????????????? }
?
??????????????? pGeometryCollection.AddGeometry(pPointCollection as IGeometry, ref pMissing,
ref pMissing);
??????????? }
?
?
??????????? return pGeometryCollection as IGeometry;
??????? }
??????? private? IPoint GetPoint()
??????? {
??????????? const double Min = -10;
??????????? const double Max = 10;
?
??????????? Random random = new Random();
?
??????????? double x = Min + (Max - Min) * random.NextDouble();
??????????? double y = Min + (Max - Min) * random.NextDouble();
?
??????????? return ConstructPoint(x, y);
??????? }
Segment,Path,Ring和Polyline的區別
在這四者當中Segment是最小的單位具體的構成路線可以分為兩個條:
Segment-Path-Ring(封閉的Path)
Segment-Path-Polyline
我們可以這樣說Segment是Path,只不過是這個Path由一個Segment組成,Ring也是一種
Path,只不過是一個起點和終點重合的Path,至于Polyline那就很明顯了,他們的區別可
以從下圖看出:
?
?
轉載于:https://www.cnblogs.com/qiushuixizhao/p/3247920.html
總結
以上是生活随笔為你收集整理的Segment,Path,Ring和Polyline对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 1030 完美数列 (25 分)二分
- 下一篇: 第一阶段小结