這裏生成緩衝區肯定是根據點進行生成的,說是生成緩衝區其實是根據點生成面。具體思路如下:
首先根據點獲取要生成矩形緩衝區的四個頂點的座標,然後將這四個點生成面即可得到所謂的矩形緩衝區。
//首先獲取要生成緩衝區的點
IPoint pPoint = new PointClass();
pPoint.X = cPointList[i].point.X;
pPoint.Y = cPointList[i].point.Y;
//獲取生成的緩衝區的四個頂點的座標
IPointCollection pPC = new MultipointClass();
for (int j = 0; j < 4; j++)
{
IPoint pPoint1 = new PointClass();
if (j == 0)
{
pPoint1.X = pPoint.X - 2.55;
pPoint1.Y = pPoint.Y - 2.55;
}
if (j == 1)
{
pPoint1.X = pPoint.X - 2.55;
pPoint1.Y = pPoint.Y + 2.55;
} if (j == 2)
{
pPoint1.X = pPoint.X + 2.55;
pPoint1.Y = pPoint.Y + 2.55;
} if (j == 3)
{
pPoint1.X = pPoint.X + 2.55;
pPoint1.Y = pPoint.Y - 2.55;
}
pPC.AddPoint(pPoint1);
}
IGeometryCollection pGeometryCollection = new PolygonClass();
Ring ring = new RingClass();
object missing = Type.Missing;
ring.AddPointCollection(Points);
pGeometryCollection.AddGeometry(ring as IGeometry, ref missing, ref missing);
IPolygon polyGonGeo = pGeometryCollection as IPolygon;
polyGonGeo.Close();
polyGonGeo.SimplifyPreserveFromTo();
pGeo =polyGonGeo as IGeometry;
//創建要素
pFeatureBuffer = pFeaClaPolygon.CreateFeatureBuffer();
pFeatureBuffer.Shape = pGeo;
結果圖:下圖爲點生成矩形緩衝區的最終成果。
這個是融合之後的圖形。
當然在進行頂點座標輸入的時候需要按照順序,不然就會出現下邊這種情況: