Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1282968
  • 博文数量: 135
  • 博客积分: 10588
  • 博客等级: 上将
  • 技术积分: 1325
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-18 11:12
文章分类

全部博文(135)

文章存档

2013年(6)

2012年(3)

2011年(11)

2010年(7)

2009年(14)

2008年(6)

2007年(42)

2006年(46)

分类: C/C++

2009-09-28 10:06:52

public void CreatePolygonFeaturesFromCursors(IFeatureClass polygonFC,
IFeatureClass lineFC)
{
if (polygonFC.ShapeType != esriGeometryType.esriGeometryPolygon)
{
System.Console.WriteLine("The target layer is not a polygon layer.");
return ;
}

//Set IFeatureCursor object, which will be the line source to construct polygons.
IFeatureCursor lineFeatureCursor = lineFC.Search(null, false);

//Set the processing bounds to be the extent of the polygon feature class,
//which will be used to search for existing polygons in the target feature.
IGeoDataset geoDS = polygonFC as IGeoDataset;
IEnvelope processingBounds = geoDS.Extent;

//Define an IInValidArea object.
IInvalidArea invalidArea = new InvalidAreaClass();

//Define a construct feature object.
IFeatureConstruction featureConstruction = new FeatureConstructionClass();

//Start an edit session.
IDataset dataset = polygonFC as IDataset;
IWorkspace workspace = dataset.Workspace;
IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

if (workspaceEdit.IsBeingEdited() != true)
{
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
}


try
{
//**********Construct polygons using the line feature cursor.************//
featureConstruction.ConstructPolygonsFromFeaturesFromCursor(null, polygonFC,
processingBounds, true, false, lineFeatureCursor, invalidArea, - 1, null)
;

//**********AutoComplete the polygons.*************//
//IWorkspace selWorkspace = polygonFC.FeatureDataset.Workspace;
//ISelectionSet selectionSet;
//featureConstruction.AutoCompleteFromFeaturesFromCursor(polygonFC, processingBounds, lineFeatureCursor,
// invalidArea, -1, selWorkspace, out selectionSet);

//**********Split the polygons.***************//
//featureConstruction.SplitPolygonsWithLinesFromCursor(null, polygonFC, processingBounds,
// lineFeatureCursor, invalidArea, -1);

//Complete the edit operation and stop the edit session.
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
}

catch (Exception e)
{
//Abort the edit operation if errors are detected.
System.Console.WriteLine("Construct polygons failed. " + e.Message);
workspaceEdit.AbortEditOperation();
}
}
阅读(3035) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~