示例#1
0
        private IGeometry mergeSmallGeos(IGeometry geo)
        {
            ITopologicalOperator4 tp4    = (ITopologicalOperator4)geo;
            IGeometryCollection   geoCol = new PolygonClass();
            IGeometry             bGeo   = tp4.Boundary;
            ISpatialFilter        spFilt = new SpatialFilter();

            spFilt.Geometry      = bGeo;
            spFilt.SearchOrder   = esriSearchOrder.esriSearchOrderSpatial;
            spFilt.GeometryField = ftrCls.ShapeFieldName;
            spFilt.SpatialRel    = esriSpatialRelEnum.esriSpatialRelContains;
            spFilt.WhereClause   = "Shape_Area <= " + minarea;
            spFilt.SubFields     = ftrCls.ShapeFieldName;
            IFeatureCursor ftrCur  = ftrCls.Search(spFilt, false);
            IFeature       ftr     = ftrCur.NextFeature();
            int            cntTest = 0;

            while (ftr != null)
            {
                IGeometry sGeo = ftr.ShapeCopy;
                geoCol.AddGeometry(sGeo);
                ftr.Delete();
                ftr = ftrCur.NextFeature();
                cntTest++;
            }
            if (cntTest > 0)
            {
                tp4.ConstructUnion((IEnumGeometry)geoCol);
            }
            return((IGeometry)tp4);
        }
示例#2
0
        public void splitPolygons(bool MergeSmallPolysWithinBoundary)
        {
            if (ftrCls == null)
            {
                Console.WriteLine("You must convert segmented raster to polygons before you can split polygons");
                return;
            }
            //Console.WriteLine("Splitting Polygons");
            IQueryFilter qryFlt = new QueryFilterClass();
            string       qry    = "Shape_Area > " + maxarea.ToString();

            qryFlt.WhereClause = qry;
            IFeatureCursor ftrCur = ftrCls.Search(qryFlt, false);
            IFeature       ftr    = ftrCur.NextFeature();

            while (ftr != null)
            {
                string           oid     = ftr.OID.ToString();
                IGeometry        geo     = ftr.ShapeCopy;
                List <IGeometry> fGeoLst = splitGeometry(geo, MergeSmallPolysWithinBoundary);
                if (insertRecords(ftrCls, ftr, fGeoLst))
                {
                    ftr.Delete();
                }
                ftr = ftrCur.NextFeature();
            }
            //Console.WriteLine("Finished splitting Polygons");
        }
示例#3
0
 /// <summary>
 /// 删除多个几何对象
 /// </summary>
 /// <param name="lyr">图层</param>
 /// <param name="fea">要素对象</param>
 /// <param name="attributes">属性集合</param>
 /// <param name="pGeo">空间对象</param>
 /// <returns>成功失败标志</returns>
 public void DelFeatures(IFeatureLayer lyr, string sql)
 {
     try
     {
         IFeatureClass Featureclass = lyr.FeatureClass;
         if (Featureclass != null)
         {
             IFeatureCursor featurecursor = PropertySearch(sql, lyr);
             IWorkspaceEdit workspace     = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
             workspace.StartEditing(false);
             workspace.StartEditOperation();
             IFeature fea = featurecursor.NextFeature();
             while (fea != null)
             {
                 fea.Delete();
                 fea = featurecursor.NextFeature();
             }
             workspace.StopEditOperation();
             workspace.StopEditing(true);
         }
     }
     catch (Exception ei)
     {
         Log.Debug("[GIS] Del Feature: " + ei.ToString());
     }
 }
示例#4
0
        //删除不是闭合的曲线
        public IFeatureLayer deleteLine(IFeatureLayer contourLayer)
        {
            IFeatureClass conLineclass = contourLayer.FeatureClass;

            IFeatureCursor pCursor = conLineclass.Search(null, false);

            IFeature pFeature = null;

            while ((pFeature = pCursor.NextFeature()) != null)
            {
                //获取等高线
                IGeometry geometry = pFeature.Shape;
                IPolyline polyline = (IPolyline)geometry;

                //定义列表存储构成等高线的点的坐标、高程
                List <IPoint> contourPoint = new List <IPoint>();

                contourPoint = getPointByContourLine(polyline);

                if (!CheckLine(contourPoint))
                {
                    //删除该等高线
                    pFeature.Delete();
                }
            }


            return(contourLayer);
        }
示例#5
0
        public void makeSinglePart(string timeStep)
        {
            IFeatureCursor      searchCurr;
            IFeatureCursor      insertCurr;
            IFeatureBuffer      insertBuff;
            IFeature            f;
            IGeometryCollection geoColl;
            int i = 1;

            mLog.Debug("inside animal map make single part");
            IFeatureClass ifc = getShapeFile("TimeStep" + timeStep);

            mLog.Debug("file we are going to work with is " + ifc.AliasName);

            searchCurr = ifc.Search(null, false);
            mLog.Debug("there are " + ifc.FeatureCount(null).ToString() + " polygons to work with");
            insertCurr = ifc.Insert(true);
            insertBuff = ifc.CreateFeatureBuffer();
            f          = searchCurr.NextFeature();

            geoColl = (IGeometryCollection)f.Shape;
            mLog.Debug("we have " + geoColl.GeometryCount + " geometries to work on");
            if (timeStep == "1")
            {
                i = 0;
            }

            for (i = 0; i < geoColl.GeometryCount; i++)
            {
                this.InsertFeature(insertCurr, insertBuff, f, geoColl.get_Geometry(i));
            }
            insertCurr.Flush();
            f.Delete();
        }
示例#6
0
        public static void UpdateFeatureGeometry(IFeature ifeature_0, IGeometry igeometry_0)
        {
            ZDEditTools.StartEditDateTime = DateTime.Now;
            IFeature feature = null;
            bool     flag    = ZDEditTools.Oids.IndexOf(ifeature_0.OID) == -1;
            bool     flag1   = flag;

            if (flag)
            {
                feature = ZDEditTools.WriteHistory(ifeature_0);
            }
            try
            {
                ifeature_0.Shape = igeometry_0;
                ifeature_0.Store();
                if (flag1)
                {
                    IFeature feature1 = ZDEditTools.ZDFeatureClass.CreateFeature();
                    RowOperator.CopyFeatureToFeature(ifeature_0, feature1);
                    ZDEditTools.Oids.Add(feature1.OID);
                    ZDEditTools.WriteHistoryLine(ifeature_0, feature1, feature, 3, ZDEditTools.StartEditDateTime);
                    ifeature_0.Delete();
                }
            }
            catch
            {
                if (feature != null)
                {
                    feature.Delete();
                }
            }
        }
示例#7
0
        private IFeature FeatureMerge(IFeatureClass pSearchFC, IGeometry pEnv, esriSpatialRelEnum spatialRel, string strGeoObjNum)
        {
            IFeature       feature       = null;
            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry    = pEnv;
            spatialFilter.SpatialRel  = spatialRel;
            spatialFilter.WhereClause = "SMSSYMBOL = '" + strGeoObjNum + "'";
            IFeatureCursor featureCursor = pSearchFC.Update(spatialFilter, false);

            if (featureCursor != null)
            {
                IFeature feature2 = featureCursor.NextFeature();
                feature = feature2;
                while (feature2 != null)
                {
                    if (feature2.OID != feature.OID)
                    {
                        feature.Shape = CommonFunction.UnionGeometry(feature.Shape, feature2.Shape);
                        feature2.Delete();
                        feature.Store();
                    }
                    feature2 = featureCursor.NextFeature();
                }
                Marshal.ReleaseComObject(featureCursor);
            }
            return(feature);
        }
示例#8
0
        //这个函数以实现要素的删除为例
        public void DeleteEdit(ref AxMapControl mapControl)
        {
            ILayer lyr; //获取编辑图层

            if ((lyr = mapControl.Map.get_Layer(0)) == null)
            {
                return;
            }
            IWorkspaceEdit pWorkspaceEdit = WorkshopEdit(lyr);//得到图层空间

            pWorkspaceEdit.StartEditOperation();
            IFeatureCursor pFeatureCursor = GetSelectedFeatures((IFeatureLayer)lyr);//获取游标
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                pFeature.Delete();
                pFeature = pFeatureCursor.NextFeature();
            }
            pWorkspaceEdit.StopEditOperation();

            IActiveView pActiveView = (IActiveView)mapControl.Map;

            pActiveView.Refresh();
        }
示例#9
0
 public override void OnClick()
 {
     try
     {
         if (MessageBox.Show("是否删除所选择的要素?", "提示", MessageBoxButtons.YesNo) != DialogResult.No)
         {
             Editor.UniqueInstance.StartEditOperation();
             IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
             IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;
             iDs.Reset();
             for (int i = iDs.Next(); i != -1; i = iDs.Next())
             {
                 IFeature editFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(i);
                 AttributeManager.AttributeDeleteHandleClass.AttributeDelete(editFeature);
                 editFeature.Delete();
             }
             this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, Editor.UniqueInstance.TargetLayer, this._hookHelper.ActiveView.Extent);
             Editor.UniqueInstance.StopEditOperation("delete");
         }
     }
     catch (Exception exception)
     {
         Editor.UniqueInstance.AbortEditOperation();
         this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Delete1", "OnClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
示例#10
0
        /// <summary>
        /// changed this to private since this need to be called only from within generate range
        /// </summary>
        private void GenerateDeadAreas()
        {
            //get the service territory
            IWorkspaceEdit pWorkspaceEdit;

            pWorkspaceEdit = (IWorkspaceEdit)this._workspace;
            try
            {
                IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;

                // ServiceTerritory mainST = new ServiceTerritory(_workspace, "MAIN");

                if (this.ServiceTerritoryFeature != null)
                {
                    IGeometry pSVGeometry = ServiceTerritoryFeature.Shape;
                    //IGeometry pRecptionGeometry = mainST.getReceptionArea();
                    //union all the signals and get one big reception area geometry

                    //edit and add to fc
                    IGeometry pDeadArea = getDeadArea();
                    //pWorkspaceEdit.StartEditing(true);

                    IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

                    pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                    pWorkspaceEdit.StartEditOperation();

                    double deadCoverage      = ((IArea)pDeadArea).Area * 100 / ((IArea)pSVGeometry).Area;
                    double receptionCoverage = 100 - deadCoverage;

                    IFeatureClass pDeadAreasFC = pFWorkspace.OpenFeatureClass("sde.DeadAreas");


                    //delete all features
                    IFeatureCursor pcursor       = pDeadAreasFC.Update(null, false);
                    IFeature       pfeaturerange = pcursor.NextFeature();
                    while (pfeaturerange != null)
                    {
                        //we need to change that later
                        pfeaturerange.Delete();
                        pfeaturerange = pcursor.NextFeature();
                    }


                    IFeature pDeadAreaFeature = pDeadAreasFC.CreateFeature();
                    pDeadAreaFeature.Shape = pDeadArea;
                    pDeadAreaFeature.Store();

                    pWorkspaceEdit.StopEditOperation();
                    pWorkspaceEdit.StopEditing(true);

                    updateCoverages(deadCoverage, receptionCoverage);
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                pWorkspaceEdit.AbortEditOperation();
            }
        }
示例#11
0
        public void eliminateSlivers()
        {
            if (ftrCls == null)
            {
                Console.WriteLine("You must convert segemented raster to a polygon before you can eliminate slivers");
                return;
            }
            Console.WriteLine("Eliminating slivers");
            IQueryFilter qryFlt = new QueryFilterClass();

            qryFlt.WhereClause = "Shape_Area < " + minarea.ToString();
            IFeatureCursor ftrCur = ftrCls.Search(qryFlt, false);
            IFeature       ftr    = ftrCur.NextFeature();

            while (ftr != null)
            {
                int oid = ftr.OID;
                if (updatePolygon(ftrCls, oid))
                {
                    ftr.Delete();
                }
                ftr = ftrCur.NextFeature();
            }
            Console.WriteLine("Finished Eliminating Slivers");
        }
示例#12
0
        private static void DeleteZD(IFeature ifeature_0)
        {
            ZDEditTools.StartEditDateTime = DateTime.Now;
            IFeature feature = ZDEditTools.WriteHistory(ifeature_0);

            ZDEditTools.WriteDelHistoryLine(ifeature_0, feature, 4, ZDEditTools.StartEditDateTime);
            ifeature_0.Delete();
        }
 public void OnClick()
 {
     try
     {
         m_Map              = m_hookHelper.FocusMap;
         m_activeView       = m_Map as IActiveView;
         m_EngineEditor     = MapManager.EngineEditor;
         m_EngineEditLayers = MapManager.EngineEditor as IEngineEditLayers;
         if (m_EngineEditor == null)
         {
             return;
         }
         if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
         {
             return;
         }
         if (m_EngineEditLayers == null)
         {
             return;
         }
         IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
         if (pFeatLyr == null)
         {
             return;
         }
         IFeatureClass pFeatCls = pFeatLyr.FeatureClass;
         if (pFeatCls == null)
         {
             return;
         }
         IFeatureCursor pFeatCur = MapManager.GetSelectedFeatures(pFeatLyr);
         if (pFeatCur == null)
         {
             MessageBox.Show("请选择要删除的要素!", "提示",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         m_EngineEditor.StartOperation();
         IFeature pFeature = pFeatCur.NextFeature();
         if (MessageBox.Show("是否删除所选要素?", "提示", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Information) == DialogResult.Yes)
         {
             while (pFeature != null)
             {
                 pFeature.Delete();
                 pFeature = pFeatCur.NextFeature();
             }
         }
         System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
         m_EngineEditor.StopOperation("DelFeatureCommand");
         m_activeView.Refresh();
     }
     catch (Exception ex)
     {
         //SysLogHelper.WriteOperationLog("要素删除错误", ex.Source, "数据编辑");
     }
 }
示例#14
0
        //删除FeatureClass中所有Feature
        public static void DeleteFeature(IFeatureClass pFeatureClass, string condtion, out Exception Error)
        {
            Error = null;
            if (pFeatureClass == null)
            {
                return;
            }
            IDataset       dataset       = pFeatureClass as IDataset;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

            workspaceEdit.DisableUndoRedo();
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();
            IFeatureCursor pFeatureCursor = null;

            if (condtion != "")
            {
                IQueryFilter pFilter = new QueryFilterClass();
                pFilter.WhereClause = condtion;
                pFeatureCursor      = pFeatureClass.Update(pFilter, false);
            }
            else
            {
                pFeatureCursor = pFeatureClass.Search(null, false);
            }
            IFeature pFeature = pFeatureCursor.NextFeature();
            int      count    = 0;

            try
            {
                while (pFeature != null)
                {
                    // pFeatureCursor.DeleteFeature();
                    pFeature.Delete();
                    count++;
                    if (count == 500)
                    {
                        pFeatureCursor.Flush();
                        count = 0;
                    }
                    pFeature = pFeatureCursor.NextFeature();
                }
                if (count > 0)
                {
                    pFeatureCursor.Flush();
                }
            }
            catch (Exception ex)
            {
                Error = ex;
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
        }
示例#15
0
        private void ImportAxfInfoForDelete(AxfInfo axfInfo)
        {
            List <AxfField> tempAxfFields = axfInfo.AxfFieldList.Where(c => c.AxfStatus == 128).ToList();

            foreach (AxfField tempAxfField in tempAxfFields)
            {
                IFeature pTargetFeature = axfInfo.TargetFeatureLayer.FeatureClass.GetFeature(tempAxfField.Objectid);
                pTargetFeature.Delete();
            }
        }
示例#16
0
        public void Delete(BaseModel BaseModel)
        {
            IFeature _feature = ((IFeatureWorkspace)_workspace).OpenFeatureClass(BaseModel.EntityName).GetFeature(((GISModel)BaseModel).ObjectId);

            _feature.Delete();

            foreach (ModelProperty _property in BaseModel.ModelProperties)
            {
                _property.Property.SetValue(BaseModel, null, null);
            }
        }
示例#17
0
        private void DeleteInOperation(IFeature featureToDelete, IEditOperationObserver observer)
        {
            observer.StartedOperation();

            featureToDelete.Delete();

            observer.Deleting(featureToDelete);

            observer.IsCompletingOperation = true;
            observer.CompletingOperation();
            observer.IsCompletingOperation = false;
        }
示例#18
0
        public override void OnClick()
        {
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }

            IFeatureLayer tmpFeatureLayer = getEditLayer.isExistLayer(_AppHk.MapControl.Map) as IFeatureLayer;

            if (tmpFeatureLayer == null || tmpFeatureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPoint)
            {
                MessageBox.Show("请设置编辑图层为点图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            IWorkspaceEdit iWE = (tmpFeatureLayer.FeatureClass as IDataset).Workspace as IWorkspaceEdit;

            if (!iWE.IsBeingEdited())
            {
                iWE.StartEditing(false);
            }
            ISelectionSet iSS = (tmpFeatureLayer as IFeatureSelection).SelectionSet;
            ICursor       iCursor;

            iSS.Search(null, false, out iCursor);
            IFeatureCursor iFC        = iCursor as IFeatureCursor;
            IFeature       tmpFeature = iFC.NextFeature();

            if (tmpFeature == null)
            {
                return;
            }
            if (tmpFeature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                MessageBox.Show("请选择点要素!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("是否删除选择的点!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
            {
                return;
            }
            while (tmpFeature != null)
            {
                tmpFeature.Delete();
                tmpFeature = iFC.NextFeature();
            }
            iWE.StopEditing(true);
            iWE = null;
            _AppHk.MapControl.ActiveView.Refresh();
        }
示例#19
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (m_pCurFeature != null)
     {
         if (MessageBox.Show(string.Format("确认删除工程:{0}!", m_pCurFeature.get_Value(m_pCurFeature.Fields.FindField("任务号"))), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
         {
             m_pCurFeature.Delete();
             dataGridView1.Rows.RemoveAt(m_nCurRowIndex);
         }
     }
     EngineFuntions.m_AxMapControl.ActiveView.Refresh();
 }
示例#20
0
        public static bool UpdateZDAttribute(IFeature ifeature_0, string string_0, object object_0,
                                             out IFeature ifeature_1)
        {
            ZDEditTools.StartEditDateTime = DateTime.Now;
            Editor.StartEditOperation();
            IWorkspace workspace = AppConfigInfo.GetWorkspace();

            if (!WorkspaceOperator.WorkspaceIsSame(workspace, Editor.EditWorkspace as IWorkspace))
            {
                (workspace as IWorkspaceEdit).StartEditOperation();
            }
            ifeature_1 = null;
            bool     flag    = ZDEditTools.Oids.IndexOf(ifeature_0.OID) == -1;
            IFeature feature = null;

            if (flag)
            {
                feature = ZDEditTools.WriteHistory(ifeature_0);
            }
            bool flag1 = true;

            try
            {
                ifeature_0.Value[ifeature_0.Fields.FindField(string_0)] = object_0;
                ifeature_0.Store();
                if (flag)
                {
                    IFeature feature1 = ZDEditTools.ZDFeatureClass.CreateFeature();
                    RowOperator.CopyFeatureToFeature(ifeature_0, feature1);
                    ZDEditTools.Oids.Add(feature1.OID);
                    ifeature_1 = feature1;
                    ZDEditTools.WriteHistoryLine(ifeature_0, feature1, feature, 5, ZDEditTools.StartEditDateTime);
                    ifeature_0.Delete();
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (feature != null)
                {
                    feature.Delete();
                }
                flag1 = false;
                MessageBox.Show("输入数据格式错误");
                // CErrorLog.writeErrorLog(null, exception, "");
            }
            if (!WorkspaceOperator.WorkspaceIsSame(workspace, Editor.EditWorkspace as IWorkspace))
            {
                (workspace as IWorkspaceEdit).StopEditOperation();
            }
            Editor.StopEditOperation();
            return(flag1);
        }
示例#21
0
 // protected ArcGisPublic agp = new ArcGisPublic();
 private void button2_Click(object sender, EventArgs e)
 {
     if (ifeat != null)
     {
         ifeat.Delete();
         associateMapControl.ActiveView.Refresh();
     }
     else
     {
         MessageBox.Show("请选择数据删除!");
     }
 }
示例#22
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                setalllayerSelectable();
                IFeatureLayer featurelayer = eep.TargetLayer as IFeatureLayer;
                if (featurelayer == null)
                {
                    MessageBox.Show("请启动编辑!并选择目标图层!"); return;
                }
                IPoint pt = activeview.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                ITopologicalOperator topo = pt as ITopologicalOperator;
                IGeometry            pGeo = topo.Buffer(5);
                pt.SpatialReference = map.SpatialReference;
                ISpatialFilter sf = new SpatialFilterClass();
                sf.Geometry      = pGeo;
                sf.GeometryField = featurelayer.FeatureClass.ShapeFieldName;
                switch (featurelayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint: sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; break;

                case esriGeometryType.esriGeometryPolyline: sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses; break;

                case esriGeometryType.esriGeometryPolygon: sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; break;
                }

                IFeatureSelection pfs = featurelayer as IFeatureSelection;
                pfs.SelectFeatures(sf, esriSelectionResultEnum.esriSelectionResultNew, true);
                ISelectionSet ss = pfs.SelectionSet;
                ICursor       pcursor;
                ss.Search(null, true, out pcursor);
                IFeatureCursor pfcursor = pcursor as IFeatureCursor;
                IFeature       pfeature = pfcursor.NextFeature();
                if (pfeature != null)
                {
                    activeview.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, activeview.Extent);
                    DialogResult result;
                    result = MessageBox.Show("确定删除该要素?", "Question Dialog", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (DialogResult.Yes == result)
                    {
                        pfeature.Delete(); activeview.Refresh();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("未选中要素"); return;
                }
            }
        }
示例#23
0
        public static bool UpdateZDAttribute(IFeature ifeature_0, string string_0, object object_0,
                                             out IFeature ifeature_1)
        {
            ZDEditTools.StartEditDateTime = System.DateTime.Now;
            Editor.Editor.StartEditOperation();
            IWorkspace workspace = AppConfigInfo.GetWorkspace();

            if (!WorkspaceOperator.WorkspaceIsSame(workspace, Editor.Editor.EditWorkspace as IWorkspace))
            {
                (workspace as IWorkspaceEdit).StartEditOperation();
            }
            ifeature_1 = null;
            bool     flag    = ZDEditTools.Oids.IndexOf(ifeature_0.OID) == -1;
            IFeature feature = null;

            if (flag)
            {
                feature = ZDEditTools.WriteHistory(ifeature_0);
            }
            bool result = true;

            try
            {
                int index = ifeature_0.Fields.FindField(string_0);
                ifeature_0.set_Value(index, object_0);
                ifeature_0.Store();
                if (flag)
                {
                    IFeature feature2 = ZDEditTools.ZDFeatureClass.CreateFeature();
                    RowOperator.CopyFeatureToFeature(ifeature_0, feature2);
                    ZDEditTools.Oids.Add(feature2.OID);
                    ifeature_1 = feature2;
                    ZDEditTools.WriteHistoryLine(ifeature_0, feature2, feature, 5, ZDEditTools.StartEditDateTime);
                    ifeature_0.Delete();
                }
            }
            catch (System.Exception exception_)
            {
                if (feature != null)
                {
                    feature.Delete();
                }
                result = false;
                System.Windows.Forms.MessageBox.Show("输入数据格式错误");
                //Logger.Current.Error("", exception_, "");
            }
            if (!WorkspaceOperator.WorkspaceIsSame(workspace, Editor.Editor.EditWorkspace as IWorkspace))
            {
                (workspace as IWorkspaceEdit).StopEditOperation();
            }
            Editor.Editor.StopEditOperation();
            return(result);
        }
示例#24
0
        public override void OnClick()
        {
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }
            IFeatureLayer tmpFeatureLayer = getEditLayer.isExistLayer(_AppHk.MapControl.Map) as IFeatureLayer;

            if (tmpFeatureLayer == null)
            {
                MessageBox.Show("请设置编辑图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            IWorkspaceEdit iWE = (tmpFeatureLayer.FeatureClass as IDataset).Workspace as IWorkspaceEdit;

            if (!iWE.IsBeingEdited())
            {
                iWE.StartEditing(false);
            }
            ISelectionSet iSS = (tmpFeatureLayer as IFeatureSelection).SelectionSet;
            ICursor       iCursor;

            iSS.Search(null, false, out iCursor);
            IFeatureCursor iFC        = iCursor as IFeatureCursor;
            IFeature       tmpFeature = iFC.NextFeature();

            if (tmpFeature == null)
            {
                MessageBox.Show("请选择编辑图层上要删除的图元!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("是否删除选择的图元!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
            {
                return;
            }
            iWE.StartEditOperation();
            while (tmpFeature != null)
            {
                tmpFeature.Delete();
                tmpFeature = iFC.NextFeature();
            }
            iWE.StopEditOperation();
            Plugin.LogTable.Writelog(Caption);
            //iWE.StopEditing(true);
            iWE = null;
            _AppHk.MapControl.ActiveView.Refresh();
        }
示例#25
0
 private void ToolStripMenuItemDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否删除当前要素?", "删除询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         IFeature feature = this.mFeatureClass.GetFeature(Convert.ToInt32(this.dataGridViewX1.Rows[this.mCurrentRowIndex].Cells[this.mFeatureClass.OIDFieldName].Value));
         if (feature != null)
         {
             feature.Delete();
             this.dataGridViewX1.Rows.RemoveAt(this.mCurrentRowIndex);
         }
         this.mMapControl.Refresh((esriViewDrawPhase)0xffff, Missing.Value, Missing.Value);
     }
 }
示例#26
0
        public override void OnClick()
        {
            Dictionary <IGeometry, IElement> ges = new Dictionary <IGeometry, IElement>();

            MoData.v_CurWorkspaceEdit.StartEditOperation();

            IEnumFeature features = myHook.MapControl.Map.FeatureSelection as IEnumFeature;

            features.Reset();
            IFeature feature = features.Next();

            while (feature != null)
            {
                IDataset       pDataset       = feature.Class as IDataset;
                IWorkspaceEdit pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;
                if (pWorkspaceEdit.IsBeingEdited())
                {
                    IElement ele = null;
                    if (feature is IAnnotationFeature)
                    {
                        IAnnotationFeature af = feature as IAnnotationFeature;
                        ele = af.Annotation;
                    }

                    ges.Add(feature.ShapeCopy, ele);
                    try
                    {
                        feature.Delete();
                    }
                    catch (Exception eError)
                    {
                        //******************************************
                        //guozheng added System Exception log
                        if (SysCommon.Log.Module.SysLog == null)
                        {
                            SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                        }
                        SysCommon.Log.Module.SysLog.Write(eError);
                        //******************************************

                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("Ìáʾ", "¼ôÇÐʧ°Ü£¡\nÇëʹÓá®Êý¾Ý±à¼­¡¯Öеġ®ÒªËر༭¡¯Ñ¡ÔñÒªËؽøÐмôÇвÙ×÷¡£");
                    }
                }
                feature = features.Next();
            }

            MoData.v_CurWorkspaceEdit.StopEditOperation();
            ControlsPaste.GeometriesToBePasted = ges;

            myHook.MapControl.ActiveView.Refresh();
        }
示例#27
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            if (_context.Config.EngineSnapEnvironment.SnapToleranceUnits ==
                esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
            {
                _tolerance = ArcGIS.Common.Helpers.CommonHelper.ConvertPixelsToMapUnits(_context.ActiveView,
                                                                                        _tolerance);
            }
            this.SelectByClick(x, y);
            IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;

            _pointFeature = enumFeature.Next();
            IPoint linkPoint = _pointFeature?.Shape as IPoint;

            if (linkPoint == null)
            {
                return;
            }
            this.SelectByShape(linkPoint);
            IFeatureSelection featureSelection = _lineFeatureLayer as IFeatureSelection;
            ICursor           cursor;

            featureSelection.SelectionSet.Search(null, false, out cursor);

            if ((_lineFeature1 = cursor.NextRow() as IFeature) == null)
            {
                return;
            }
            if ((_lineFeature2 = cursor.NextRow() as IFeature) == null)
            {
                return;
            }
            FrmDeletePipeline frm = new FrmDeletePipeline(_lineFeature1, _lineFeature2, linkPoint, _lineFeatureLayer);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                _pointFeature.Delete();
                _lineFeature1.Delete();
                _lineFeature2.Delete();
                int      oid     = frm.FeatureOID;
                IFeature feature = _lineFeatureLayer.FeatureClass.GetFeature(oid);
                _context.FocusMap.ClearSelection();
                _context.FocusMap.SelectFeature(_lineFeatureLayer, feature);
                _context.ActiveView.Refresh();
            }
        }
示例#28
0
        private void  除控制点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ISelection   pSeletion    = axMapControl1.Map.FeatureSelection;
            IEnumFeature pEnumFeature = (IEnumFeature)pSeletion;

            IFeature pFeature = pEnumFeature.Next();

            while (pFeature != null && pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                pFeature.Delete();
                pFeature = pEnumFeature.Next();
            }
            axMapControl1.Refresh();
        }
示例#29
0
        /// <summary>
        /// Will take a given polygon and 'cookie cut' it into the chosen layer
        /// </summary>
        /// <param name="homesite_polygon"></param>
        private void StampPolygonIntoHomesiteLayer(IPolygon homesite_polygon)
        {
            try
            {
                IFeatureLayer featureLayer = _utilitiesArcMap.FeatureLayer(cbo_featureclass.Text);
                IFeatureClass featureClass = featureLayer.FeatureClass;

                _editor.StartOperation();

                ISpatialFilter spatialFilter = new SpatialFilter();
                spatialFilter.GeometryField = featureClass.ShapeFieldName;
                spatialFilter.Geometry      = homesite_polygon;
                spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false);
                IFeature       feature       = null;

                while ((feature = featureCursor.NextFeature()) != null)
                {
                    ITopologicalOperator topologicalOperator = feature.Shape as ITopologicalOperator;
                    IGeometry            geometry            = topologicalOperator.Difference(homesite_polygon);
                    IPolygon             polygon             = geometry as IPolygon;


                    IFeature newFeature = featureClass.CreateFeature();
                    newFeature.Shape = polygon as IPolygon;

                    // This caused a problem with memory allocation. It would not delete the orignal data.
                    ArrayList fields = _utilitiesArcMap.NumberFieldsWithDomain(featureLayer);

                    // Set the attribute back to the old ones.
                    foreach (string field in fields)
                    {
                        newFeature.set_Value(newFeature.Fields.FindField(field), feature.get_Value(feature.Fields.FindField(field)));
                    }


                    newFeature.Store();
                    feature.Delete();
                }

                IFeature homesite = featureClass.CreateFeature();
                homesite.Shape = homesite_polygon;
                homesite.Store();

                _editor.StopOperation("Homesite");
            } catch (Exception ex)
            {
                RS_Tools.Utilities.Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE);
            }
        }
示例#30
0
 public void DeleteJZD(IList <JZD> jzds)
 {
     if (jzds != null)
     {
         foreach (JZD jzd in jzds)
         {
             IFeature feature = jzd.Feature;
             if (feature != null)
             {
                 feature.Delete();
             }
         }
     }
 }
示例#31
0
        private static Dictionary<string, string> StoreOldRoads(IList<IPolyline> lines, IFeature f, IFeatureClass fc, IFeatureClass crossFC, DateTime createDate)
        {
            var ret = new Dictionary<string, string>();
            if (lines.Count < 2) return ret;
            var geo = f.ShapeCopy as IPolyline;

            var cursor = fc.Insert(true);
            var idIndex = cursor.FindField(IDFieldName);
            var pidIndex = cursor.FindField(ParentIDFieldName);
            var dtIndex = cursor.FindField(CreateTimeFieldName);
            var fromIndex = cursor.FindField(FromNodeFieldName);
            var toIndex = cursor.FindField(ToNodeFieldName);
            var id = GetNewId(fc);
            foreach (var line in lines)
            {
                var pc = line as IPointCollection;
                var fromNO = CreateOrGetCrossingNo(pc.Point[0], crossFC, 0.000012);
                var toNO = CreateOrGetCrossingNo(pc.Point[pc.PointCount - 1], crossFC, 0.000012);

                var buff = fc.CreateFeatureBuffer();
                ret.Add(id.ToString(), f.get_Value(idIndex).ToString());
                buff.Shape = line;
                CopyFields(f, buff);
                buff.set_Value(idIndex, id);
                buff.set_Value(pidIndex, f.get_Value(idIndex));
                buff.set_Value(dtIndex, createDate);

                buff.set_Value(fromIndex, fromNO);
                buff.set_Value(toIndex, toNO);

                cursor.InsertFeature(buff);
                cursor.Flush();
                id++;
            }

            Marshal.ReleaseComObject(cursor);
            f.Delete();
            return ret;
        }
示例#32
0
        /// <summary>
        /// 删除几何对象
        /// </summary>
        /// <params name="lyr">图层</params>
        /// <params name="fea">要素对象</params>
        /// <params name="attributes">属性集合</params>
        /// <params name="pGeo">空间对象</params>
        /// <returns>成功失败标志</returns>
        public void DelFeature(IFeatureLayer lyr, IFeature fea)
        {
            try
            {
                IFeatureClass Featureclass = lyr.FeatureClass;
                if (Featureclass != null)
                {
                    IWorkspaceEdit workspace = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
                    if (fea != null)
                    {
                        workspace.StartEditing(false);
                        workspace.StartEditOperation();

                        fea.Delete();
                        workspace.StopEditOperation();
                        workspace.StopEditing(true);
                    }
                }
            }
            catch (Exception ei)
            {
                Log.Debug("[GIS] Del Feature1: " + ei.ToString());
            }
        }
示例#33
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
                return;

            IPoint pMousePnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            pMousePnt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pMousePnt);
            IGeometry pgeo = GIS.Common.DataEditCommon.g_pMyMapCtrl.TrackRectangle() as IGeometry;
            if (pgeo.IsEmpty)
                return;
            mGeo = pgeo;
            m_hookHelper.FocusMap.SelectByShape(pgeo, null, false);

            m_FeatureTrim = GetTrimLine();
            if (m_FeatureTrim != null)
            {
                if (TrimLine(m_FeatureTrim, m_FeatureRef, pMousePnt))   //��ʼ�ü�,���ϳɹ�����ɾ��ѡ�����
                {
                    m_hookHelper.FocusMap.SelectByShape(pgeo, null, false);
                    m_FeatureTrim = GetTrimLine();
                    if (m_engineEditor != null)
                    {
                        m_engineEditor.StartOperation();
                        m_FeatureTrim.Delete();
                        m_engineEditor.StopOperation("Delete Features");
                    }
                }
            }
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, m_hookHelper.ActiveView.Extent);
        }