Преглед изворни кода

新增管点时增加坐标输入功能

419638610@qq.com пре 1 година
родитељ
комит
439da142a9

BIN
Package/wwGIS110.smwu


BIN
Package/~[0]@wwGIS110.smwu


+ 106 - 12
WWPipeLine/WWPipeLine.Map/Tools/Conditions/EditGuanWang/GuanDianXinZeng.cs

@@ -25,7 +25,7 @@ namespace WWPipeLine.MapTools.Conditions.EditGuanWang
         public GuanDianXinZeng() : base()
         {
             this.ConditionPanelName = "新增管点信息";
-            this.SetSize(300, 900);
+            this.SetSize(300, 550);
             InitializeComponent();
             this.IsShowResultWindow = false;
             LayerPanel = new LayerWithDataListPanel();
@@ -318,9 +318,9 @@ namespace WWPipeLine.MapTools.Conditions.EditGuanWang
             // 
             // textBoxX
             // 
-            this.textBoxX.Location = new System.Drawing.Point(123, 326);
+            this.textBoxX.Location = new System.Drawing.Point(85, 326);
             this.textBoxX.Name = "textBoxX";
-            this.textBoxX.Size = new System.Drawing.Size(100, 29);
+            this.textBoxX.Size = new System.Drawing.Size(180, 29);
             this.textBoxX.TabIndex = 3;
             // 
             // label2
@@ -334,16 +334,16 @@ namespace WWPipeLine.MapTools.Conditions.EditGuanWang
             // 
             // textBoxY
             // 
-            this.textBoxY.Location = new System.Drawing.Point(123, 368);
+            this.textBoxY.Location = new System.Drawing.Point(85, 368);
             this.textBoxY.Name = "textBoxY";
-            this.textBoxY.Size = new System.Drawing.Size(100, 29);
+            this.textBoxY.Size = new System.Drawing.Size(180, 29);
             this.textBoxY.TabIndex = 5;
             // 
             // button1
             // 
-            this.button1.Location = new System.Drawing.Point(200, 403);
+            this.button1.Location = new System.Drawing.Point(190, 403);
             this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.Size = new System.Drawing.Size(75, 32);
             this.button1.TabIndex = 6;
             this.button1.Text = "定位";
             this.button1.UseVisualStyleBackColor = true;
@@ -376,17 +376,111 @@ namespace WWPipeLine.MapTools.Conditions.EditGuanWang
             {
                 Sunny.UI.UIMessageTip.ShowError("请选择需要新增节点的图层,并输入正确的坐标!仅能输入数字、小数点"); return;
             }
-            Point2D point = new Point2D(pointX, pointY);
-            MapControl.Map.Center = point;
+
+            Point2D pClickTmp = new Point2D(pointX, pointY);
+            Point2Ds point2Ds = new Point2Ds();
+            point2Ds.Add(pClickTmp);
+
+            PrjCoordSys srcTY = GetTargetPrjCoordSys(1); // 原坐标系(大安中央子午线是123)
+            PrjCoordSys desTY = new PrjCoordSys(4549); // 目标坐标系
+
+            bool forward = CoordSysTranslator.Convert(point2Ds, srcTY, desTY, new CoordSysTransParameter(), CoordSysTransMethod.GeocentricTranslation);
+
+            Point2D pClick = point2Ds[0];
+            MapControl.Map.Center = pClick;
             MapControl.Map.Refresh();
 
-            _geoPoint = new GeoPoint(point);
-            _geoPoint.X = Convert.ToDouble(textBoxX.Text);
-            _geoPoint.Y = Convert.ToDouble(textBoxY.Text);
+            //限制线上点(即执行管线打断功能)
+            if (uiCBpol.Checked)
+            {
+                GeoPoint pointClick = new GeoPoint(pClick);
+                Recordset rdJSLK = ComsStatic.gsGuanXian.Query(pointClick, 3, CursorType.Static);
+                if (rdJSLK.RecordCount == 0)
+                {
+                    Sunny.UI.UIMessageTip.ShowError("当前鼠标双击点附近没有找到管线信息"); return;
+                }
+                double distance_temp = 0.0D;
+                double distance = 0.0D;
+                GeoLine _rd_temp;
+                GeoLine _rd_line = new GeoLine();
+                rdJSLK.MoveFirst();
+                while (!rdJSLK.IsEOF)
+                {
+                    _rd_temp = rdJSLK.GetGeometry() as GeoLine;
+                    distance_temp = Geometrist.Distance(pointClick, _rd_temp);
+                    if (distance_temp <= distance || distance == 0.0D)
+                    {
+                        distance = distance_temp;
+                        _rd_line = _rd_temp;
+                        gxSMID = Int32.Parse(rdJSLK.GetFieldValue("smid").ToString());
+                    }
+                    rdJSLK.MoveNext();
+                }
+                ComsStatic.RecordsetDispose(rdJSLK);
+                pClick = Geometrist.NearestPointToVertex(pClick, _rd_line);
+            }
+            _geoPoint = new GeoPoint(pClick);
             _geoPoint.Style = ComsStatic.geoStyle_Red_Mark5mm;
             MapControl.Map.TrackingLayer.Clear();
             MapControl.Map.TrackingLayer.Add(_geoPoint, "jiedian");
             MapControl.Map.RefreshTrackingLayer();
         }
+
+        /// <summary>
+        /// 按照不同的投影类型,初始化投影坐标系
+        /// </summary>
+        /// <param name="type">1:高斯投影;2:UTM投影;3:兰勃脱投影</param>
+        /// <returns></returns>
+        private PrjCoordSys GetTargetPrjCoordSys(int type)
+        {
+            PrjCoordSys targetPrjCoordSys = null;
+            PrjParameter parameter = null;
+            Projection projection = null;
+
+            switch (type)
+            {
+                case 1:
+                    {
+                        targetPrjCoordSys = new PrjCoordSys(PrjCoordSysType.UserDefined);
+                        projection = new Projection(ProjectionType.GaussKruger);
+                        targetPrjCoordSys.Projection = projection;
+                        parameter = new PrjParameter();
+                        parameter.CentralMeridian = 123;
+                        parameter.FalseEasting = 500000;
+                        parameter.ScaleFactor = 1;
+
+                        GeoCoordSys geoCoordSys = new GeoCoordSys();
+                        geoCoordSys.Type = GeoCoordSysType.China2000;
+                        targetPrjCoordSys.GeoCoordSys = geoCoordSys;
+                        targetPrjCoordSys.PrjParameter = parameter;
+                    }
+                    break;
+                case 2:
+                    {
+                        targetPrjCoordSys = new PrjCoordSys(PrjCoordSysType.UserDefined);
+                        projection = new Projection(ProjectionType.TransverseMercator);
+                        targetPrjCoordSys.Projection = projection;
+                        parameter = new PrjParameter();
+                        parameter.CentralMeridian = 110;
+                        parameter.StandardParallel1 = 0;
+                        targetPrjCoordSys.PrjParameter = parameter;
+                    }
+                    break;
+                case 3:
+                    {
+                        targetPrjCoordSys = new PrjCoordSys(PrjCoordSysType.UserDefined);
+                        projection = new Projection(ProjectionType.LambertConformalConic);
+                        targetPrjCoordSys.Projection = projection;
+                        parameter = new PrjParameter();
+                        parameter.CentralMeridian = 110;
+                        parameter.StandardParallel1 = 30;
+                        targetPrjCoordSys.PrjParameter = parameter;
+                    }
+                    break;
+                default:
+                    break;
+            }
+            return targetPrjCoordSys;
+        }
     }
 }