GIS中由點生成線,點生成面的方法介紹

在GIS中單純的用點生成面,沒有任何意義,因爲沒有確定生成路線!要先生成線,然後由線閉合生成面:

構造Polygon對象必須保證每個構成Ring都是有效的,Ring之間的邊界不能重合,外部Ring方向是順時針,內部Ring方式是逆時針,不存在面積爲0的Ring。IPolygon接口是Polygon類得主要接口,定義了一系列的屬性和方法來控制Ring。如ExteriorRingCount屬性用於返回一個多邊形的全部外部環的數目,InteriorRingCount屬性用於返回一個多邊形內部環的數目,QueryExteriorRings屬性用於查詢全部的外部Ring,QueryInteriorRings屬性則用於查詢全部的內部Ring。

            IPoint pnt1 = new PointClass();
            IPoint pnt2 = new PointClass();
            IPoint pnt3 = new PointClass();
            IPoint pnt4 = new PointClass();
            IPoint pnt5 = new PointClass();
            pnt1.X = 0; pnt1.Y = 0;
            pnt2.X = 0; pnt2.Y = 500;
            pnt3.X = 500; pnt3.Y = 500;
            pnt4.X = 500; pnt4.Y = 0;
            pnt5.X = 0; pnt5.Y = 0;

            ILine pLine = new LineClass();
            pLine.PutCoords(pnt1, pnt2);
            ISegmentCollection pPath = new PathClass();
            pPath.AddSegment((ISegment)pLine, Type.Missing, Type.Missing);

            pLine = new LineClass();
            pLine.PutCoords(pnt2, pnt3);
            pPath.AddSegment((ISegment)pLine, Type.Missing, Type.Missing);

            pLine = new LineClass();
            pLine.PutCoords(pnt3, pnt4);
            pPath.AddSegment((ISegment)pLine, Type.Missing, Type.Missing);

            pLine = new LineClass();
            pLine.PutCoords(pnt4, pnt5);
            pPath.AddSegment((ISegment)pLine, Type.Missing, Type.Missing);

            IGeometryCollection pPolyline = new PolylineClass();
            pPolyline.AddGeometry((IGeometry)pPath, Type.Missing, Type.Missing);




            //線生成面<pre name="code" class="csharp">            
            IGeometryCollection pPolygon = new PolygonClass();
            for (int i = 0; i < pPolyline.GeometryCount; i++) 
                { 
                   pRing = new RingClass(); 
                   pRing.AddSegmentCollection(pPolyline.get_Geometry(i) as ISegmentCollection); 
                   pPolygon.AddGeometry(pRing as IGeometry, Type.Missing, Type.Missing); 
                } 
            IPolygon pPolygonNew = pPolygon as IPolygon;


 

 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章