首页 > 代码库 > Arcengine 基本操作(待更新)
Arcengine 基本操作(待更新)
/// <summary> /// 删除fieldName属性值为1的弧段 /// </summary> /// <param name="fieldName"></param> /// <param name="t"></param> public void DelectPolyline(string fieldName, int t) { ILayer pLayer = axMapControl1.get_Layer(0); IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IFields pIFields = pFeatureLayer.FeatureClass.Fields; int fieldIndex = pIFields.FindField(fieldName); var pDataset = pFeatureClass as IDataset; IWorkspace pWorkspace = pDataset.Workspace; IFeatureWorkspace pFWs = pWorkspace as IFeatureWorkspace; IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pFWs; pWorkspaceEdit.StartEditing(true); pWorkspaceEdit.StartEditOperation(); IFeatureCursor pEF = pFeatureLayer.Search(null, false); IFeature pFeatureDe = pEF.NextFeature(); while (pFeatureDe != null) { if (Convert.ToInt32(pFeatureDe.get_Value(fieldIndex)) != t) { pFeatureDe.Delete(); } pFeatureDe = pEF.NextFeature(); } pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); MessageBox.Show("删除成功"); }
///若干个线要素合并成一个 private void MergeFeatures(List<int> OneFeatureArr,ILayer tSelectLayer) { IFeatureLayer tFeatureLayer = tSelectLayer as IFeatureLayer; IFeatureClass pFeatureClass = tFeatureLayer.FeatureClass; var pDataset = pFeatureClass as IDataset; IWorkspace pWorkspace = pDataset.Workspace; IFeatureWorkspace pFWs = pWorkspace as IFeatureWorkspace; IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pFWs; pWorkspaceEdit.StartEditing(true); pWorkspaceEdit.StartEditOperation(); IFeatureLayer pFeatureLayer = tSelectLayer as IFeatureLayer; IFeatureCursor pEF = pFeatureLayer.Search(null, false); IFeature pFeatureFirst = pEF.NextFeature(); while (pFeatureFirst != null) {//找到在数组里的第一个要素 if (pFeatureFirst.OID == OneFeatureArr[0]) { //OneFeatureArr.RemoveAt(0);//除掉第一个要素 break; } else pFeatureFirst = pEF.NextFeature(); } pEF = pFeatureLayer.Search(null, false); IGeometry pGeometryFirst = pFeatureFirst.Shape; ITopologicalOperator2 pTopOperatorFirst = (ITopologicalOperator2)pGeometryFirst; IRelationalOperator pRelOperatorFirst = (IRelationalOperator)pGeometryFirst; pTopOperatorFirst.IsKnownSimple_2 = false; pTopOperatorFirst.Simplify(); pGeometryFirst.SnapToSpatialReference(); IGeometry pGeometrySecond = null; IFeature pFeatureSecond = pEF.NextFeature(); IGeometryCollection Geometrybag = new GeometryBagClass();//装geometry的袋子 object oMissing = Type.Missing; while (pFeatureSecond != null) { if (OneFeatureArr.IndexOf(pFeatureSecond.OID) == -1) { pFeatureSecond = pEF.NextFeature(); continue; } pGeometrySecond = pFeatureSecond.ShapeCopy; Geometrybag.AddGeometry(pGeometrySecond, ref oMissing, ref oMissing);//将geometry装进袋子 //pFeatureSecond.Delete(); pFeatureSecond = pEF.NextFeature(); } IEnumGeometry tEnumGeometry = (IEnumGeometry)Geometrybag; pTopOperatorFirst.ConstructUnion(tEnumGeometry); pTopOperatorFirst.IsKnownSimple_2 = false; pTopOperatorFirst.Simplify(); pFeatureFirst.Shape = pGeometryFirst; pFeatureFirst.Store(); pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); }
Arcengine 基本操作(待更新)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。