示例#1
0
        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;
            }
        }
示例#2
0
        /// <summary>
        /// 坐标文件展绘点图层
        /// </summary>
        public void TextToPoint()
        {
            if (m_FeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                MessageBox.Show("请确定展绘的第一个图层为点图层", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                return;
            }
            OpenFileDialog openfileDialog = new OpenFileDialog();

            openfileDialog.Title            = "请选择展绘点图层的坐标文件";
            openfileDialog.Filter           = " txt files(*.txt)|*.txt|All files(*.*)|*.*";
            openfileDialog.RestoreDirectory = true;
            if (openfileDialog.ShowDialog() == DialogResult.OK)
            {
                frmW.WaitingLabel = "正在启动绘制...";
                frmW.Show();
                Application.DoEvents();
                LocalFilePath = openfileDialog.FileName;
                StreamReader strReadToEnd = new StreamReader(LocalFilePath);
                string       sAllLine     = strReadToEnd.ReadToEnd();
                int          LineCount    = sAllLine.Split('\n').Length + 1;
                string[]     pline        = new string[LineCount];
                double[]     x            = new double[LineCount];
                double[]     y            = new double[LineCount];
                string[]     pSeparate    = new string[] { };



                //m_statusBar.Panels[0].ProgressBarMinValue = 0;
                //m_statusBar.Panels[0].ProgressBarMaxValue = LineCount - 1;

                StreamReader strRead = new StreamReader(LocalFilePath);
                int          i       = 0;
                int          j       = 0;
                try
                {
                    if (strRead != null)
                    {
                        pline[i] = strRead.ReadLine();
                        while (pline[i] != null)
                        {
                            pSeparate = pline[i].Split(',', ' ', ';');
                            if (pSeparate.Length >= 3)
                            {
                                x[j] = double.Parse(pSeparate[1]);
                                y[j] = double.Parse(pSeparate[2]);
                                IFeatureClass pFeaCls  = m_FeatureLayer.FeatureClass;
                                IFeature      pFeature = pFeaCls.CreateFeature();
                                IPoint        pPoint   = new PointClass();
                                pPoint.X       = x[j];
                                pPoint.Y       = y[j];
                                pFeature.Shape = pPoint as IGeometry;
                                pFeature.Store();
                                m_mapControl.ActiveView.Refresh();
                                j++;
                                i++;
                                pline[i] = strRead.ReadLine();
                            }
                            else
                            {
                                i++;
                                pline[i] = strRead.ReadLine();
                            }
                            m_statusBar.Panels[0].ProgressBarValue = i;
                            frmW.WaitingLabel = "正在绘制第 " + i.ToString() + " 坐标";
                            Application.DoEvents();
                        }
                    }
                    frmW.Close();
                    MessageBox.Show("绘制完成!");
                }
                catch
                {
                    MessageBox.Show("请检查文本文件的第" + i + "行", "错误信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
            }
            ICommand pCommand = new ControlsMapFullExtentCommandClass();

            pCommand.OnCreate(m_mapControl.Object);
            pCommand.OnClick();
            m_statusBar.Panels[0].ProgressBarValue = 0;
        }
示例#3
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();
            }
        }