判断IPolygon是否自相交,如果相交范围很小,执行Simplify()后结果与ArcMap不符

如果Polygon自相交范围特别小,如下图1,Engine中执行ITopologicalOperator3.Simplify();后结点会发生变化,最上方的小三角形消失了。而ArcMap中输入相同坐标点,生成的Polygon会自动变成两个Part,上方的小三角形还会保存。Engine中如何获取与ArcMap相同的结果? 

已邀请:

朱新颖

赞同来自:

【解决办法】:
通过使用IFeatureSimplify2.SimplifyGeometry();可以解决该问题,结果与ArcMap中一致,测试代码如下:
string gdbPath= @E:ZhuXinying测试数据Data.gdb;
string fileName = Polygon1;
IWorkspaceFactory pWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(gdbPath, 0);
IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(fileName);
IWorkspaceEdit pWorkspaceEdit = pWorkspace as IWorkspaceEdit;
//启动编辑会话
pWorkspaceEdit.StartEditing(false);
//启动编辑操作
pWorkspaceEdit.StartEditOperation();
IFeature polygonFeature = pFeatureClass.CreateFeature(); //创建要素
IPointCollection pointCollection = new RingClass();
IPoint point1 = new PointClass();
point1.PutCoords(120.95302366645218, 31.666315738264195);
IPoint point2 = new PointClass();
point2.PutCoords(120.95300938968614, 31.666315738264195);
IPoint point3 = new PointClass();
point3.PutCoords(120.95338534452506, 31.665992131567403);
IPoint point4 = new PointClass();
point4.PutCoords(120.95251684125793, 31.665416302003994);
IPoint point5 = new PointClass();
point5.PutCoords(120.95204808743979, 31.665708975707712);
IPoint point6 = new PointClass();
point6.PutCoords(120.95302366645218, 31.666315738264195);
pointCollection.AddPoint(point1);
pointCollection.AddPoint(point2);
pointCollection.AddPoint(point3);
pointCollection.AddPoint(point4);
pointCollection.AddPoint(point5);
pointCollection.AddPoint(point6);
IRing ringOut = pointCollection as IRing;
ringOut.Close();

IGeometryCollection geometryCollection = new PolygonClass();
geometryCollection.AddGeometry(pointCollection as IGeometry);

IPolygon pPolygon = geometryCollection as IPolygon;

polygonFeature.Shape = pPolygon as IGeometry; //为新创建的要素赋予Shape属性
IFeatureSimplify2 fs2 = polygonFeature as IFeatureSimplify2;
esriNonSimpleReasonEnum ab;
fs2.get_IsSimpleGeometry(pPolygon,out ab);
fs2.SimplifyGeometry(pPolygon);
polygonFeature.Store();

//结束编辑操作
pWorkspaceEdit.StopEditOperation();
//结束编辑回话
pWorkspaceEdit.StopEditing(true); //保存该要素

要回复问题请先登录注册