//面转化为线
//闫磊 Email:[email protected],[email protected] 2004.12.03编写
function PolygonToPolyLine(pPoly: IPolygon): IPolyLine;
var
i, count : Integer;
pSegs, pAddSegs : ISegmentCollection;
pGeosPoly, pGeoms : IGeoMetryCollection;
pClone, pClone2 : IClone;
pGeom : IGeoMetry;
begin
pClone := pPoly as IClone;
pClone.Clone(pClone2);
pGeosPoly := pClone2 as IGeoMetryCollection;
pGeosPoly.Get_GeometryCount(count);
pGeoms := CoPolyLine.Create as IGeoMetryCollection;
for i := 0 to count - 1 do
begin
pSegs := coPath.Create as ISegmentCollection;
pGeosPoly.Get_Geometry(i, pGeom);
pAddSegs := pGeom as ISegmentCollection;
pSegs.AddSegmentCollection(pAddSegs);
pGeom := pSegs as IGeoMetry;
pGeoms.AddGeoMetry(pGeom, EmptyParam, EmptyParam);
end;
result := pGeoms as IPolyLine;
end;
//线转化为面
//闫磊 Email:[email protected],[email protected] 2004.12.03编写
function PolyLineToPolygon(pPoly: IPolyLine): IPolygon;
var
i, count : Integer;
pSegs, pAddSegs : ISegmentCollection;
pGeosPoly, pGeoms : IGeoMetryCollection;
pClone, pClone2 : IClone;
pGeom : IGeoMetry;
begin
pClone := pPoly as IClone;
pClone.Clone(pClone2);
pGeosPoly := pClone2 as IGeoMetryCollection;
pGeosPoly.Get_GeometryCount(count);
pGeoms := CoPolygon.Create as IGeoMetryCollection;
for i := 0 to count - 1 do
begin
pSegs := coPath.Create as ISegmentCollection;
pGeosPoly.Get_Geometry(i, pGeom);
pAddSegs := pGeom as ISegmentCollection;
pSegs.AddSegmentCollection(pAddSegs);
pGeom := pSegs as IGeoMetry;
pGeoms.AddGeoMetry(pGeom, EmptyParam, EmptyParam);
end;
result := pGeoms as IPolygon;
end;