Beispiel #1
0
        /// <summary>
        /// 鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && !isControl)
            {
                downPoint = new MapLngLat(e.mapX, e.mapY);
                if (listMapPoints.Count == 0)
                {
                    listMapPoints.Add(downPoint);

                    Kml kmlLine = new Kml();
                    kmlLine.Placemark.Name = "arc_line" + Utils.ElementIndex;

                    KmlLineString line = new KmlLineString();
                    line.PositionList       = listMapPoints;
                    line.Color              = Color.Gray;
                    line.Width              = 2;
                    kmlLine.Placemark.Graph = line;
                    IMFElement element = null;
                    layer.AddElement(kmlLine, out element);
                    lineElement = element as IMFLine;//绘制完成后得到该图元
                    isFinish    = false;
                }
                //若重复点击同一个点则不添加
                else if (listMapPoints.Find(p => p.Lng == downPoint.Lng && p.Lat == downPoint.Lat) == null)
                {
                    listMapPoints.Add(downPoint);
                }
            }
        }
Beispiel #2
0
        private void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (eventInited == 1)
            {
                ICommand command = mapControl.CurrentTool as ICommand;
                if (command != null && command.Name == "ControlToolsMapNavigation_Pan")
                {
                    //更新标牌
                    IPoint targetPoint = base.Geometry as IPoint;
                    Core.Model.MapLngLat startPoint = new Core.Model.MapLngLat(targetPoint.X, targetPoint.Y);
                    int x = -1;
                    int y = -1;
                    mapControl.FromMapPoint(targetPoint, ref x, ref y);
                    mapLabel.UpdateLabelLocation(new System.Drawing.Point(x, y));

                    //更新线
                    IPoint labelPoint             = mapControl.ToMapPoint(mapLabel.Location.X, mapLabel.Location.Y);
                    Core.Model.MapLngLat endPoint = new Core.Model.MapLngLat(labelPoint.X, labelPoint.Y);
                    MapFrame.Core.Interface.IMFElement element = BelongLayer.GetElement("标牌线");
                    if (element == null)
                    {
                        return;
                    }
                    IMFLine lineElement = element as IMFLine;
                    List <Core.Model.MapLngLat> lnglatList = new List <Core.Model.MapLngLat>();
                    lnglatList.Add(startPoint);
                    lnglatList.Add(endPoint);
                    lineElement.UpdatePosition(lnglatList);
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// 鼠标左键双击
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void mapControl_eventLButtonDbClick(object sender, _DHOSOFTMapControlEvents_eventLButtonDbClickEvent e)
 {
     if (!isControl && listPoints.Count >= 2)
     {
         if (!string.IsNullOrEmpty(tempName))
         {
             mapControl.MgsDelObject(tempName);
         }
         //if (listPoints.Count < 2) return;
         Kml           kml  = new Kml();
         KmlLineString line = new KmlLineString();
         line.PositionList   = listPoints;
         line.Color          = System.Drawing.Color.Red;
         line.Width          = 3;
         kml.Placemark.Name  = "mgis_line" + Utils.ElementIndex;
         kml.Placemark.Graph = line;
         IMFElement element = null;
         layer.AddElement(kml, out element);
         lineElement = element as IMFLine;
         RegistCommondExecutedEvent();
         ReleaseCommond();//修改  陈静
         listPoints.Clear();
         isFinish = true;
     }
 }
Beispiel #4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_mapControl">arcgis地图控件</param>
 /// <param name="_element">要编辑的线图元</param>
 public EditLine(AxMapControl _mapControl, IMFElement _element)
 {
     element     = _element as IMFLine;
     markerList  = new List <EditMarker>();
     lineElement = _element as LineElementClass;
     mapControl  = _mapControl;
     pointList   = new List <Point_ArcMap>();
 }
Beispiel #5
0
        // 更新目标航迹
        private void UpdateTrackPoint(Model3D model)
        {
            List <TrackPoint> trackPoints = trackMgr.GetTrackPoints(model.ModelName);

            if (trackPoints == null || trackPoints.Count <= 1)
            {
                return;                                                   // 如果没有点,或者最多只有一个点,则返回不进行航迹绘制
            }
            var layer = mapLogic.AddLayer(model.LayerName);

            if (layer == null)
            {
                return;
            }

            string lineName = model.ModelName + "line";
            var    line     = layer.GetElement(lineName);

            if (line == null)
            {
                Kml kmlLine = new Kml();
                kmlLine.Placemark.Name = lineName;
                KmlLineString linekml = new KmlLineString();
                linekml.Color = Color.Red;
                linekml.Width = 1;
                List <MapLngLat> plist = new List <MapLngLat>();

                for (int i = 0; i < trackPoints.Count; i++)
                {
                    var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt);
                    plist.Add(point);
                }

                linekml.PositionList = plist;
                linekml.Rasterize    = false;

                kmlLine.Placemark.Graph = linekml;
                var result = layer.AddElement(kmlLine);
            }
            else
            {
                IMFLine lineElement = line as IMFLine;
                if (line == null)
                {
                    return;
                }

                List <MapLngLat> plist = new List <MapLngLat>();

                for (int i = 0; i < trackPoints.Count; i++)
                {
                    var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt);
                    plist.Add(point);
                }

                lineElement.UpdatePosition(plist);
            }
        }
        // 更新航迹
        private void UpdateTrackPoint(Plane plane)
        {
            List <TrackPoint> trackPoints = trackMgr.GetTrackPoints(plane.Name);

            if (trackPoints == null || trackPoints.Count <= 1)
            {
                return;
            }

            var layer = mapLogic.AddLayer(plane.LayerName);

            if (layer == null)
            {
                return;
            }

            string lineName = plane.Name + "line";
            var    line     = layer.GetElement(lineName);

            if (line == null)
            {
                Kml kmlLine = new Kml();
                kmlLine.Placemark.Name = lineName;
                KmlLineString lineKml = new KmlLineString();
                lineKml.Color = System.Drawing.Color.Blue;
                lineKml.Width = 1;
                List <MapLngLat> plist = new List <MapLngLat>();

                for (int i = 0; i < trackPoints.Count; i++)
                {
                    var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt);
                    plist.Add(point);
                }

                lineKml.PositionList    = plist;
                kmlLine.Placemark.Graph = lineKml;
                var ret = layer.AddElement(kmlLine);
            }
            else
            {
                IMFLine lineElement = line as IMFLine;
                if (line == null)
                {
                    return;
                }

                List <MapLngLat> plist = new List <MapLngLat>();
                for (int i = 0; i < trackPoints.Count; i++)
                {
                    var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt);
                    plist.Add(point);
                }

                lineElement.UpdatePosition(plist);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     listPoints.Clear();
     listPoints  = null;
     mapControl  = null;
     lineElement = null;
     isFinish    = false;
     isControl   = false;
     layer       = null;
     mapLogic    = null;
 }
Beispiel #8
0
        /// <summary>
        /// 鼠标单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1 && !isControl)
            {
                downPoint = new MapLngLat(e.mapX, e.mapY);
                if (listMapPoints.Count == 0)
                {
                    ResultEventArgs(" ");
                    listMapPoints.Add(downPoint);
                    switch (measureType)
                    {
                    case "distance":
                        Kml kmlLine = new Kml();
                        kmlLine.Placemark.Name = "mea_line";

                        KmlLineString line = new KmlLineString();
                        line.PositionList       = listMapPoints;
                        line.Color              = Color.Gray;
                        line.Width              = 2;
                        kmlLine.Placemark.Graph = line;
                        IMFElement element = null;
                        layer.AddElement(kmlLine, out element);
                        measureLine = element as IMFLine;    //绘制完成后得到该图元
                        isFinish    = false;
                        break;

                    case "area":
                        Kml kml = new Kml();
                        kml.Placemark.Name = "mea_arcPolygon";
                        Color outlineColor = Color.Blue;
                        Color fillColor    = Color.Black;
                        kml.Placemark.Graph = new KmlPolygon()
                        {
                            FillColor = fillColor, OutLineColor = outlineColor, OutLineSize = 1, PositionList = listMapPoints
                        };
                        IMFElement element1 = null;
                        layer.AddElement(kml, out element1);
                        measurePolygon = element1 as IMFPolygon;
                        isFinish       = false;
                        break;
                    }
                }
                else
                {
                    listMapPoints.Add(downPoint);
                }

                if (segmentLength != 0)
                {
                    //长度
                    toltalLength += segmentLength;
                }
            }
        }
Beispiel #9
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     gmapControl          = null;
     lineElement          = null;
     mapLogic             = null;
     listMapPoints        = null;
     layer     = null;
     drawn     = false;
     mouseDown = false;
 }
Beispiel #10
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            ReleaseCommond();

            CommondExecutedEvent = null;
            mapLogic             = null;
            mapControl           = null;
            lineElement          = null;
            listMapPoints        = null;
            isControl            = false;
            isFinish             = false;
        }
Beispiel #11
0
        private void 添加ToolStripMenuItem1_Click(object sender, System.EventArgs e)
        {
            Kml kml = new Kml();

            kml.Placemark.Name = "line";

            KmlLineString    linekml = new KmlLineString();
            List <MapLngLat> pList   = new List <MapLngLat>();

            pList.Add(new MapLngLat(101, 23));
            pList.Add(new MapLngLat(15, 50));

            linekml.PositionList = pList;
            kml.Placemark.Graph  = linekml;
            mapLogic.GetLayer(drawLayerName).AddElement(kml, out element);
            lineElement = element as IMFLine;
        }
Beispiel #12
0
        /// <summary>
        /// 鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gmapControl_MouseDown(object sender, MouseEventArgs e)
        {
            TimeSpan span = DateTime.Now - fistTimer;

            if (span.TotalMilliseconds < 170)
            {
                return;
            }
            fistTimer = DateTime.Now;
            if (e.Clicks == 2 || e.Button != MouseButtons.Left || mouseDown)
            {
                return;
            }
            var lngLat    = gmapControl.FromLocalToLatLng(e.X, e.Y);
            var maplngLat = new MapLngLat(lngLat.Lng, lngLat.Lat);

            if (listMapPoints.Count == 0)
            {
                //加线
                Kml kmlLine = new Kml();
                kmlLine.Placemark.Name = "draw_line" + Utils.ElementIndex;

                KmlLineString line = new KmlLineString();
                line.Color = Color.Green;
                line.Width = 2;
                List <MapLngLat> pList = new List <MapLngLat>();
                pList.Add(new MapLngLat(lngLat.Lng, lngLat.Lat));
                line.PositionList       = pList;                    //string.Format("{0},{1}", lngLat.Lng, lngLat.Lat);
                kmlLine.Placemark.Graph = line;
                IMFElement element = null;
                drawn       = layer.AddElement(kmlLine, out element);
                lineElement = element as IMFLine;
                listMapPoints.Add(maplngLat);
                gmapControl.MouseMove += gmapControl_MouseMove;
            }
            else
            {
                if (!listMapPoints.Contains(maplngLat))
                {
                    listMapPoints.Add(maplngLat);
                    lineElement.AddPoint(maplngLat);
                }
            }
        }
Beispiel #13
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     mapControl = null;
     mapLogic   = null;
     if (measureTool != null)
     {
         measureTool.Dispose();
     }
     downPoint            = null;
     listMapPoints        = null;
     toltalLength         = 0;
     segmentLength        = 0;
     measureArea          = 0;
     measureLine          = null;
     measurePolygon       = null;
     isFinish             = false;
     isControl            = false;
     measureType          = string.Empty;
     CommondExecutedEvent = null;
 }
Beispiel #14
0
        /// <summary>
        /// 标牌移动移动线的位置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapLabel_Move(object sender, EventArgs e)
        {
            IPoint targetPoint = base.Geometry as IPoint;

            Core.Model.MapLngLat startPoint = new Core.Model.MapLngLat(targetPoint.X, targetPoint.Y);//目标点

            MapFrame.ArcMap.Windows.MapLabel label = sender as MapFrame.ArcMap.Windows.MapLabel;
            IPoint labelLocation = mapControl.ToMapPoint(label.Location.X, label.Location.Y);

            Core.Model.MapLngLat endPoint = new Core.Model.MapLngLat(labelLocation.X, labelLocation.Y);//标牌点

            MapFrame.Core.Interface.IMFElement element = BelongLayer.GetElement("标牌线");
            if (element == null)
            {
                return;
            }
            IMFLine lineElement = element as IMFLine;
            List <Core.Model.MapLngLat> lnglatList = new List <Core.Model.MapLngLat>();

            lnglatList.Add(startPoint);
            lnglatList.Add(endPoint);
            lineElement.UpdatePosition(lnglatList);//更新位置
        }
Beispiel #15
0
        void Form1_CommondExecutedEvent(object sender, MessageEventArgs e)
        {
            switch (e.ToolType)
            {
            case ToolTypeEnum.Draw:
                element = e.Data as IMFElement;
                switch (element.ElementType)
                {
                case ElementTypeEnum.Circle:
                    circleElement = element as IMFCircle;
                    break;

                case ElementTypeEnum.Point:
                    pointElement = element as IMFPoint;
                    break;

                case ElementTypeEnum.Line:
                    lineElement = element as IMFLine;
                    double length = lineElement.GetDistance();
                    break;

                case ElementTypeEnum.Polygon:
                    polygonElement = element as IMFPolygon;
                    double area = polygonElement.GetArea();
                    break;

                case ElementTypeEnum.Text:
                    textElement = element as IMFText;
                    break;

                case ElementTypeEnum.Rectangle:
                    rectangleElement = element as IMFPolygon;
                    break;
                }
                break;

            case ToolTypeEnum.Measure:
                break;

            case ToolTypeEnum.Select:
                List <IMFElement> elements = (sender as IMFSelect).GetSelectElements();
                break;

            case ToolTypeEnum.Edit:
                switch (element.ElementType)
                {
                case ElementTypeEnum.Point:
                    pointElement = element as IMFPoint;
                    break;

                case ElementTypeEnum.Line:
                    lineElement = element as IMFLine;
                    double length = lineElement.GetDistance();
                    break;

                case ElementTypeEnum.Polygon:
                    polygonElement = element as IMFPolygon;
                    double area = polygonElement.GetArea();
                    break;

                case ElementTypeEnum.Text:
                    textElement = element as IMFText;
                    break;
                }
                break;
            }
        }
Beispiel #16
0
        // 更新波束位置
        private void UpdateBeamElement(Beam beam, Model3D model)
        {
            var layer = mapLogic.GetLayer(beam.BeamLayerName);

            if (layer == null)
            {
                return;
            }

            string           elementName      = beam.BeamName;
            List <MapLngLat> pointListPolygon = new List <MapLngLat>();
            List <MapLngLat> pointListCover   = new List <MapLngLat>();

            pointListPolygon.Add(model.Coordinate);
            //pointListCover.Add(new MapLngLat(beam.CenterPoint.Lng, beam.CenterPoint.Lat, 100000));

            for (double tempAngle = -180; tempAngle <= 180; tempAngle = tempAngle + beam.StepValue)
            {
                var p = Utils.GetPointByDistanceAndAngle(beam.Radius, beam.CenterPoint, tempAngle);
                if (p != null)
                {
                    pointListPolygon.Add(p);
                    pointListCover.Add(new MapLngLat(p.Lng, p.Lat, 100000));
                }
            }

            var coverLayer = mapLogic.AddLayer(coverLayerName);

            if (coverLayer != null)
            {
                // 线
                IMFElement eleLine = coverLayer.GetElement(elementName + "cover_line");
                if (eleLine != null)
                {
                    IMFLine line = eleLine as IMFLine;
                    if (line != null)
                    {
                        line.UpdatePosition(pointListCover);
                    }
                }

                // 更新覆盖图元
                IMFElement elePolygon = coverLayer.GetElement(elementName + "cover");
                if (elePolygon != null)
                {
                    IMFPolygon polygonEle = elePolygon as IMFPolygon;
                    if (polygonEle != null)
                    {
                        polygonEle.UpdatePosition(pointListCover);    // 更新覆盖图元位置
                    }
                }
            }

            // 更新波束图元
            IMFElement element = layer.GetElement(elementName);

            if (element == null)
            {
                return;
            }
            IMFPolygon polygonElement = element as IMFPolygon;

            if (polygonElement == null)
            {
                return;
            }
            polygonElement.UpdatePosition(pointListPolygon);    // 更新波束位置

            layer.Refresh();
        }