arcgisengine实现矩形转面

面文件都有几何类型. arcengine在绘图时,不规则的多边形的几何类型是esriGeometryPolygon,矩形的几何类型是esriGeometryEnvelope,圆的几何类型是esriGeometryPolygon. 在将IGeometry转为IFeatureClass的过程中,矩形的会报错,所以想到将矩形转面.\

IGeometry geometry;//绘制好的矩形

IEnvelope envelope =  geometry as IEnvelope;
IPoint pt = new PointClass();

IPointCollection ptc = new PolygonClass();
object _missing = Type.Missing;

pt.PutCoords(envelope.XMin,envelope.YMin);
ptc.AddPoint(pt, ref _missing, ref _missing);
pt.PutCoords(envelope.XMin,envelope.YMax);
ptc.AddPoint(pt, ref _missing, ref _missing);
pt.PutCoords(envelope.XMax,envelope.YMax);
ptc.AddPoint(pt, ref _missing, ref _missing);
pt.PutCoords(envelope.XMax,envelope.YMin);
ptc.AddPoint(pt, ref _missing, ref _missing);

IPolygon polygon = new PolygonClass();
polygon = ptc as IPolygon;
 geometry = polygon as IGeometry;

参考:

https://www.bbsmax.com/A/pRdBZPY1dn/

https://www.bbsmax.com/A/q4zVM4wGdK/

 

posted @ 2018-02-06 11:09  Youse的二分口粮地  阅读(712)  评论(0)    收藏  举报