Beispiel #1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            double offsetValue = -1;

            try
            {
                offsetValue = Convert.ToDouble(textEdit1.Text);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("请输入数值类型", "提示信息", MessageBoxButtons.OK);
                return;
            }
            try
            {
                //启动编辑
                IFeatureLayer featureLayer  = mLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = featureLayer.FeatureClass;

                IWorkspace    workspace     = null;
                IEngineEditor mEngineEditor = mEngineEditor = new EngineEditorClass();
                if (pFeatureClass.FeatureDataset != null)
                {
                    workspace = pFeatureClass.FeatureDataset.Workspace;
                    mEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned;
                    mEngineEditor.StartEditing(workspace, mMap);
                    ((IEngineEditLayers)mEngineEditor).SetTargetLayer(featureLayer, -1);
                    mEngineEditor.StartOperation();
                }



                ISelectionSet mSelectionSet = (mLayer as IFeatureSelection).SelectionSet;
                ICursor       mCursor;
                mSelectionSet.Search(null, false, out mCursor);

                IFeature mFeature = mCursor.NextRow() as IFeature;
                while (mFeature != null)
                {
                    IGeometry  geometry  = mFeature.ShapeCopy;
                    IPolycurve polycurve = geometry as IPolycurve;
                    polycurve.Smooth(offsetValue);
                    mFeature.Shape = polycurve as IGeometry;
                    mFeature.Store();
                    mFeature = mCursor.NextRow() as IFeature;
                }
                if (workspace != null)
                {
                    mEngineEditor.StopEditing(true);
                }

                this.Dispose();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("平滑失败", "提示信息", MessageBoxButtons.OK);
            }
        }
Beispiel #2
0
 public override void OnClick()
 {
     try
     {
         frmMaxAllowableOffset _frmMaxAllowableOffset = new frmMaxAllowableOffset()
         {
             Text = "平滑"
         };
         if (_frmMaxAllowableOffset.ShowDialog() == DialogResult.OK)
         {
             double       maxAllowableOffset = _frmMaxAllowableOffset.MaxAllowableOffset;
             IEnumFeature featureSelection   = _context.FocusMap.FeatureSelection as IEnumFeature;
             featureSelection.Reset();
             IFeature       feature       = featureSelection.Next();
             IWorkspaceEdit editWorkspace = Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace;
             editWorkspace.StartEditOperation();
             IPolycurve shape = null;
             while (feature != null)
             {
                 shape = feature.Shape as IPolycurve;
                 if (shape != null && editWorkspace == (feature.Class as IDataset).Workspace)
                 {
                     shape.Smooth(maxAllowableOffset);
                     feature.Shape = shape;
                     feature.Store();
                 }
                 feature = featureSelection.Next();
             }
             editWorkspace.StopEditOperation();
             _context.ActiveView.Refresh();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }