Ejemplo n.º 1
0
        private void ImportExeclData(DataTable table)
        {
            pts = new Point2Ds();
            Point2D pnt = new Point2D();

            for (int p = 0; p < table.Rows.Count; p++)
            {
                pnt.X = Convert.ToDouble(table.Rows[p][0].ToString());
                pnt.Y = Convert.ToDouble(table.Rows[p][1].ToString());
                pts.Add(pnt);
            }
            trackLine = new GeoLine();
            trackLine.AddPart(pts);
            trackLine.Style = pStyle;

            //添加轨迹路线
            m_MapControl.Map.TrackingLayer.Add(trackLine, "GPSTrack");
            m_MapControl.Map.EnsureVisible(trackLine);
            m_MapControl.Map.Zoom(0.7);
            m_MapControl.Map.Refresh();
        }
Ejemplo n.º 2
0
        private void DisplayRect(Rectangle2D rectangleDisplay)
        {
            try
            {
                m_engleRectangle            = rectangleDisplay;
                m_mapControlEagleEye.Cursor = Cursors.Cross;

                Double   rectangleWidth  = rectangleDisplay.Width;
                Double   rectangleHeight = rectangleDisplay.Height;
                Double   pntLeftTopX     = rectangleDisplay.Left;
                Double   pntLeftTopY     = rectangleDisplay.Top;
                Point2Ds points          = new Point2Ds();
                Point2D  pntLeftTop      = new Point2D(pntLeftTopX, pntLeftTopY);
                points.Add(pntLeftTop);
                Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight);
                points.Add(pntLeftBottom);
                Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight);
                points.Add(pntRightBottom);
                Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY);
                points.Add(pntRightTop);
                points.Add(pntLeftTop);
                GeoLine rectangleBoundary = new GeoLine();
                rectangleBoundary.AddPart(points);

                GeoStyle rectangleStyle = new GeoStyle();
                rectangleStyle.LineColor = Color.FromArgb(255, 0, 0);
                rectangleStyle.LineWidth = 0.5;

                rectangleBoundary.Style = rectangleStyle;
                m_mapControlEagleEye.Map.TrackingLayer.Clear();
                m_mapControlEagleEye.Map.TrackingLayer.Add((Geometry)rectangleBoundary, "");
                m_mapControlEagleEye.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 按照指定风格显示矩形框
        /// </summary>
        /// <param name="rectDisplay"></param>
        private void DisplayRect(Rectangle2D rectangleDisplay)
        {
            try
            {
                m_engleRectangle = rectangleDisplay;

                Double rectangleWidth  = rectangleDisplay.Width;
                Double rectangleHeight = rectangleDisplay.Height;
                Double pntLeftTopX     = rectangleDisplay.Left;
                Double pntLeftTopY     = rectangleDisplay.Top;
                //设置图框四点坐标
                Point2Ds points = new Point2Ds();

                Point2D pntLeftTop = new Point2D(pntLeftTopX, pntLeftTopY);
                points.Add(pntLeftTop);
                Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight);
                points.Add(pntLeftBottom);
                Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight);
                points.Add(pntRightBottom);
                Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY);
                points.Add(pntRightTop);
                points.Add(pntLeftTop);
                //将点连成线,并设置样式

                GeoLine rectangleBoundary = new GeoLine();
                rectangleBoundary.AddPart(points);

                GeoStyle rectangleStyle = new GeoStyle();
                rectangleStyle.LineColor = Color.FromArgb(255, 0, 0);
                rectangleStyle.LineWidth = 0.5;

                rectangleBoundary.Style = rectangleStyle;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }