예제 #1
0
        public gk061()
        {
            InitializeComponent();

            #region 添加地图
            workspace1 = new SuperMap.Data.Workspace();
            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
            mapLayoutControl1.MapLayout.Workspace = workspace1;
            datasetVector = importDatasource.Datasets["gkfqd"] as DatasetVector;
            mapLayoutControl1.IsHorizontalScrollbarVisible = true;
            mapLayoutControl1.IsVerticalScrollbarVisible   = true;
            AddMap("temp");
            mapLayoutControl1.MapLayout.Zoom(4);

            #endregion
            //添加系统默认打印服务
            foreach (String printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                toolStripComboBox2.Items.Add(printer);
            }
            toolStripComboBox2.SelectedIndex = 0;
            //不显示dataGridView1最后一行
            // dataGridView1.AllowUserToAddRows = false;
            comboBox1.SelectedIndex = 0;
            //区县comboBox列表加载
            LoadComboBox();
        }
예제 #2
0
        /// <summary>
        /// 打开文件形工作空间
        /// </summary>
        public void fileWorkSpaceOpen()
        {
            this.fileWorkspace = new SuperMap.Data.Workspace();



            try
            {
                //打开工作空间及地图文件类型
                WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"..\..\template\temp.smwu");

                fileWorkspace.Open(conInfo);
                m_srcDatasource = fileWorkspace.Datasources["temp"];
                m_sourceRegion  = m_srcDatasource.Datasets["gkfqd"] as DatasetVector;
                dataImport      = new DataImport();

                this.mapControl1.Map.Workspace = fileWorkspace;
                mapControl1.Map.Layers.Clear();
                mapControl1.Map.Layers.Add(m_sourceRegion, true);
                mapControl1.Map.ViewEntire();
                mapControl1.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
예제 #3
0
        //public static OleDbConnection conn = new OleDbConnection("Provider=MSDAORA.1;User ID=gkfqd;Password=123456;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))");

        //public static OracleConnection gkfqd.Common.DbUse.GetOleDbconnection() = new OracleConnection("Datasource =ORCL; User = gkfqd; Password = 123456;");
        #endregion

        #region 初始化
        public gk043()
        {
            try
            {
                InitializeComponent();
                //区县comboBox列表加载
                LoadComboBox();
                //默认选内蒙古自治区
                comboBox1.SelectedIndex = 0;
                //默认年份为 全部
                comboBox4.SelectedIndex = 0;
                //不显示dataGridView1最后一行
                dataGridView1.AllowUserToAddRows = false;
                //默认叠加年份2014
                comboBox4.Text   = "2017";
                comboBox5.Text   = "2017";
                this.x_workspace = new SuperMap.Data.Workspace();
                //this.mapControl1 = new SuperMap.UI.MapControl();
                //m_mapControl.Dock = DockStyle.Fill;
                m_sampleRun = new SampleRun(x_workspace, mapControl1);
                //x_sampleRun = new SampleRun(x_workspace, mapControl1);
                //base.Controls.Add(mapControl1);
                base.Controls.SetChildIndex(mapControl1, 0);
                mapControl1.GeometrySelected += new SuperMap.UI.GeometrySelectedEventHandler(m_mapControl_GeometrySelected);
                // mapControl1.Paint += new PaintEventHandler(m_mapControl_Paint);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
예제 #4
0
        public void ImportToShp()
        {
            //-------------数据库打开工作空间
            workspace1 = new SuperMap.Data.Workspace();
            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
            dataImport       = new DataImport();

            try
            {
                dataImport.ImportSettings.Clear();
                //ImportSettingSHP shpSetting = new ImportSettingSHP();
                ImportSettingBMP bmpSetting = new ImportSettingBMP();
                bmpSetting.ImportMode = ImportMode.Overwrite;
                string str = System.IO.Directory.GetCurrentDirectory();
                //复制选择文件到临时文件夹,目的是重命名文件,导入到数据库指定文件中
                String targetPath = str + "\\tempFolder\\temp_gkfqd01.bmp";
                bmpSetting.SourceFilePath   = targetPath;
                bmpSetting.TargetDatasource = importDatasource;
                dataImport.ImportSettings.Add(bmpSetting);

                dataImport.Run();
                mapControl1.Map.ViewEntire();
                mapControl1.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }
예제 #5
0
 public void MapShow(string mapLayerName)
 {
     workspace1 = new SuperMap.Data.Workspace();
     workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
     importDatasource          = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
     importResultShp           = importDatasource.Datasets[mapLayerName] as DatasetVector;
     mapControl1.Map.Workspace = workspace1;
     mapControl1.Map.Layers.Clear();
     mapControl1.Map.Layers.Add(importResultShp, true);
     mapControl1.Map.ViewEntire();
     mapControl1.Map.Refresh();
 }
예제 #6
0
        public gk03b()
        {
            InitializeComponent();
            workspace1 = new SuperMap.Data.Workspace();

            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            importDatasource          = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
            importResultShp           = importDatasource.Datasets["IntersectTemp"] as DatasetVector;
            mapControl1.Map.Workspace = workspace1;
            mapControl1.Map.Layers.Clear();
            mapControl1.Map.Layers.Add(importResultShp, true);
            mapControl1.Map.ViewEntire();
            mapControl1.Map.Refresh();
        }
예제 #7
0
        public SymbolResourceWnd(Workspace workspace)
        {
            try
            {
                InitializeComponent();

                this.m_workspace = workspace;

                //实例化SampleRun
                m_sampleRun = new SampleSymbolRun(m_workspace);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
        /// <summary>
        /// 导入为shp
        /// </summary>
        public void ImportToShp()
        {
            //-------------数据库打开工作空间
            workspace1 = new SuperMap.Data.Workspace();

            /* WorkspaceconnectionInfo workspaceconnectionInfo = new WorkspaceconnectionInfo();
             * workspaceconnectionInfo.Type = WorkspaceType.Oracle;
             * workspaceconnectionInfo.Server = "ORCL";
             * workspaceconnectionInfo.Database = "";
             * workspaceconnectionInfo.Name = "workspace";
             * workspaceconnectionInfo.User = "******";
             * workspaceconnectionInfo.Password = "******";
             * workspace1.Open(workspaceconnectionInfo);*/
            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
            dataImport       = new DataImport();

            try
            {
                dataImport.ImportSettings.Clear();
                ImportSettingSHP shpSetting = new ImportSettingSHP();
                shpSetting.ImportMode = ImportMode.Overwrite;
                string str = System.IO.Directory.GetCurrentDirectory();
                //复制选择文件到临时文件夹,目的是重命名文件,导入到数据库指定文件中
                String targetPath = str + "\\tempFolder\\temp_gkfqd.shp";
                shpSetting.SourceFilePath   = targetPath;
                shpSetting.TargetDatasource = importDatasource;
                dataImport.ImportSettings.Add(shpSetting);
                dataImport.Run();

                importResultShp           = importDatasource.Datasets["temp_gkfqd"] as DatasetVector;
                mapControl1.Map.Workspace = workspace1;
                mapControl1.Map.Layers.Clear();
                mapControl1.Map.Layers.Add(importResultShp, true);
                mapControl1.Map.ViewEntire();
                mapControl1.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                MessageBox.Show(ex.Message);
            }
            RefreshDataGridView();
        }
예제 #9
0
        public gk065()
        {
            InitializeComponent();


            workspace1 = new SuperMap.Data.Workspace();

            /* WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
             * workspaceConnectionInfo.Type = WorkspaceType.Oracle;
             * workspaceConnectionInfo.Server = "ORCL";
             * workspaceConnectionInfo.Database = "";
             * workspaceConnectionInfo.Name = "workspace";
             * workspaceConnectionInfo.User = "******";
             * workspaceConnectionInfo.Password = "******";
             * workspace1.Open(workspaceConnectionInfo);*/
            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            mapLayoutControl1.MapLayout.Workspace = workspace1;

            mapLayoutControl1.IsHorizontalScrollbarVisible = true;
            mapLayoutControl1.IsVerticalScrollbarVisible   = true;

            try
            {
                LayoutElements elements = mapLayoutControl1.MapLayout.Elements;
                //构造GeoMap
                GeoMap geoMap = new GeoMap();
                geoMap.MapName = "temp";

                //设置GeoMap对象的外切矩形
                Rectangle2D rect = new Rectangle2D(new Point2D(850, 1300), new Size2D(
                                                       1500, 1500));
                GeoRectangle geoRect = new GeoRectangle(rect, 0);
                geoMap.Shape = geoRect;
                elements.AddNew(geoMap);
                m_mapID = elements.GetID();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            mapLayoutControl1.TrackMode = TrackMode.Edit;
            mapLayoutControl1.MapLayout.Zoom(4);
        }
예제 #10
0
        public FormMain()
        {
            try
            {
                InitializeComponent();
                SetTopPanelStyle();

                //隐藏悬浮工具栏
                label_arrow.Location = new Point(468, 0);
                label_arrow.Image    = imageCollection1.Images[2];
                toolStrip1.Visible   = false;

                workspace1 = new SuperMap.Data.Workspace(this.components);
            }

            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
예제 #11
0
        public FormMain()
        {
            try
            {
                InitializeComponent();
                this.Load += new EventHandler(FormMain_Load);

                //this.m_workspace = new SuperMap.Data.Workspace();
                this.m_workspace  = (SuperMap.Data.Workspace)Lemon.SwapFindObject(typeof(SuperMap.Data.Workspace));
                this.m_mapControl = new SuperMap.UI.MapControl();

                m_mapControl.Dock = DockStyle.Fill;

                base.Controls.Add(m_mapControl);
                base.Controls.SetChildIndex(m_mapControl, 0);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
예제 #12
0
        public gk031()
        {
            InitializeComponent();
            workspace1 = new SuperMap.Data.Workspace();

            /* WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
             * workspaceConnectionInfo.Type = WorkspaceType.Oracle;
             * workspaceConnectionInfo.Server = "ORCL";
             * workspaceConnectionInfo.Database = "";
             * workspaceConnectionInfo.Name = "workspace";
             * workspaceConnectionInfo.User = "******";
             * workspaceConnectionInfo.Password = "******";
             * workspace1.Open(workspaceConnectionInfo);*/
            workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
            importDatasource          = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
            importResultShp           = importDatasource.Datasets["gkfqd"] as DatasetVector;
            mapControl1.Map.Workspace = workspace1;
            mapControl1.Map.Layers.Clear();
            mapControl1.Map.Layers.Add(importResultShp, true);
            mapControl1.Map.ViewEntire();
            mapControl1.Map.Refresh();
        }
예제 #13
0
        /// <summary>
        /// 导入为Dwg
        /// </summary>
        public void ImportToDwg()
        {
            //-----------
            this.fileWorkspace = new SuperMap.Data.Workspace();

            //打开工作空间及地图
            WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"..\..\template\temp.smwu");

            fileWorkspace.Open(conInfo);

            dataImport = new DataImport();
            // m_srcDatasource = fileWorkspace.Datasources["temp"];
            importDatasource = fileWorkspace.Datasources["temp"];
            //----------
            try
            {
                dataImport.ImportSettings.Clear();
                ImportSettingDWG dwgSetting = new ImportSettingDWG();
                dwgSetting.ImportMode = ImportMode.Append;
                //dwgSetting.SourceFilePath = @"..\..\SampleData\DataExchange\DwgImport\Polyline.dwg";
                dwgSetting.SourceFilePath   = imgPath;
                dwgSetting.TargetDatasource = importDatasource;
                dwgSetting.ImportingAsCAD   = true;
                dataImport.ImportSettings.Add(dwgSetting);
                dataImport.Run();
                DatasetVector importResult = importDatasource.Datasets["Polyline"] as DatasetVector;
                this.mapControl1.Map.Workspace = fileWorkspace;
                mapControl1.Map.Layers.Clear();
                mapControl1.Map.Layers.Add(importResult, true);
                mapControl1.Map.ViewEntire();
                mapControl1.Map.Refresh();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
예제 #14
0
        public string TransFile(byte[] fileBt, double width, string fileName, bool ifCreate)
        {
            // 0长度文件返回 0
            string rst = "0";

            if (fileBt.Length == 0)
            {
                return(rst);
            }
            string filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["CSVPath"].ToString());   //存储文件路径

            //创建系统日期文件夹,避免同一文件夹下文件太多问题,避免同一地图应文档重名
            filePath = filePath + DateTime.Now.ToString("yyyyMMdd") + "\\";

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            FileStream fstream;

            //是否创建新文件
            if (ifCreate)
            {
                fstream = new FileStream(filePath + fileName, FileMode.Create);
            }
            else
            {
                fstream = new FileStream(filePath + fileName, FileMode.Append);
            }
            try
            {
                fstream.Write(fileBt, 0, fileBt.Length);   //二进制转换成文件
                //上传成功返回 1
                fstream.Close();
            }
            catch (Exception ex)
            {
                //上传失败返回 1
                rst = "error";
            }
            finally
            {
                fstream.Close();
            }
            //读取坐标文件转换面积
            //设置为实际值
            string imgPath = filePath + fileName;
            //坐标点导入处理
            StreamReader objReader = new StreamReader(imgPath);
            string       sLine     = "";
            ArrayList    LineList  = new ArrayList();

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null && !sLine.Equals(""))
                {
                    LineList.Add(sLine);
                }
            }
            objReader.Close();
            bool   isrewrite  = true;
            string sourcePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["sourcePath"].ToString());   //存储文件路径
            string targetPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["targetPath"].ToString());   //存储文件路径            String targetPath = str + "\\tempFolder\\temp_gkfqd.shp";
            string temp       = GenerateRandomCode(10);

            targetPath = targetPath + DateTime.Now.ToString("yyyyMMdd") + "\\";

            if (!Directory.Exists(targetPath))
            {
                Directory.CreateDirectory(targetPath);
            }
            targetPath = targetPath + temp + "\\";
            if (!Directory.Exists(targetPath))
            {
                Directory.CreateDirectory(targetPath);
            }
            System.IO.File.Copy(sourcePath + "testG.smwu", targetPath + "testG.smwu", isrewrite);
            System.IO.File.Copy(sourcePath + "test.udd", targetPath + "test.udd", isrewrite);
            System.IO.File.Copy(sourcePath + "test.udb", targetPath + "test.udb", isrewrite);
            this.fileWorkspace = new SuperMap.Data.Workspace();
            string workSpaceFilePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["BinPath"].ToString());   //存储文件路径

            try
            {
                //打开工作空间及地图文件类型
                WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(targetPath + "testG.smwu");
                fileWorkspace.Open(conInfo);
                fileDatasource      = fileWorkspace.Datasources["test"];
                sourceDatasetVector = fileDatasource.Datasets["dataT"] as DatasetVector;
                Recordset recordset = (sourceDatasetVector as DatasetVector).GetRecordset(false, CursorType.Dynamic);
                // 获得记录集对应的批量更新对象
                Recordset.BatchEditor editor = recordset.Batch;
                // 开始批量添加,将 example 数据集每条记录对应的几何对象添加到数据集中
                editor.Begin();
                //删除所有记录
                recordset.DeleteAll();
                Point2Ds points = new Point2Ds();
                for (int i = 1; i < LineList.Count - 1; i++)
                {
                    string[] fieldInfoListZ = LineList[i].ToString().Split(',');
                    Point2D  point2D        = new Point2D();
                    point2D.X = double.Parse(fieldInfoListZ[0].ToString());
                    point2D.Y = double.Parse(fieldInfoListZ[1].ToString());
                    points.Add(point2D);
                }
                GeoLine geolineE = new GeoLine();
                geolineE.AddPart(points);
                recordset.AddNew(geolineE);
                editor.Update();
                //调用创建矢量数据集缓冲区方法
                //设置缓冲区分析参数
                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();

                //FLAT:平头缓冲。ROUND:圆头缓冲。
                bufferAnalystParam.EndType = BufferEndType.Flat;
                //左侧缓冲距离,单位:米。
                bufferAnalystParam.LeftDistance = width / 2;
                //右侧缓冲距离,单位:米。
                bufferAnalystParam.RightDistance = width / 2;
                String bufferName = "bufferRegionDt";
                bufferName      = fileDatasource.Datasets.GetAvailableDatasetName(bufferName);
                m_bufferDataset = fileDatasource.Datasets.Create(new DatasetVectorInfo(bufferName, DatasetType.Region));
                //设置投影信息 不设置 报投影不一致错误
                m_bufferDataset.Datasource.Datasets["bufferRegionDt"].PrjCoordSys = (fileDatasource.Datasets["dataT"] as DatasetVector).PrjCoordSys;
                Boolean   isTrue     = SuperMap.Analyst.SpatialAnalyst.BufferAnalyst.CreateBuffer(recordset, m_bufferDataset, bufferAnalystParam, false, true);
                Recordset recordsetS = m_bufferDataset.Query("SmID=1", CursorType.Static);
                pfm = double.Parse(recordsetS.GetFieldValue("SMAREA").ToString());
                mu  = pfm * 0.0015;
                double gongqing = 0.0666667 * mu;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            rst = String.Format("{0:F2}", mu);
            fileWorkspace.Close();
            return(rst);
        }
예제 #15
0
        public string TransFile(byte[] fileBt, string fileName, bool ifCreate)
        {
            // 0长度文件返回 0
            string rst = "0";

            if (fileBt.Length == 0)
            {
                return(rst);
            }
            string filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["CSVPath"].ToString());   //存储文件路径

            //创建系统日期文件夹,避免同一文件夹下文件太多问题,避免同一地图应文档重名
            // filePath = filePath + DateTime.Now.ToString("yyyyMMdd") + "\\";
            if (!Directory.Exists(filePath))
            {
                // Create the directory it does not exist.
                Directory.CreateDirectory(filePath);
            }
            FileStream fstream;

            //是否创建新文件
            if (ifCreate)
            {
                fstream = new FileStream(filePath + fileName, FileMode.Create);
            }
            else
            {
                fstream = new FileStream(filePath + fileName, FileMode.Append);
            }
            try
            {
                fstream.Write(fileBt, 0, fileBt.Length);   //二进制转换成文件
                //上传成功返回 1
                fstream.Close();
            }
            catch (Exception ex)
            {
                //上传失败返回 1
                rst = "error";
            }
            finally
            {
                fstream.Close();
            }
            //读取坐标文件转换面积
            string imgPath = "d:/zuobiao.txt";
            //坐标点导入处理
            StreamReader objReader = new StreamReader(imgPath);
            string       sLine     = "";
            ArrayList    LineList  = new ArrayList();

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null && !sLine.Equals(""))
                {
                    LineList.Add(sLine);
                }
            }
            objReader.Close();
            this.fileWorkspace = new SuperMap.Data.Workspace();
            try
            {
                //打开工作空间及地图文件类型
                WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"d:\testG.smwu");
                fileWorkspace.Open(conInfo);
                fileDatasource      = fileWorkspace.Datasources["test"];
                sourceDatasetVector = fileDatasource.Datasets["dataT"] as DatasetVector;
                //Recordset recordset = new Recordset();
                Recordset recordset = (sourceDatasetVector as DatasetVector).GetRecordset(false, CursorType.Dynamic);
                // 获得记录集对应的批量更新对象
                Recordset.BatchEditor editor = recordset.Batch;
                // 开始批量添加,将 example 数据集每条记录对应的几何对象添加到数据集中
                editor.Begin();
                //删除所有记录
                recordset.DeleteAll();
                Point2Ds points = new Point2Ds();
                for (int i = 1; i < LineList.Count - 1; i++)
                {
                    string[] fieldInfoListZ = LineList[i].ToString().Split(',');
                    Point2D  point2D        = new Point2D();
                    point2D.X = double.Parse(fieldInfoListZ[0].ToString());
                    point2D.Y = double.Parse(fieldInfoListZ[1].ToString());
                    points.Add(point2D);
                }
                GeoLine geolineE = new GeoLine();
                geolineE.AddPart(points);
                recordset.AddNew(geolineE);
                editor.Update();
                //调用创建矢量数据集缓冲区方法
                //设置缓冲区分析参数
                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();
                bufferAnalystParam.EndType       = BufferEndType.Flat;
                bufferAnalystParam.LeftDistance  = 50;
                bufferAnalystParam.RightDistance = 50;
                String bufferName = "bufferRegionDt";
                bufferName      = fileDatasource.Datasets.GetAvailableDatasetName(bufferName);
                m_bufferDataset = fileDatasource.Datasets.Create(new DatasetVectorInfo(bufferName, DatasetType.Region));
                Boolean   isTrue          = SuperMap.Analyst.SpatialAnalyst.BufferAnalyst.CreateBuffer(recordset, m_bufferDataset, bufferAnalystParam, false, true);
                Recordset formatRecordset = m_bufferDataset.GetRecordset(false, CursorType.Dynamic);
                GeoRegion geometrySearch  = (GeoRegion)formatRecordset.GetGeometry();
                pfm = geometrySearch.Area;
                mu  = pfm * 0.0015;
                double gongqing = 0.0666667 * mu;
                // 释放记录集
                //  recordset.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            rst = pfm.ToString();
            fileWorkspace.Close();
            return(rst);
        }
예제 #16
0
        private void button4_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "导出地块信息文件(*.xml)|*.xml";
            sfd.FileName = "地块信息导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss");
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = new FileStream(sfd.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                if (dataGridView2.CurrentRow == null)
                {
                    MessageBox.Show("请点击地块表行头,选择地块信息!");
                    return;
                }
                DataGridViewRow dgvr = dataGridView2.CurrentRow;
                //取得当前行项目名称值
                string strProjectName = dgvr.Cells["项目名称"].Value.ToString();
                //取得当前行地块编号该编号为用户输入的
                string strDkbh   = dgvr.Cells["地块逻辑编号"].Value.ToString();
                string tableName = gkfqd.Common.DbUse.GetTownCodeByProjectName(strProjectName);
                sqlQuery.Clear();
                sqlQuery.Append("SELECT  DKBH AS 地块编号, ");
                sqlQuery.Append("        DKWZ AS 地块位置, ");
                sqlQuery.Append("        DKZGYMJ AS 地块中的国有面积, ");
                sqlQuery.Append("        DKZJTMJ AS 地块中的集体面积, ");
                sqlQuery.Append("        XZDXPD AS 地形坡度, ");
                sqlQuery.Append("        TYBZQK AS 土源保障情况, ");
                sqlQuery.Append("        SYBZQK AS 水源保障情况, ");
                sqlQuery.Append("        XZYWDZZHYH AS 有无地质灾害隐患, ");
                sqlQuery.Append("        XZYWWRZK AS 有无污染状况, ");
                sqlQuery.Append("        XZWRZK AS 污染状况, ");
                sqlQuery.Append("        SFFHTDLYZTGH AS 是否符合土地利用总体规划, ");
                sqlQuery.Append("        SFFH AS 是否符合, ");
                sqlQuery.Append("        QTGHMC AS 其他规划名称, ");
                sqlQuery.Append("        CKYD AS 采矿用地, ");
                sqlQuery.Append("        GYYD AS 工业用地, ");
                sqlQuery.Append("        JTYSYD AS 交通运输用地, ");
                sqlQuery.Append("        SYJSLSSYD AS 水域及水利设施用地,  ");
                sqlQuery.Append("        QTJSYD  AS  其它建设用地, ");
                sqlQuery.Append("        GD AS 预期耕地面积, ");
                sqlQuery.Append("        YD AS 预期园地面积, ");
                sqlQuery.Append("        LD    AS    预期林地面积, ");
                sqlQuery.Append("        CD    AS    预期草地面积, ");
                sqlQuery.Append("        NCDL  AS    预期农村道路, ");
                sqlQuery.Append("        KTSM  AS    预期坑塘水面, ");
                sqlQuery.Append("        GQ    AS    预期沟渠, ");
                sqlQuery.Append("        QTNYD  AS   预期其他农用地面积, ");
                sqlQuery.Append("        YQDXPD AS 预期地形坡度, ");
                sqlQuery.Append("        YXTCHD AS  预期有效土层厚度, ");
                sqlQuery.Append("        YQYWDZZHYH AS 预期有无地质灾害隐患, ");
                sqlQuery.Append("        YQYWWRZK AS  预期有无污染状况, ");
                sqlQuery.Append("        YQFKGDDJ AS  预期耕地等级, ");
                sqlQuery.Append("        YQWRZK AS  预期没有达标填写污染状况,");
                sqlQuery.Append("        JSYDHF AS  建设用地合法性,");
                sqlQuery.Append("        FKYWR AS  复垦义务人情况,");
                sqlQuery.Append("        DKMC AS  地块名称,");
                sqlQuery.Append("        DKMJ AS  地块面积,");
                sqlQuery.Append("        ZBX AS  坐标系,");
                sqlQuery.Append("        JZDS AS  界址点数,");
                sqlQuery.Append("        JDFD AS  几度分带,");
                sqlQuery.Append("        JD AS  精度,");
                sqlQuery.Append("        JLDW AS  计量单位,");
                sqlQuery.Append("        JLTCSX AS  记录图形属性,");
                sqlQuery.Append("        TYLX AS  投影类型");
                sqlQuery.Append(" FROM " + tableName);
                sqlQuery.Append(" WHERE   FKXMMC = '" + strProjectName + "'");
                sqlQuery.Append(" AND    DKBH = '" + strDkbh + "'");
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                gkfqd.Common.DbUse.GetOleDbconnection().Open();
                dataSetOutPut.Clear();
                OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                MyAdapter.Fill(dataSetOutPut);
                gkfqd.Common.DbUse.GetOleDbconnection().Close();

                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<!-- 工矿复垦项目导入地块XML格式 -->");
                sw.WriteLine("<CL_PROJECT_BLOCK>");
                sw.WriteLine("  <RECLBLOCKNO name=\"地块编号\">" + dataSetOutPut.Tables[0].Rows[0]["地块编号"].ToString() + "</RECLBLOCKNO>");
                sw.WriteLine("  <LconnAME name=\"位置行政村\">" + dataSetOutPut.Tables[0].Rows[0]["地块位置"].ToString() + "</LconnAME>");
                sw.WriteLine("  <BLOCKAREAG name=\"地块中的国有面积\"> " + dataSetOutPut.Tables[0].Rows[0]["地块中的国有面积"].ToString() + "</BLOCKAREAG>");
                sw.WriteLine("  <BLOCKAREAJ name=\"地块中的集体面积\">" + dataSetOutPut.Tables[0].Rows[0]["地块中的集体面积"].ToString() + "</BLOCKAREAJ>");
                sw.WriteLine("  <!-- “建设用地合法性”填写规则:0表示“空”,1表示“1987年1月《土地管理法》颁布实施前形成”,2表示“1987年1月至1999年1月《土地管理法》修订实施前形成”,3表示“1999年1月至2011年《土地复垦条例》颁布实施前形成”-->");
                string strJsyd = "";
                if (dataSetOutPut.Tables[0].Rows[0]["建设用地合法性"].ToString() == "1987年1月《土地管理法》颁布实施前形成")
                {
                    strJsyd = "1";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["建设用地合法性"].ToString() == "1987年1月至1999年1月《土地管理法》修订实施前形成")
                {
                    strJsyd = "2";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["建设用地合法性"].ToString() == "1999年1月至2011年《土地复垦条例》颁布实施前形成")
                {
                    strJsyd = "3";
                }
                sw.WriteLine("  <BUILDLEGALNO name=\"建设用地合法性\">" + strJsyd + "</BUILDLEGALNO>");
                sw.WriteLine("  <!--“复垦义务人情况”填写规则:0表示“空”,1表示“复垦义务人灭失”,2表示“1988年《土地复垦规定》颁布实施以前损毁土地”,3表示“政策原因无法追溯义务人”-->");
                string strFkyw = "";
                if (dataSetOutPut.Tables[0].Rows[0]["复垦义务人情况"].ToString() == "复垦义务人灭失")
                {
                    strFkyw = "1";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["复垦义务人情况"].ToString() == "1988年《土地复垦规定》颁布实施以前损毁土地")
                {
                    strFkyw = "2";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["复垦义务人情况"].ToString() == "政策原因无法追溯义务人")
                {
                    strFkyw = "3";
                }
                sw.WriteLine(" <RELCPERSON name=\"复垦义务人情况\">" + strFkyw + "</RELCPERSON>");
                string strTdbzqk = "";
                if (dataSetOutPut.Tables[0].Rows[0]["土源保障情况"].ToString() == "")
                {
                    strTdbzqk = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["土源保障情况"].ToString() == "良好")
                {
                    strTdbzqk = "1";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["土源保障情况"].ToString() == "一般")
                {
                    strTdbzqk = "2";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["土源保障情况"].ToString() == "较差")
                {
                    strTdbzqk = "3";
                }
                sw.WriteLine("  <LANDSTUATION name=\"土源保障情况\">" + strTdbzqk + "</LANDSTUATION>");
                sw.WriteLine("  <!--“水源保障情况” 0表示“空”,1表示“良好”,2表示“一般”,3表示“较差”-->");
                string strSybzqk = "";
                if (dataSetOutPut.Tables[0].Rows[0]["水源保障情况"].ToString() == "")
                {
                    strSybzqk = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["水源保障情况"].ToString() == "良好")
                {
                    strSybzqk = "1";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["水源保障情况"].ToString() == "一般")
                {
                    strSybzqk = "2";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["水源保障情况"].ToString() == "较差")
                {
                    strSybzqk = "3";
                }
                sw.WriteLine("  <WATERSTUATION name=\"水源保障情况\">" + strSybzqk + "</WATERSTUATION>");
                string strYwyh = "";
                if (dataSetOutPut.Tables[0].Rows[0]["有无地质灾害隐患"].ToString() == "无")
                {
                    strYwyh = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["有无地质灾害隐患"].ToString() == "有")
                {
                    strYwyh = "1";
                }
                sw.WriteLine("  <ISLANDHURT nmae=\"有无地质灾害隐患\">" + strYwyh + "</ISLANDHURT>");
                string strYwwr = "";
                if (dataSetOutPut.Tables[0].Rows[0]["有无污染状况"].ToString() == "无")
                {
                    strYwwr = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["有无污染状况"].ToString() == "有")
                {
                    strYwwr = "1";
                }
                sw.WriteLine("  <ISPOLUSTUATION name=\"有无污染状况\">" + strYwwr + "</ISPOLUSTUATION>");
                sw.WriteLine("  <POLUSTUATION name=\"污染状况\">" + dataSetOutPut.Tables[0].Rows[0]["污染状况"].ToString() + "</POLUSTUATION>");
                string strFh = "";
                if (dataSetOutPut.Tables[0].Rows[0]["是否符合土地利用总体规划"].ToString() == "否")
                {
                    strFh = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["是否符合土地利用总体规划"].ToString() == "是")
                {
                    strFh = "1";
                }
                sw.WriteLine("  <ISLANDUSEPLAN name=\"是否符合土地利用总体规划\">" + strFh + "</ISLANDUSEPLAN>");
                string strSfh = "";
                if (dataSetOutPut.Tables[0].Rows[0]["是否符合"].ToString() == "否")
                {
                    strSfh = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["是否符合"].ToString() == "是")
                {
                    strSfh = "1";
                }
                sw.WriteLine("  <ISOTHERPLAN name=\"是否符合\">" + strSfh + "</ISOTHERPLAN>");
                sw.WriteLine("  <OTHERPLANNAME name=\"其他规划名称\">" + dataSetOutPut.Tables[0].Rows[0]["其他规划名称"].ToString() + "</OTHERPLANNAME>");
                sw.WriteLine("  <CLANDAREA name=\"采矿用地\">" + dataSetOutPut.Tables[0].Rows[0]["采矿用地"].ToString() + "</CLANDAREA>");
                sw.WriteLine("  <GLANDAREA nmae=\"工业用地\">" + dataSetOutPut.Tables[0].Rows[0]["工业用地"].ToString() + "</GLANDAREA>");
                sw.WriteLine("  <JLANDAREA name=\"交通运输用地\">" + dataSetOutPut.Tables[0].Rows[0]["交通运输用地"].ToString() + "</JLANDAREA>");
                sw.WriteLine("  <SLANDAREA name=\"水域及水利设施用地\">" + dataSetOutPut.Tables[0].Rows[0]["水域及水利设施用地"].ToString() + "</SLANDAREA>");
                sw.WriteLine("  <OLANDAREA name=\"其它建设用地\">" + dataSetOutPut.Tables[0].Rows[0]["其它建设用地"].ToString() + "</OLANDAREA>");
                sw.WriteLine("  <EXGLANDAREA name=\"预期耕地面积\">" + dataSetOutPut.Tables[0].Rows[0]["预期耕地面积"].ToString() + "</EXGLANDAREA>");
                sw.WriteLine("  <EXYLANDAREA name=\"预期园地面积\">" + dataSetOutPut.Tables[0].Rows[0]["预期园地面积"].ToString() + "</EXYLANDAREA>");
                sw.WriteLine("  <EXLLANDAREA name=\"预期林地面积\">" + dataSetOutPut.Tables[0].Rows[0]["预期林地面积"].ToString() + "</EXLLANDAREA>");
                sw.WriteLine("  <EXCLANDAREA name=\"预期草地面积\">" + dataSetOutPut.Tables[0].Rows[0]["预期草地面积"].ToString() + "</EXCLANDAREA>");
                sw.WriteLine("  <EXDLANDAREA name=\"预期农村道路\">" + dataSetOutPut.Tables[0].Rows[0]["预期农村道路"].ToString() + "</EXDLANDAREA>");
                sw.WriteLine("  <EXKLANDAREA nmae=\"预期坑塘水面\">" + dataSetOutPut.Tables[0].Rows[0]["预期坑塘水面"].ToString() + "</EXKLANDAREA>");
                sw.WriteLine("  <EXQLANDAREA name=\"预期沟渠\">" + dataSetOutPut.Tables[0].Rows[0]["预期沟渠"].ToString() + "</EXQLANDAREA>");
                sw.WriteLine("  <EXOLANDAREA name=\"预期其他农用地面积\">" + dataSetOutPut.Tables[0].Rows[0]["预期其他农用地面积"].ToString() + "</EXOLANDAREA>");
                sw.WriteLine("  <!--“预期地形坡度”填写规则:请选择填入0,0—5度,5—15度,15—25度,25度以上,中的一个。-->");
                sw.WriteLine("  <EXLANDSLIP name=\"预期地形坡度\">" + dataSetOutPut.Tables[0].Rows[0]["预期地形坡度"].ToString() + "</EXLANDSLIP>");
                sw.WriteLine("  <EXLANDINCL name=\"预期有效土层厚度\">" + dataSetOutPut.Tables[0].Rows[0]["预期有效土层厚度"].ToString() + "</EXLANDINCL>");
                string strZhyh = "";
                if (dataSetOutPut.Tables[0].Rows[0]["预期有无地质灾害隐患"].ToString() == "无")
                {
                    strZhyh = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["预期有无地质灾害隐患"].ToString() == "有")
                {
                    strZhyh = "1";
                }
                sw.WriteLine("  <EXISLANDHURT name=\"预期有无地质灾害隐患\">" + strZhyh + "</EXISLANDHURT>");
                string strYwwrzk = "";
                if (dataSetOutPut.Tables[0].Rows[0]["预期有无污染状况"].ToString() == "无")
                {
                    strYwwrzk = "0";
                }
                if (dataSetOutPut.Tables[0].Rows[0]["预期有无污染状况"].ToString() == "有")
                {
                    strYwwrzk = "1";
                }
                sw.WriteLine("  <EXISPOLUSTUATION name=\"预期有无污染状况\">" + strYwwrzk + "</EXISPOLUSTUATION>");
                sw.WriteLine("  <EXPOLUSTUATION name=\"预期没有达标填写污染状况\">" + dataSetOutPut.Tables[0].Rows[0]["预期没有达标填写污染状况"].ToString() + "</EXPOLUSTUATION>");
                sw.WriteLine("  <EXGLANDRECLLEVEL name=\"预期耕地等级\">" + dataSetOutPut.Tables[0].Rows[0]["预期耕地等级"].ToString() + "</EXGLANDRECLLEVEL>");
                sw.WriteLine("  <CUTNU name=\"几度分带\">" + dataSetOutPut.Tables[0].Rows[0]["几度分带"].ToString() + "</CUTNU>");
                sw.WriteLine("  <MEASUREMENT name=\"计量单位\">" + dataSetOutPut.Tables[0].Rows[0]["计量单位"].ToString() + "</MEASUREMENT>");
                sw.WriteLine("  <PRECISION name=\"精度\">" + dataSetOutPut.Tables[0].Rows[0]["精度"].ToString() + "</PRECISION>");
                sw.WriteLine("  <DROPNU name=\"界址点数\">" + dataSetOutPut.Tables[0].Rows[0]["界址点数"].ToString() + "</DROPNU>");
                sw.WriteLine("  <LANDNAME name=\"地块名称\">" + dataSetOutPut.Tables[0].Rows[0]["地块名称"].ToString() + "</LANDNAME>");
                sw.WriteLine("  <DRAWINGPROPERTY name=\"记录图形属性\">" + dataSetOutPut.Tables[0].Rows[0]["记录图形属性"].ToString() + "</DRAWINGPROPERTY>");
                sw.WriteLine("  <SHADOWTYPE name=\"投影类型\">" + dataSetOutPut.Tables[0].Rows[0]["投影类型"].ToString() + "</SHADOWTYPE>");
                sw.WriteLine("  <COORSYSTEM name=\"坐标系\">" + dataSetOutPut.Tables[0].Rows[0]["坐标系"].ToString() + "</COORSYSTEM>");
                sw.WriteLine("  <LANDAREA name=\"地块面积\">" + dataSetOutPut.Tables[0].Rows[0]["地块面积"].ToString() + "</LANDAREA>");
                sw.Write("  <param ZB=\"@1$");
                DataGridViewRow dgvr1   = dataGridView2.CurrentRow;
                string          strSmid = dgvr1.Cells["地块编号"].Value.ToString();//获取smid值
                // 构造一个查询参数对象,查询选中的记录
                QueryParameter para = new QueryParameter();
                para.AttributeFilter = "SMID =" + strSmid;
                para.CursorType      = CursorType.Dynamic;

                DatasetVector           importResultShp = null;
                SuperMap.Data.Workspace workspace1;
                workspace1 = new SuperMap.Data.Workspace();
                workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
                importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
                importResultShp  = importDatasource.Datasets[tableName] as DatasetVector;
                Recordset recordset = null;
                try
                {
                    recordset = importResultShp.Query(para);
                    while (!recordset.IsEOF)
                    {
                        Geometry  geometry = recordset.GetGeometry();
                        GeoRegion region   = geometry as GeoRegion;
                        for (int i = 0; i < region.PartCount; i++)
                        {
                            Point2Ds point2ds = region[i];
                            for (int k = 0; k < point2ds.Count; k++)
                            {
                                Point2D point2d = point2ds[k];
                                sw.Write((k + 1).ToString() + "," + point2d.X.ToString() + "," + point2d.Y.ToString() + ";");
                            }
                        }
                        recordset.MoveNext();
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
                finally
                {
                    recordset.Dispose();
                }
                sw.WriteLine(" \" />");
                sw.WriteLine("</CL_PROJECT_BLOCK>");
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
                MessageBox.Show("项目信息导出成功!");
            }
        }
예제 #17
0
        public void CreateWorkspace(string wpsPath, string sources, string symbol)
        {
            // 创建工作空间,弹出 “关于”对话框
            Msg("正在创建工作空间···");
            SuperMap.Data.Workspace workspace = new SuperMap.Data.Workspace();
            WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
            workspaceConnectionInfo.Type = WorkspaceType.SMWU;

            workspaceConnectionInfo.Name = "MapResult";
            workspaceConnectionInfo.Password = set.passWod;
            String file = wpsPath;
            workspaceConnectionInfo.Server = file;

            if (workspace.Create(workspaceConnectionInfo))
            {
                //MessageBox.Show("创建工作空间成功");
                workspace.Caption = "MapResult";
                workspace.Save();
                Msg("工作空间创建成功:" + workspace.Caption);
                //System.Threading.Thread.Sleep(500);
                Msg("正在导入符号库···");
                DirectoryInfo di = new DirectoryInfo(symbol);
                foreach (FileInfo fill in di.GetFiles("*.bru"))
                {
                    File.Copy(fill.FullName, sources + "//" + fill.Name, true);
                    SymbolFillLibrary sf = workspace.Resources.FillLibrary;
                    sf.FromFile(sources + "//" + fill.Name);
                    workspace.Save();
                }
                foreach (FileInfo point in di.GetFiles("*.sym"))
                {
                    File.Copy(point.FullName, sources + "//" + point.Name, true);

                    SymbolMarkerLibrary sf = workspace.Resources.MarkerLibrary;
                    sf.FromFile(sources + "//" + point.Name);
                    workspace.Save();
                } foreach (FileInfo Line in di.GetFiles("*.lsl"))
                {
                    File.Copy(Line.FullName, sources + "//" + Line.Name, true);

                    SymbolLineLibrary sf = workspace.Resources.LineLibrary;
                    sf.FromFile(sources + "//" + Line.Name);
                    workspace.Save();
                }
                Msg("符号库导入成功");

                System.Threading.Thread.Sleep(500);

                di = new DirectoryInfo(sources);
                FileInfo[] fl = di.GetFiles("*.udb");
                for (int s = 0; s < fl.Length; s++)
                {

                    DatasourceConnectionInfo ds = new DatasourceConnectionInfo();
                    ds.Alias = fl[s].Name.Substring(0, fl[s].Name.Length - 4);
                    Msg( "添加数据源:" + ds.Alias);
                    
                    ds.Server = sources + "\\" + fl[s].ToString();
                    ds.Password = set.passWod;
                    
                    Datasource datasource = workspace.Datasources.Open(ds);
                    if (datasource == null)
                    {
                        MessageBox.Show("打开数据源失败");
                    }
                    else
                    {
                        //MessageBox.Show(fl[s].Name+"数据源打开成功!");
                    }
                    workspace.Save();

                }
                workspace.Close();
                workspace.Dispose();
                workspaceConnectionInfo.Dispose();
            }

        }
예제 #18
0
        public void ModelApplication(String xml, string wksPath, string name)
        {
            //初始化工作空间
            try
            {
                SuperMap.Data.Workspace sWorkspace1 = new SuperMap.Data.Workspace();
                WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(wksPath);//@"G:\数据转换\测试数据\Test1\test.smwu");
                info.Password = set.passWod;
                sWorkspace1.Open(info);
                SuperMap.Data.Maps maps = sWorkspace1.Maps;
                maps.Add(name, xml);//,WorkspaceVersion.UGC60
                
                //sWorkspace1.Maps.SetMapXML(name, xml);
                
                sWorkspace1.Save();

                sWorkspace1.Dispose();
            }
            catch (Exception ex)
            {
                Msg(ex.Message);
            }

        }
예제 #19
0
        //创建工作空间(超图)
        public void CreateWorkspace(string wpsPath, string sources, string symbol)
        {
            // 创建工作空间,弹出 “关于”对话框
            SuperMap.Data.Workspace workspace = new SuperMap.Data.Workspace();
            WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
            workspaceConnectionInfo.Type = WorkspaceType.SMWU;

            workspaceConnectionInfo.Name = "MapResult";
            workspaceConnectionInfo.Password = "******";
            String file = wpsPath;
            workspaceConnectionInfo.Server = file;

            if (workspace.Create(workspaceConnectionInfo))
            {
                //MessageBox.Show("创建工作空间成功");
                workspace.Caption = "MapResult";
                workspace.Save();
                DirectoryInfo di = new DirectoryInfo(symbol);
                foreach (FileInfo fill in di.GetFiles("*.bru"))
                {
                    File.Copy(fill.FullName, sources + "//" + fill.Name, true);
                    SymbolFillLibrary sf = workspace.Resources.FillLibrary;
                    sf.FromFile(sources + "//" + fill.Name);
                    workspace.Save();
                }
                foreach (FileInfo point in di.GetFiles("*.sym"))
                {
                    File.Copy(point.FullName, sources + "//" + point.Name, true);

                    SymbolMarkerLibrary sf = workspace.Resources.MarkerLibrary;
                    sf.FromFile(sources + "//" + point.Name);
                    workspace.Save();
                } foreach (FileInfo Line in di.GetFiles("*.lsl"))
                {
                    File.Copy(Line.FullName, sources + "//" + Line.Name, true);

                    SymbolLineLibrary sf = workspace.Resources.LineLibrary;
                    sf.FromFile(sources + "//" + Line.Name);
                    workspace.Save();
                }
                di = new DirectoryInfo(sources);
                FileInfo[] fl = di.GetFiles("*.udb");
                for (int s = 0; s < fl.Length; s++)
                {
                    DatasourceConnectionInfo ds = new DatasourceConnectionInfo();
                    ds.Alias = fl[s].Name.Substring(0, fl[s].Name.Length - 4);
                    ds.Password = "******";
                    ds.Server = sources + "\\" + fl[s].ToString();
                    //ds.Password = "******";
                    Datasource datasource = workspace.Datasources.Open(ds);
                    if (ds.Alias.Substring(0, 4) == "ymgc")
                    {
                        ProjectConverTest(@"G:\移动风险监测\参考坐标\CGCS_2000.xml", datasource);
                        System.Threading.Thread.Sleep(100);
                    }
                    //= "ymgc1";
                    if (datasource == null)
                    {
                        MessageBox.Show("打开数据源失败");
                    }
                    else
                    {
                        //MessageBox.Show(fl[s].Name+"数据源打开成功!");
                    }
                    workspace.Save();

                }
                workspace.Close();
                workspace.Dispose();
                workspaceConnectionInfo.Dispose();
            }

        }
예제 #20
0
        /*1、打开数据集
                  * 2、获取记录集  没有就增加字段
                  * 3、读取xls对应导入
                  * 4、更新属性表
                  * 5、关闭数据源
                  */

        /*public void ConnectAttribute(string xlsPath, string udbPath)
        {
            datetime = DateTime.Now;
            string[] m_newFieldName = { "GDP", "耕地面积", "总人口" };
            //定义工作空间
            SuperMap.Data.Workspace wps = new SuperMap.Data.Workspace();
            //工作空间打开数据源
            wps.Datasources.Open(new DatasourceConnectionInfo(udbPath, "yxfx", "aaaazzzz"));
            //临时数据集
            Dataset srcDataset = wps.Datasources[0].Datasets["xzjLayer"];
            DatasetVector dv = (DatasetVector)srcDataset;
            FieldInfos m_fieldInfos = dv.FieldInfos;
            for (int i = 0; i < m_newFieldName.Length; i++)
            {
                try
                {
                    if (m_fieldInfos.IndexOf(m_newFieldName[i]) != -1)
                    {
                        Msg("数据集中已经有指定字段!" + m_newFieldName[i]);

                        continue;
                    }

                    SuperMap.Data.FieldInfo delField = new SuperMap.Data.FieldInfo(m_newFieldName[i], SuperMap.Data.FieldType.Double);
                    delField.IsRequired = false;
                    delField.DefaultValue = "0.0";
                    delField.Caption = m_newFieldName[i];
                    m_fieldInfos.Add(delField);
                    Msg("成功添加字段:" + m_newFieldName[i]);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
            recordset = dv.GetRecordset(false, CursorType.Dynamic);
            UpdateFieldValueTest(recordset, xlsPath);
            wps.Dispose();
            Msg("用时:" + ExecDateDiff(datetime, DateTime.Now));
        }

        private void UpdateFieldValue(Recordset recordset, string xlsPath)
        {
            try
            {
                DataTable dt = importTool.ExcelToDataTable(xlsPath, "sheet1");

                int length = recordset.RecordCount;
                if (length != 0)
                {

                    //for (Int32 i = 1; i <length; i++)
                    //{   

                    //recordset.Edit();
                    //UpdateFieldValue(recordset);
                    try
                    {
                        for (int m = 0; m < dt.Columns.Count; m++)
                        {
                            if (dt.Columns[m].ColumnName == null)
                                continue;
                            if (dt.Columns[m].ColumnName == "GDP")
                            {
                                for (Int32 i = 1; i < length; i++)
                                {

                                    recordset.SeekID(i);
                                    recordset.Edit();
                                    if (i > dt.Rows.Count)
                                        continue;
                                    object valueGDP = dt.Rows[i - 1][m];
                                    recordset.SetFieldValue("GDP", valueGDP);
                                }
                            }
                            else
                                if (dt.Columns[m].ColumnName == "FARMLAND")
                                {
                                    for (Int32 i = 1; i < length; i++)
                                    {
                                        recordset.SeekID(i);
                                        recordset.Edit();
                                        if (i > dt.Rows.Count)
                                            continue;
                                        object valueAC = dt.Rows[i - 1][m];
                                        recordset.SetFieldValue("耕地面积", valueAC);
                                    }
                                }
                                else
                                    if (dt.Columns[m].ColumnName == "POPUL")
                                    {
                                        for (Int32 i = 1; i < length; i++)
                                        {
                                            recordset.SeekID(i);
                                            recordset.Edit();
                                            if (i > dt.Rows.Count)
                                                continue;
                                            object valuePE = dt.Rows[i - 1][m];
                                            recordset.SetFieldValue("总人口", valuePE);
                                        }
                                    }
                                    else
                                        continue;


                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    recordset.Update();

                    Msg("修改属性字段完成");
                }
                else
                {
                    Msg("记录集中没有记录");
                }
            }
            catch (Exception ex)
            {
                Msg(ex.Message);
            }


        }*/
        public void ConnectAttribute(string xlsPath, string udbPath)
        {
            datetime = DateTime.Now;
            string[] m_newFieldName = { "生产总值", "耕地面积", "人口总数" };
            //定义工作空间
            SuperMap.Data.Workspace wps = new SuperMap.Data.Workspace();
            //工作空间打开数据源
            wps.Datasources.Open(new DatasourceConnectionInfo(udbPath, "yxfx", set.passWod));
            //临时数据集
            Dataset srcDataset = wps.Datasources[0].Datasets["xzjLayer"];
            DatasetVector dv = (DatasetVector)srcDataset;
            FieldInfos m_fieldInfos = dv.FieldInfos;
            for (int i = 0; i < m_newFieldName.Length; i++)
            {
                try
                {
                    if (m_fieldInfos.IndexOf(m_newFieldName[i]) != -1)
                    {
                        Msg("数据集中已经有指定字段!" + m_newFieldName[i]);

                        continue;
                    }

                    SuperMap.Data.FieldInfo delField = new SuperMap.Data.FieldInfo(m_newFieldName[i], SuperMap.Data.FieldType.Double);
                    delField.IsRequired = false;
                    delField.DefaultValue = "0.0";
                    delField.Caption = m_newFieldName[i];
                    m_fieldInfos.Add(delField);
                    Msg("成功添加字段:" + m_newFieldName[i]);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
            recordset = dv.GetRecordset(false, CursorType.Dynamic);
            UpdateFieldValueTest(recordset, xlsPath);
            wps.Dispose();
            Msg("用时:" + ExecDateDiff(datetime, DateTime.Now));
        }
예제 #21
0
        /*专题图制作部分 
         * 一、SuperMap中
         *   1、将一个数据集拖拽到地图
         *   2、进来的是默认的栅格图层  然后右键制作专题图  选择栅格分段专题图
         *   3、加载专题图模板。
         *   二、代码部分
         *   1、将数据集添加进地图
         *   2、
         */
        public void refreshMod(string wksPath, string name,string password,string ref_zt)
        {
            try
            {
                SuperMap.Data.Workspace sWorkspace1 = new SuperMap.Data.Workspace();
                WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(wksPath + ".smwu");//@"G:\数据转换\测试数据\Test1\test.smwu");
                info.Password = password;
                sWorkspace1.Open(info);
                if (sWorkspace1.Datasources[name] == null)
                    return;
                Datasource ds = sWorkspace1.Datasources[name];
                int con = ds.Datasets.Count;
               
                SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(sWorkspace1);
                map.Open(name);
                
                Layers layers = map.Layers;
                
                ThemeGridRange tgr = new ThemeGridRange();
                tgr.FromXML(readXML(ref_zt));
                
                for (int i = 1; i <= con; i++)
                {
                    
                    if (map.Layers[i].Name.Substring(0, 4) == "time")
                        continue;
                    DatasetGrid dataSet = ds.Datasets["time" + i.ToString()] as DatasetGrid;
                    Layer layer =map.Layers.Insert(i, dataSet,tgr);
                    // map.Layers.Add(dataSet, tgr, true);
                    layer.IsVisible = false;
                    layer.Caption = "time" + i.ToString();
                    map.Refresh();
                    

                }
                sWorkspace1.Maps.SetMapXML(name, map.ToXML());
                //sWorkspace1.Maps.Add(name+"_x", map.ToXML());
                map.Workspace.Save();
                sWorkspace1.Dispose();
               
                //MessageBox.Show("Over");
                //  sWorkspace1.Save(); MessageBox.Show(layers.Count + "");
                 //layer.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                //layerSettingGrid.ColorTable = Colors.MakeGradient(20, ColorGradientType.BlueWhite, false);

                //layerSettingGrid.SpecialValue = -9999;
                //layerSettingGrid.IsSpecialValueTransparent = true;
                //LayerSettingVector layerSettingVector = new LayerSettingVector();
                //GeoStyle style = new GeoStyle();
                //style.FillForeColor = Color.HotPink;
                //layerSettingGrid.Style = style;
                
                
                
                //ThemeCustom tc = new ThemeCustom();
                //tc.FromXML(readXML(@"D:\移动风险监测\time53.xml"));
               
                //Theme theme=
                //string themes = theme.ToXML();
                //DevComponents.DotNetBar.Controls.RichTextBoxEx re = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
                //re.Text = themes;
                //re.SaveFile(@"D:\移动风险监测\test.txt",RichTextBoxStreamType.TextTextOleObjs);
                //theme.FromXML(readXML(@"D:\移动风险监测\time53.xml"));
               

                   

                  //  layer.Theme.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                   //layer.FromXML(readXML(@"D:\移动风险监测\time1.xml"));
                   // lyy1.Caption = ;
                    
                    //Layer lyy = layers.Add(dataSet, layerSettingGrid, true);
                    
                 
                    //MessageBox.Show(layers.Count + "");
                    //if(layers.Count==400)
                    //    j=layers.Count;
                    //layers.Add(dataSet,new LayerSettingGrid(), true);
                   //Layer ly=  layers.Insert(i, dataSet, tgr);
                   //MessageBox.Show(layers.Count + "");
                   //layers.Add(dataSet, true);
                   //MessageBox.Show(layers.Count + "");
                   //map.EnsureVisible(ly);
                 
                //sWorkspace1.Maps.Add(sWorkspace1.Maps.GetAvailableMapName(name), map.ToXML()); 
              
               
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #22
0
        public string mo;//定义全局变量:模板路径
       
        /// <summary>
        /// 初始化
        /// </summary>
        public ImportTool(SuperMap.Data.Workspace workspace)
        {
            m_workspace = workspace;
            m_dataImport = new DataImport();

        }
예제 #23
0
 //
 /// <summary>
 /// 模板应用
 /// </summary>
 /// <param name="xml">模板文件字符</param>
 /// <param name="wksPath">工作空间路径</param>
 /// <param name="name">地图名称</param>
 public void ModelApplication(String xml, string wksPath, string name)
 {
     //初始化工作空间
     SuperMap.Data.Workspace sWorkspace1 = new SuperMap.Data.Workspace();
     WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(wksPath);//@"G:\数据转换\测试数据\Test1\test.smwu");
     info.Password ="******";
     sWorkspace1.Open(info);
     SuperMap.Data.Maps maps = sWorkspace1.Maps;
     maps.Add(name, xml);
     sWorkspace1.Save();
     sWorkspace1.Dispose();
 }
예제 #24
0
 /// <summary>
 /// 获得地图模板:从已有地图中
 /// </summary>
 /// <param name="wksPath">工作空间</param>
 /// <param name="index">地图索引</param>
 /// <returns>xml的字符</returns>
 public String gainXML(string wksPath, int index)
 {
     SuperMap.Data.Workspace sWorkspace = new SuperMap.Data.Workspace();
     WorkspaceConnectionInfo infomation = new WorkspaceConnectionInfo(wksPath);//@"G:\数据转换\测试数据\Test\test.smwu");
     sWorkspace.Open(infomation);
     if (sWorkspace.Maps.Count == 0)
     {
         MessageBox.Show("当前工作空间中不存在地图!");
         return "";
     }
     SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(sWorkspace);
     map.Open(sWorkspace.Maps[index]);
     String xml = map.ToXML();
     string name = map.Name;
     map.Close();
     sWorkspace.Dispose();
     return xml;
 }
예제 #25
0
        public void ProjectConver(string wpsPath, string prjRef, string name)
        {
            try
            {
                SuperMap.Data.Workspace wps = new SuperMap.Data.Workspace();
                WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(wpsPath);
                wps.Open(info);
                Datasource dc = wps.Datasources["ymgc3"];

                //Dataset dset = wps.Datasources["ymgc1"].Datasets[name];// dsets["time1"];

                //dset.Datasource.Datasets.Delete("time2");
                //Dataset dst = dset.Datasource.CopyDataset(dset, "time2", dset.EncodeType);
                PrjCoordSys prj = new PrjCoordSys();
                prj.FromFile(prjRef, PrjFileType.SuperMap);

                for (int i = 1; i <= dc.Datasets.Count; i++)
                {
                    name = "time" + i.ToString();
                    try
                    {
                        Dataset dset = dc.Datasets[name];
                        //bool ok = CoordSysTranslator.Convert(dset, prj, new CoordSysTransParameter(), CoordSysTransMethod.GeocentricTranslation);
                        dset = CoordSysTranslator.Convert(dset, prj, dset.Datasource, name + "_", new CoordSysTransParameter(), CoordSysTransMethod.GeocentricTranslation);
                        dset.Datasource.Datasets.Delete(name);
                        dset.Datasource.CopyDataset(dset, name, dset.EncodeType);
                        dset.Datasource.Datasets.Delete(name + "_");
                        wps.Save();
                    }
                    catch
                    {
                        continue;
                    }

                }
                wps.Dispose();
                MessageBox.Show("OVER");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
예제 #26
0
        private void button2_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "导出txt坐标文件(*.txt)|*.txt";
            sfd.FileName = "坐标导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss");

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = new FileStream(sfd.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                if (dataGridView1.CurrentRow == null)
                {
                    return;
                }
                DataGridViewRow dgvr = dataGridView1.CurrentRow;


                string strSmid = dgvr.Cells["地块编号"].Value.ToString();//获取smid值
                // 构造一个查询参数对象,查询选中的记录
                QueryParameter para = new QueryParameter();
                para.AttributeFilter = "SMID =" + strSmid;
                para.CursorType      = CursorType.Dynamic;

                DatasetVector           importResultShp = null;
                SuperMap.Data.Workspace workspace1;
                workspace1 = new SuperMap.Data.Workspace();

                workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
                string tableName = gkfqd.Common.DbUse.GetTownCode(comboBox4.Text);
                importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
                importResultShp  = importDatasource.Datasets[tableName] as DatasetVector;
                Recordset recordset = null;
                try
                {
                    recordset = importResultShp.Query(para);
                    while (!recordset.IsEOF)
                    {
                        Geometry  geometry = recordset.GetGeometry();
                        GeoRegion region   = geometry as GeoRegion;
                        for (int i = 0; i < region.PartCount; i++)
                        {
                            Point2Ds point2ds = region[i];
                            for (int k = 0; k < point2ds.Count; k++)
                            {
                                Point2D point2d = point2ds[k];
                                sw.WriteLine(point2d.X.ToString() + "," + point2d.Y.ToString());
                            }
                        }
                        recordset.MoveNext();
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
                finally
                {
                    recordset.Dispose();
                }
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
                MessageBox.Show("坐标导出成功!");
            }
        }
예제 #27
0
        private void button4_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "导出建新地块信息文件(*.xml)|*.xml";
            sfd.FileName = "建新地块信息导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss");
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = new FileStream(sfd.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                if (dataGridView2.CurrentRow == null)
                {
                    MessageBox.Show("请点击地块表行头,选择地块信息!");
                    return;
                }
                DataGridViewRow dgvr = dataGridView2.CurrentRow;
                //取得当前行项目名称值
                string strProjectName = dgvr.Cells["项目名称"].Value.ToString();
                //取得当前行地块编号该编号为用户输入的
                string strDkbh   = dgvr.Cells["地块逻辑编号"].Value.ToString();
                string tableName = gkfqd.Common.DbUse.GetTownCodeByProjectNameJx(strProjectName);
                sqlQuery.Clear();
                sqlQuery.Append("SELECT  DKBH AS 建新地块编号, ");
                sqlQuery.Append("        DKWZ AS 位置, ");
                sqlQuery.Append("        DKMC AS 地块名称, ");
                sqlQuery.Append("        DKMJ AS 地块面积, ");
                sqlQuery.Append("        ZBX AS 坐标系, ");
                sqlQuery.Append("        JDFD AS 几度分带, ");
                sqlQuery.Append("        TYLX AS 投影类型, ");
                sqlQuery.Append("        JLDW AS 计量单位, ");
                sqlQuery.Append("        JD AS 精度, ");
                sqlQuery.Append("        JZDS AS 界址点数, ");
                sqlQuery.Append("        JLTCSX AS 记录图形属性 ");
                sqlQuery.Append(" FROM   " + tableName);
                sqlQuery.Append(" WHERE   FKXMMC = '" + strProjectName + "'");
                sqlQuery.Append(" AND    DKBH = '" + strDkbh + "'");
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                gkfqd.Common.DbUse.GetOleDbconnection().Open();
                dataSetOutPut.Clear();
                OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                MyAdapter.Fill(dataSetOutPut);
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<CL_BUILD_NEW_BLOCK>");
                sw.WriteLine("  <BUILDNLANDNO name=\"建新地块编号\">" + dataSetOutPut.Tables[0].Rows[0]["建新地块编号"].ToString() + "</BUILDNLANDNO>");
                sw.WriteLine("  <BLOCATION name=\"位置\"> " + dataSetOutPut.Tables[0].Rows[0]["位置"].ToString() + "</BLOCATION>");
                sw.WriteLine("  <LANDNAME name=\"地块名称\">" + dataSetOutPut.Tables[0].Rows[0]["地块名称"].ToString() + "</LANDNAME>");
                sw.WriteLine("  <LANDAREA name=\"地块面积\">" + dataSetOutPut.Tables[0].Rows[0]["地块面积"].ToString() + "</LANDAREA>");
                sw.WriteLine("  <COORSYSTEM name=\"坐标系\">" + dataSetOutPut.Tables[0].Rows[0]["坐标系"].ToString() + "</COORSYSTEM>");
                sw.WriteLine("  <CUTNU name=\"几度分带\">" + dataSetOutPut.Tables[0].Rows[0]["几度分带"].ToString() + "</CUTNU>");
                sw.WriteLine("  <SHADOWTYPE name=\"投影类型\">" + dataSetOutPut.Tables[0].Rows[0]["投影类型"].ToString() + "</SHADOWTYPE>");
                sw.WriteLine("  <MEASUREMENT name=\"计量单位\">" + dataSetOutPut.Tables[0].Rows[0]["计量单位"].ToString() + "</MEASUREMENT>");
                sw.WriteLine("  <PRECISION name=\"精度\">" + dataSetOutPut.Tables[0].Rows[0]["精度"].ToString() + "</PRECISION>");
                sw.WriteLine("  <DROPNU name=\"界址点数\">" + dataSetOutPut.Tables[0].Rows[0]["界址点数"].ToString() + "</DROPNU>");
                sw.WriteLine("  <DRAWINGPROPERTY name=\"记录图形属性\"> " + dataSetOutPut.Tables[0].Rows[0]["记录图形属性"].ToString() + "</DRAWINGPROPERTY>");
                sw.Write("  <param ZB=\"@1$");
                //"1,3795840.7720,39534660.2200;2,3795836.7200,39534645.9400;3,3795824.1590,39534648.6700;4,3795780.9330,39534495.1600;5,3796003.2890,39534435.7600;6,3796049.6000,39534601.4200;7,3795840.7720,39534660.2200;" />");


                DataGridViewRow dgvr1   = dataGridView2.CurrentRow;
                string          strSmid = dgvr1.Cells["地块编号"].Value.ToString();
                // 构造一个查询参数对象,查询选中的记录
                QueryParameter para = new QueryParameter();
                para.AttributeFilter = "SMID =" + strSmid;
                para.CursorType      = CursorType.Dynamic;

                DatasetVector           importResultShp = null;
                SuperMap.Data.Workspace workspace1;
                workspace1 = new SuperMap.Data.Workspace();

                /*WorkspaceconnectionInfo workspaceconnectionInfo = new WorkspaceconnectionInfo();
                 * workspaceconnectionInfo.Type = WorkspaceType.Oracle;
                 * workspaceconnectionInfo.Server = "ORCL";
                 * workspaceconnectionInfo.Database = "";
                 * workspaceconnectionInfo.Name = "workspace";
                 * workspaceconnectionInfo.User = "******";
                 * workspaceconnectionInfo.Password = "******";
                 * workspace1.Open(workspaceconnectionInfo);*/
                workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
                importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
                importResultShp  = importDatasource.Datasets[tableName] as DatasetVector;
                Recordset recordset = null;
                try
                {
                    recordset = importResultShp.Query(para);
                    while (!recordset.IsEOF)
                    {
                        Geometry  geometry = recordset.GetGeometry();
                        GeoRegion region   = geometry as GeoRegion;
                        for (int i = 0; i < region.PartCount; i++)
                        {
                            Point2Ds point2ds = region[i];
                            for (int k = 0; k < point2ds.Count; k++)
                            {
                                Point2D point2d = point2ds[k];
                                sw.Write((k + 1).ToString() + "," + point2d.X.ToString() + "," + point2d.Y.ToString() + ";");
                            }
                        }
                        recordset.MoveNext();
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
                finally
                {
                    recordset.Dispose();
                }
                sw.WriteLine(" \" />");
                sw.WriteLine("</CL_BUILD_NEW_BLOCK>");
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
                MessageBox.Show("建新地块信息导出成功!");
            }
        }
예제 #28
0
        private void button5_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter   = "导出txt坐标文件(*.txt)|*.txt";
            sfd.FileName = "坐标导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss");

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = new FileStream(sfd.FileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);

                if (dataGridView2.CurrentRow == null)
                {
                    return;
                }
                DataGridViewRow dgvr = dataGridView2.CurrentRow;

                string strSmid = dgvr.Cells["地块编号"].Value.ToString();//获取smid值
                // 构造一个查询参数对象,查询选中的记录
                QueryParameter para = new QueryParameter();
                para.AttributeFilter = "SMID =" + strSmid;
                para.CursorType      = CursorType.Dynamic;

                // DataGridViewRow dgvr1 = dataGridView2.CurrentRow;
                //取得当前行项目名称值
                string strProjectName = dgvr.Cells["项目名称"].Value.ToString();
                //取得当前行地块编号该编号为用户输入的
                string strDkbh   = dgvr.Cells["地块逻辑编号"].Value.ToString();
                string tableName = gkfqd.Common.DbUse.GetTownCodeByProjectNameJx(strProjectName);

                DatasetVector           importResultShp = null;
                SuperMap.Data.Workspace workspace1;
                workspace1 = new SuperMap.Data.Workspace();

                workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo());
                importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()];
                importResultShp  = importDatasource.Datasets[tableName] as DatasetVector;
                Recordset recordset = null;
                //取系统时间
                DateTime dt = DateTime.Now;

                if (dataGridView2.CurrentRow == null)
                {
                    MessageBox.Show("请点击地块表行头,选择地块信息!");
                    return;
                }

                sqlQuery.Clear();
                sqlQuery.Append("SELECT  DKMC AS 地块名称, ");
                sqlQuery.Append("        DKMJ AS 地块面积, ");
                sqlQuery.Append("        ZBX AS 坐标系, ");
                sqlQuery.Append("        JZDS AS 界址点数, ");
                sqlQuery.Append("        JDFD AS 几度分带, ");
                sqlQuery.Append("        JD AS 精度, ");
                sqlQuery.Append("        JLDW AS 计量单位, ");
                sqlQuery.Append("        JLTCSX AS 记录图形属性, ");
                sqlQuery.Append("        TYLX AS 投影类型 ");
                sqlQuery.Append(" FROM    " + tableName);
                sqlQuery.Append(" WHERE   FKXMMC = '" + strProjectName + "'");
                sqlQuery.Append(" AND    DKBH = '" + strDkbh + "'");
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                gkfqd.Common.DbUse.GetOleDbconnection().Open();
                dataSetOutPutZb.Clear();
                OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                MyAdapter.Fill(dataSetOutPutZb);
                gkfqd.Common.DbUse.GetOleDbconnection().Close();

                sw.WriteLine("[属性描述]");
                sw.WriteLine("格式版本号=1.01版本");
                sw.WriteLine("数据产生单位=国土资源部");
                sw.WriteLine("数据产生日期=" + dt.ToLongDateString().ToString());
                sw.WriteLine("坐标系=" + dataSetOutPutZb.Tables[0].Rows[0]["坐标系"].ToString());
                sw.WriteLine("几度分带=" + dataSetOutPutZb.Tables[0].Rows[0]["几度分带"].ToString());
                sw.WriteLine("投影类型=" + dataSetOutPutZb.Tables[0].Rows[0]["投影类型"].ToString());
                sw.WriteLine("计量单位=" + dataSetOutPutZb.Tables[0].Rows[0]["计量单位"].ToString());
                sw.WriteLine("带号=" + dataSetOutPutZb.Tables[0].Rows[0]["几度分带"].ToString());
                sw.WriteLine("精度=" + dataSetOutPutZb.Tables[0].Rows[0]["精度"].ToString());
                sw.WriteLine("转换参数=0,0,0,0,0,0,0");
                sw.WriteLine("[地块坐标]");
                //保留该行记录导出结果,界址点数,地块面积,地块编号,地块名称,记录图形属性(点、线、面),图幅号,地块用途,地类编码,@
                //以上记录信息如界址点数、地块面积、地块用途、地类编码需进一步编码取得
                //sw.WriteLine("9,0.018,2003-10,双桥乡地块1,面,I-50-77-(22),公共基础设施,,@");
                try
                {
                    recordset = importResultShp.Query(para);
                    while (!recordset.IsEOF)
                    {
                        Geometry  geometry = recordset.GetGeometry();
                        GeoRegion region   = geometry as GeoRegion;
                        for (int i = 0; i < region.PartCount; i++)
                        {
                            Point2Ds point2ds = region[i];
                            for (int k = 0; k < point2ds.Count; k++)
                            {
                                Point2D point2d = point2ds[k];
                                //点号,地块圈号,X坐标,Y坐标
                                sw.WriteLine((k + 1).ToString() + "," + (i + 1).ToString() + "," + point2d.X.ToString() + "," + point2d.Y.ToString());
                            }
                        }
                        recordset.MoveNext();
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
                finally
                {
                    recordset.Dispose();
                }
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
                MessageBox.Show("建新属性坐标信息导出成功!");
            }
        }
예제 #29
0
 public void ImportTIFFTest(string importPath, string sourceUDB)
 {
     try
     {
         // 1. 构建数据源连接对象。
         DatasourceConnectionInfo info = new DatasourceConnectionInfo();
         info.Server = sourceUDB;
         WorkspaceConnectionInfo ConnectionInfo = new WorkspaceConnectionInfo(sourceUDB);
         SuperMap.Data.Workspace wps = new SuperMap.Data.Workspace();
         wps.Create(ConnectionInfo);
         Datasources ds = wps.Datasources;
         //ds.Open(info);
         Datasource dss = ds.Create(info); // new Datasource();
         //dss.Connect();
         // 2. 构建SHP导入设置对象(ImportSettingSHP),设置数据源,设置导入数据路径。
         ImportSettingTIF importSettingTIF = new ImportSettingTIF();
         importSettingTIF.ImportMode = ImportMode.Overwrite;//可复写
         importSettingTIF.SourceFilePath = importPath;
         importSettingTIF.TargetDatasourceConnectionInfo = info;
         importSettingTIF.ImportingAsGrid = true;//栅格数据集形式
         // 3. 获取导入设置对象的导入信息集合(ImportDataInfos),设置目标数据集的名字。
         // ImportDataInfo dataInfos = importSettingSHP.GetTargetDataInfos("");
         //importSettingSHP.SetTargetDataInfos(dataInfos);
         // 4. 构建数据导入类对象(DataImport),构建并设置导入设置对象集合。
         PrjCoordSys prj = new PrjCoordSys();
         prj.Type = PrjCoordSysType.SphereMercator;
         importSettingTIF.TargetPrjCoordSys = prj;//设置了参考投影,还需改变其投影转换
         //prj.GeoCoordSys.FromXML(readXML())
         DataImport import1 = new DataImport();
         ImportSettings settings = import1.ImportSettings;
         settings.Add(importSettingTIF);
         import1.Run();
         try
         {
             int m = importPath.LastIndexOf('\\');
             string dsName = importPath.Substring(m + 1);
             int n = dsName.LastIndexOf('.');
             string dsname = dsName.Substring(0, n);
             Datasets datasets = dss.Datasets;
             Dataset m_processDataset = datasets[dsname];
             PrjCoordSys prj1 = new PrjCoordSys();
             prj1.FromXML(readXML(@"G:\移动风险监测\参考坐标\CGCS_2000.xml"));
             Boolean result = CoordSysTranslator.Convert(m_processDataset, prj1, new CoordSysTransParameter(), CoordSysTransMethod.GeocentricTranslation);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         i++;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }