你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
朱新颖
赞同来自:
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); //保存该要素
要回复问题请先登录或注册
1 个回复
朱新颖
赞同来自:
通过使用IFeatureSimplify2.SimplifyGeometry();可以解决该问题,结果与ArcMap中一致,测试代码如下:
要回复问题请先登录或注册