Пример #1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ExportToFGDB.OnClick implementation
            IMapControl3        mapcontrol3 = m_hookHelper.Hook as IMapControl3;
            ILayer              pLayer      = (ILayer)mapcontrol3.CustomProperty;
            FolderBrowserDialog fd          = new FolderBrowserDialog();

            if (fd.ShowDialog() == DialogResult.OK)
            {
            }
            {
                IWorkspace    pWorkspace   = Utilities.WorkspaceHelper.GetFGDBWorkspace(fd.SelectedPath);
                IFeatureLayer featureLayer = pLayer as IFeatureLayer;
                ArcGISUtilities.CopyData(featureLayer.FeatureClass, pWorkspace, featureLayer.Name);
            }
        }
Пример #2
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add UpdateAreaPrimeter.OnClick implementation


            IFeatureLayer pLayer = m_pLayer as IFeatureLayer;

            if (pLayer == null)
            {
                return;
            }
            IFeatureClass pFC = pLayer.FeatureClass;

            ArcGISUtilities.UpdateAreaAndPrim(pFC);
            MessageBox.Show("成功更新");
        }
Пример #3
0
        private void butOk_Click(object sender, EventArgs e)
        {
            if (this.CheckingInput())
            {
                Application.DoEvents();
                this.comboxlayer.Enabled  = false;
                this.comboxFiled.Enabled  = false;
                this.comboClss1.Enabled   = false;
                this.comboClss2.Enabled   = false;
                this.textBox1.Enabled     = false;
                this.button1.Enabled      = false;
                this.butOk.Enabled        = false;
                this.progressBar1.Visible = true;
                this.progressBar1.Minimum = 0;


                ILayer   layer    = this.MapLayer[this.comboxlayer.SelectedIndex];
                IDataset pDataSet = (layer as IFeatureLayer).FeatureClass as IDataset;
                //string outputDir = System.Environment.CurrentDirectory + "\\Default.gdb";
                IWorkspace pWorkspace = Utilities.WorkspaceHelper.GetShapefileWorkspace(MainForm.outshape);
                //
                IEnumDataset pDataSetsEnum = pWorkspace.get_Datasets(esriDatasetType.esriDTAny);
                IDataset     pDataTM       = pDataSetsEnum.Next();
                while (pDataTM != null)
                {
                    if (pDataTM.Name == "temp")
                    {
                        if (pDataTM.CanDelete())
                        {
                            pDataTM.Delete();
                            break;
                        }
                        else
                        {
                            MessageBox.Show("请检查是否处于打开状态!");
                            return;
                        }
                    }

                    pDataTM = pDataSetsEnum.Next();
                }
                ArcGISUtilities.CopyData((layer as IFeatureLayer).FeatureClass, pWorkspace, "temp");
                IEnumDataset pEnumDS = pWorkspace.get_Datasets(esriDatasetType.esriDTAny);

                IFeatureClass  featureClass = ArcGISUtilities.GetDatasetByName(pEnumDS, "temp") as IFeatureClass;
                IQueryFilter   pQueryFilter = null;
                IFeatureCursor pFCursor     = null;



                int index = featureClass.Fields.FindField(comboxFiled.Text);
                if (index < 0)
                {
                    MessageBox.Show("请检查数据是否含分类码或检查编码文件.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                foreach (ListViewItem lvi in listView1.Items)
                {
                    string code = lvi.Text;
                    if (code.Substring(0, 1) == "0" || code.Substring(0, 1) == "1")
                    {
                        string temp = lvi.Text.Substring(2, 2);
                        //一级类
                        if (temp == "00")
                        {
                            code         = code.Substring(0, 2);
                            pQueryFilter = new QueryFilterClass();
                            //pQueryFilter.WhereClause = "[" + comboxFiled.Text + "]" + " LIKE " + "\'" + code + "**" + "\'";//GeoDatase中
                            pQueryFilter.WhereClause = comboxFiled.Text + " LIKE " + "\'" + code + "__" + "\'";
                            pFCursor = featureClass.Update(pQueryFilter, false);
                            IFeature pFeat = pFCursor.NextFeature();
                            while (pFeat != null)
                            {
                                pFeat.set_Value(index, lvi.Text);
                                pFCursor.UpdateFeature(pFeat);
                                pFeat = pFCursor.NextFeature();
                            }
                        }
                        //二级类
                        else if (temp.Substring(1, 1) == "0")
                        {
                            code                     = code.Substring(0, 3);
                            pQueryFilter             = new QueryFilterClass();
                            pQueryFilter.WhereClause = "[" + comboxFiled.Text + "]" + " LIKE " + "\'" + code + "*" + "\'";
                            pFCursor                 = featureClass.Update(pQueryFilter, false);
                            IFeature pFeat = pFCursor.NextFeature();
                            while (pFeat != null)
                            {
                                pFeat.set_Value(index, lvi.Text);
                                pFCursor.UpdateFeature(pFeat);
                                pFeat = pFCursor.NextFeature();
                            }
                        }
                    }

                    this.progressBar1.Value += 1;
                }

                ////////////////////////////////////////////////////////////////////////////////////////////////////
                Application.DoEvents();
                this.progressBar1.Value = 70;
                IFeatureClass pFeatureClass = null;

                VectorOperation operation = new VectorOperation();

                pFeatureClass = operation.Dissolv(featureClass, comboxFiled.Text, textBox1.Text.Trim(), this.textBox2.Text.Trim()
                                                  , this.progressBar1);

                IFeatureLayer pLayer = new FeatureLayerClass
                {
                    FeatureClass = pFeatureClass,
                    Name         = pFeatureClass.AliasName
                };

                this.m_axMapControl.AddLayer(pLayer);
                this.m_axMapControl.ActiveView.Refresh();
                //释放资源
                if (pFCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFCursor);
                }
                if (pQueryFilter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pQueryFilter);
                }
                if (featureClass != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass);
                }

                MessageBox.Show(pLayer.Name + "处理完成!");
                base.Close();
            }
        }
Пример #4
0
        /// <summary>
        /// 初始化一二级分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboxFiled_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboClss1.Items.Count > 0)
            {
                comboClss1.Items.Clear();
            }
            if (comboClss2.Items.Count > 0)
            {
                comboClss2.Items.Clear();
            }
            ILayer        layer         = this.MapLayer[this.comboxlayer.SelectedIndex];
            IFeatureClass pFeatureClass = (layer as IFeatureLayer).FeatureClass;
            IFields       pFields       = pFeatureClass.Fields;

            string fieldName = comboxFiled.Text;

            if (fieldName == "")
            {
                return;
            }

            //组合二级类别
            IEnumerator   pEnumerator = ArcGISUtilities.GetUniqueValue(pFeatureClass, fieldName);
            List <string> classes     = new List <string>();
            List <string> firstclass  = new List <string>();

            pEnumerator.Reset();
            while (pEnumerator.MoveNext())
            {
                string tempcode = pEnumerator.Current.ToString();
                classes.Add(pEnumerator.Current.ToString().Substring(0, 3).PadRight(4, '0'));
            }
            object[] clss2 = FragStats.Stats.GetDistinctValues(classes);//二级类的唯一值
            for (int i = 0; i < clss2.Length; i++)
            {
                firstclass.Add(clss2[i].ToString().Substring(0, 2).PadRight(4, '0'));

                string temp = clss2[i].ToString().Substring(2, 2);
                if (temp == "00")
                {
                    continue;
                }
                if (MainForm.pData.ContainsKey(clss2[i].ToString()))
                {
                    comboClss2.Items.Add(MainForm.pData[clss2[i].ToString()]);
                }
            }

            comboClss2.Text = "";
            //组合一级类别
            object[] clss1 = FragStats.Stats.GetDistinctValues(firstclass);
            for (int i = 0; i < clss1.Length; i++)
            {
                if (MainForm.pData.ContainsKey(clss1[i].ToString()))
                {
                    comboClss1.Items.Add(MainForm.pData[clss1[i].ToString()]);
                }
            }
            comboClss1.Text = "";
            //释放资源
            // System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClass);
            //System.Runtime.InteropServices.Marshal.ReleaseComObject(pEnumerator);
        }