private void button11_Click(object sender, EventArgs e)
{
IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pCommonFeaureWorkspace;
pWorkspaceEdit.StartEditing(true);
pWorkspaceEdit.StartEditOperation();
IFeatureCursor pFeatureCursor = pCommonFeatureClass.Search(null, false);
IFeature pFeatureFirst = pFeatureCursor.NextFeature();
//int count = 0;
//while (pFeatureFirst != null)
//{
Console.WriteLine(pFeatureFirst.get_Value(0).ToString());
IGeometry pGeometryFirst = pFeatureFirst.Shape;
ITopologicalOperator2 pTopOperatorFirst = (ITopologicalOperator2)pGeometryFirst;
IRelationalOperator pRelOperatorFirst = (IRelationalOperator)pGeometryFirst;
pTopOperatorFirst.IsKnownSimple_2 = false;
pTopOperatorFirst.Simplify();
pGeometryFirst.SnapToSpatialReference();
IGeometry pGeometrySecond;
IFeature pFeatureSecond = pFeatureCursor.NextFeature();
while (pFeatureSecond != null)
{
pGeometrySecond = pFeatureSecond.ShapeCopy;
ITopologicalOperator2 pTopOperatorSecond = (ITopologicalOperator2)pGeometrySecond;
pTopOperatorSecond.IsKnownSimple_2 = false;
pTopOperatorSecond.Simplify();
pGeometrySecond.SnapToSpatialReference();
Console.WriteLine(pFeatureSecond.get_Value(0).ToString());
if (pRelOperatorFirst.Overlaps(pGeometrySecond) == true)
{
pGeometryFirst = pTopOperatorFirst.Union(pGeometrySecond);
pFeatureSecond.Delete();
}
pFeatureSecond = pFeatureCursor.NextFeature();
}
pTopOperatorFirst.IsKnownSimple_2 = false;
pTopOperatorFirst.Simplify();
pFeatureFirst.Shape = pGeometryFirst;
pFeatureFirst.Store();
//axMapControl1.Refresh();
//count++;
// pFeatureCursor = pCommonFeatureClass.Search(null, false);
// for (int i = 0; i <= count; i++)
// {
// pFeatureFirst = pFeatureCursor.NextFeature();
// }
//}
pWorkspaceEdit.StopEditOperation();
pWorkspaceEdit.StopEditing(true);
axMapControl1.Refresh();
}