_银子

提供更专注、更专心、更专业的服务
  首页  :: 联系 :: 订阅 订阅  :: 管理

增加一个多边形

Posted on 2012-02-29 12:50  _银子  阅读(178)  评论(0编辑  收藏  举报

 {

       IFeatureCursor pFeatureCursor = _featureClass.Insert(true);
                IFeatureBuffer pFeatureBuffer = _featureClass.CreateFeatureBuffer();

                object missing = Type.Missing;
                IPointCollection points = new RingClass();
                IPoint pt1 = new PointClass();
                pt1.X = 0;
                pt1.Y = 0;
                points.AddPoint(pt1, ref missing, ref missing);
                IPoint pt2 = new PointClass();
                pt2.X = 0;
                pt2.Y = 1;
                points.AddPoint(pt2, ref missing, ref missing);
                IPoint pt3 = new PointClass();
                pt3.X = 1;
                pt3.Y = 1;
                points.AddPoint(pt3, ref missing, ref missing);
                IPoint pt4 = new PointClass();
                pt4.X = 1;
                pt4.Y = 0;
                points.AddPoint(pt4, ref missing, ref missing);
                IPoint pt5 = new PointClass();
                pt5.X = 0;
                pt5.Y = 0;
                points.AddPoint(pt5, ref missing, ref missing);
                MultipointClass mp = points as MultipointClass;

                IRing ring = points as IRing;
                ISegmentCollection SegCol = ring as ISegmentCollection;
                IPolygon pPolygon = new PolygonClass();

                ISegmentCollection newSegCol = pPolygon as ISegmentCollection;
                newSegCol.AddSegmentCollection(SegCol);

                pFeatureBuffer.Shape = pPolygon;

 
                pFeatureCursor.InsertFeature(pFeatureBuffer);
                pFeatureCursor.Flush();

}