在ArcGIS Engine下如何实现矩形外扩指定距离?可以使用接口 ITransform2D。
ITransform2D.Scale(IPointOrigin,doublesx,doublesy);
其中 Origin为缩放基点、sx与sy分别是X、Y方向的缩放因子。在开发帮助中我们可以下面的描述:
where sX is the ratio of Old Width to New Width, and sY is the ratio of Old Height to New Height(sX是原始宽度与新宽度的比例,sY是原始高度与新高度的比例)
源码:
IPolygon pPolygon = pFeature.ShapeCopy as IPolygon;
IPoint pCenter = new PointClass();
pCenter.PutCoords((pPolygon.Envelope.XMin+pPolygon.Envelope.XMax)/2,
(pPolygon.Envelope.YMin+pPolygon.Envelope.YMax)/2);
pCenter.SpatialReference = pPolygon.SpatialReference;
ITransform2D pTran = pPolygon as ITransform2D;
pTran.Scale(pCenter, (pPolygon.Envelope.Width + dis * 2) / pPolygon.Envelope.Width,
(pPolygon.Envelope.Height + dis * 2) / pPolygon.Envelope.Height);
pPolygon = pTran as IPolygon;
pFeature.Shape = pPolygon;
pFeature.Store();
pFeature = pFeatureCursor.NextFeature();