Exemplo n.º 1
0
 private bool JoinField(object table, string inField, string joinTable, string joinField)
 {
     try
     {
         ESRI.ArcGIS.Geoprocessor.Geoprocessor     gp   = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
         ESRI.ArcGIS.DataManagementTools.JoinField join = new ESRI.ArcGIS.DataManagementTools.JoinField();
         join.in_data       = table;
         join.in_field      = inField;
         join.join_table    = joinTable;
         join.join_field    = joinField;
         gp.AddOutputsToMap = AppSingleton.Instance().AralariEkle;
         gp.OverwriteOutput = true;
         gp.Execute(join, null);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 导出数据shp
        /// </summary>
        /// <param name="_TablePath"></param>
        /// <param name="_TableName"></param>
        /// <returns></returns>
        public bool ExportIFeatureClass(string _TablePath, string _TableName, ProgressBar progress)
        {
            bool    isSuccess = true;
            ITable  pTable    = CreateTable(_TablePath, _TableName);
            DataRow row       = null;

            progress.Minimum = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                row = dt.Rows[i];
                IRow pRow = pTable.CreateRow();
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    pRow.set_Value(j + 1, row[dt.Columns[j]]);
                }
                progress.Value++;
                pRow.Store();
            }
            //测试//复制并添加属性链接功能
            IFeatureClass pFeatureClass = MainForm.baseData.zone_FC;
            IFeatureClass pFC           = IFeatureDataConverter_ConvertFeatureClass((pFeatureClass as IDataset).Workspace, (pTable as IDataset).Workspace, pFeatureClass.AliasName, _TableName + "_shp");

            ESRI.ArcGIS.DataManagementTools.JoinField pJoinField = new ESRI.ArcGIS.DataManagementTools.JoinField();
            pJoinField.in_data    = pFC;
            pJoinField.in_field   = MainForm.baseData.zidField;
            pJoinField.join_table = pTable;
            pJoinField.join_field = MainForm.baseData.zidField;
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            gp.OverwriteOutput = true;
            gp.Execute(pJoinField, null);
            //删除数据表
            IDataset pDataSet = pTable as IDataset;

            pDataSet.Delete();

            return(isSuccess);
        }
Exemplo n.º 3
0
        void Button_Click(object sender, EventArgs e)
        {
            #region 识别
            if ((Button)sender == btn_Identify)
            {
                m_isIdentify = !m_isIdentify;
                if (m_isIdentify)
                {
                    m_isDraw              = false;
                    m_isAddpoint          = false;
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerIdentify;
                }
                else
                {
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerArrow;
                }
                return;
            }
            #endregion
            #region  择
            if ((Button)sender == btn_select)
            {
                m_isDraw = !m_isDraw;
                if (m_isDraw)
                {
                    m_isIdentify          = false;
                    m_isAddpoint          = false;
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
                }
                else
                {
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerArrow;
                }
                return;
            }
            #endregion
            #region 链接
            if ((Button)sender == btn_link)
            {
                ;

                Geoprocessor gp = new Geoprocessor()
                {
                    OverwriteOutput = true
                };
                string table = debugDir + "\\AirQuality\\kqzlzk.dbf";
                ESRI.ArcGIS.ConversionTools.ExcelToTable pExcelToTavle = new ESRI.ArcGIS.ConversionTools.ExcelToTable()
                {
                    Input_Excel_File = debugDir + "\\AirQuality\\空气质量状况.xls",
                    Output_Table     = table,
                    Sheet            = "Sheet1"
                };
                gp.Execute(pExcelToTavle, null);

                IFeatureLayer pFeatureLayer = AeUtils.GetFeatureLayerByName(m_pMapC2.Map, "监测站");

                ESRI.ArcGIS.DataManagementTools.JoinField pJoinField = new ESRI.ArcGIS.DataManagementTools.JoinField()
                {
                    in_data    = pFeatureLayer,
                    in_field   = "Name",
                    join_table = table,
                    join_field = "NAME",
                    fields     = "StationID;PM2_5;SO2;NO2"
                };
                gp.Execute(pJoinField, null);
            }
            #endregion
            #region 注记
            if ((Button)sender == btn_anno)
            {
                IFeatureLayer pFeatureLayer = AeUtils.GetFeatureLayerByName(m_pMapC2.Map, "北京区县界");
                AeUtils.TextElementLabel(m_pMapC2, pFeatureLayer, "NAME");
            }
            #endregion
            #region 符号化
            if ((Button)sender == btn_symbol)
            {
                IFeatureLayer pFeatureLayer = AeUtils.GetFeatureLayerByName(m_pMapC2.Map, "北京区县界");
                AeUtils.UniqueValueRenderer(pFeatureLayer, "NAME", m_pMapC2, axTOCControl_main);
            }
            #endregion
            #region 保存图层
            if ((Button)sender == btn_outlyr)
            {
                IFeatureLayer  pFeatureLayer = AeUtils.GetFeatureLayerByName(m_pMapC2.Map, "北京区县界");
                SaveFileDialog sfg           = new SaveFileDialog()
                {
                    Title  = "保存图层",
                    Filter = "图层文件 (*.lyr)|*.lyr"
                };
                if (sfg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ILayerFile layerfile = new LayerFileClass();
                    layerfile.New(sfg.FileName);
                    layerfile.ReplaceContents(pFeatureLayer);
                    layerfile.Save();
                }
            }
            #endregion
            if ((Button)sender == btn_addpt)
            {
                m_isAddpoint = !m_isAddpoint;
                if (m_isAddpoint)
                {
                    m_isDraw              = false;
                    m_isIdentify          = false;
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
                }
                else
                {
                    m_pMapC2.MousePointer = esriControlsMousePointer.esriPointerArrow;
                }
            }
        }