private void ImportRaster()
        {
            Geoprocessor gp = new Geoprocessor(); //定义处理对象

            gp.OverwriteOutput = true;            //覆盖输出
            RasterToGeodatabase pRasterToGeodatabase = new RasterToGeodatabase();

            try
            {
                UIWaiting("正在导入" + this.textBox1.Text + "层");
                Application.DoEvents();

                FileInfo fileInfo = new FileInfo(this.textBox1.Text.ToString());
                string   fpath    = fileInfo.DirectoryName;
                string   fname    = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));

                pRasterToGeodatabase.Input_Rasters      = this.textBox1.Text;
                pRasterToGeodatabase.Output_Geodatabase = m_FGDB;
                gp.Execute(pRasterToGeodatabase, null);

                IRasterWorkspaceEx rasterWS = m_workSpace as IRasterWorkspaceEx;
                IRasterDataset     rasterDS = rasterWS.OpenRasterDataset(fname);
                IDataset           ds       = rasterDS as IDataset;
                ds.Rename(this.m_place + "_" + this.m_satelite + "_" + this.m_time);


                m_gdata.InsertMataData(this.m_place + "_" + this.m_satelite + "_" + this.m_time, m_satelite, this.m_time, "2", this.m_place);
                Application.DoEvents();

                MessageBox.Show("入库成功!", "提示");
                frm.Close();
                this.Close();
                UIWaiting("");
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
                return;
            }
        }
Exemple #2
0
        private void Importshp()
        {
            IFeatureWorkspace feaworkspace;
            FileInfo          fileInfo;
            string            path;
            string            name;
            string            shapetype = "";

            if (this.m_type == "解译数据")
            {
                try
                {
                    fileInfo = new FileInfo(this.path);
                    string fpath = fileInfo.DirectoryName;
                    string fname = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));
                    //UIWaiting("正在导入"+name+"层");
                    frm.WaitingLabel = "正在导入" + fname + "层";
                    Application.DoEvents();

                    feaworkspace = m_gcon.OpenSHPWorkspace(fpath);
                    IFeatureClass feaFC = feaworkspace.OpenFeatureClass(fname);
                    if (feaFC.FeatureType == esriFeatureType.esriFTSimple)
                    {
                        IFeatureWorkspace feaworkspaceSDE = this.m_workSpace as IFeatureWorkspace;
                        Application.DoEvents();
                        m_gdata.ConvertFeatureClassToGDB((IWorkspace)feaworkspace, (IWorkspace)feaworkspaceSDE, fname, this.m_place + "_" + this.m_interType + "_" + this.m_time, null);
                        Application.DoEvents();
                        switch (feaFC.ShapeType)
                        {
                        case esriGeometryType.esriGeometryPoint:
                            shapetype = "point";
                            break;

                        case esriGeometryType.esriGeometryPolyline:
                            shapetype = "line";
                            break;

                        case esriGeometryType.esriGeometryPolygon:
                            shapetype = "polygon";
                            break;

                        default:
                            shapetype = "else";
                            break;
                        }
                        m_gdata.InsertInterpData(shapetype, this.m_place, this.m_time, this.m_interType);
                        Application.DoEvents();
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                    return;
                }
                MessageBox.Show("导入已成功完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frm.Close();
                this.Close();
            }
            else
            {
                try
                {
                    fileInfo = new FileInfo(this.path);
                    string fpath = fileInfo.DirectoryName;
                    string fname = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));
                    //UIWaiting("正在导入"+name+"层");
                    frm.WaitingLabel = "正在导入" + fname + "层";
                    Application.DoEvents();

                    feaworkspace = m_gcon.OpenSHPWorkspace(fpath);
                    IFeatureClass feaFC = feaworkspace.OpenFeatureClass(fname);
                    if (feaFC.FeatureType == esriFeatureType.esriFTSimple)
                    {
                        IFeatureWorkspace feaworkspaceSDE = this.m_workSpace as IFeatureWorkspace;
                        Application.DoEvents();
                        m_gdata.ConvertFeatureClassToGDB((IWorkspace)feaworkspace, (IWorkspace)feaworkspaceSDE, fname, fname, null);
                        Application.DoEvents();
                        switch (feaFC.ShapeType)
                        {
                        case esriGeometryType.esriGeometryPoint:
                            shapetype = "point";
                            break;

                        case esriGeometryType.esriGeometryPolyline:
                            shapetype = "line";
                            break;

                        case esriGeometryType.esriGeometryPolygon:
                            shapetype = "polygon";
                            break;

                        default:
                            shapetype = "else";
                            break;
                        }
                        m_gdata.InsertMataData(fname, shapetype, "地理数据", "1", "");
                        Application.DoEvents();
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message);
                    return;
                }
                MessageBox.Show("导入已成功完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frm.Close();
                this.Close();
            }
        }