Beispiel #1
0
 /// <summary>
 /// 双击鼠标,停止绘制
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gmapControl_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && lineElement != null)
     {
         lineElement.UpdatePosition(listMapPoints); // 更新
         layer.Refresh();                           // 刷新
         gmapControl.MouseMove -= gmapControl_MouseMove;
         drawn = false;
         listMapPoints.Clear();
         RegistCommondExcuteEvent();
         ReleaseCommond();//修改  陈静
     }
 }
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
        // 更新目标航迹
        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 #5
0
        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (listMapPoints.Count != 0)
            {
                MapLngLat moveLnglat = new MapLngLat(e.mapX, e.mapY);
                if (!isControl)//若没有按下空格
                {
                    listMapPoints.Add(moveLnglat);

                    switch (measureType)
                    {
                    case "distance":
                        measureLine.UpdatePosition(listMapPoints);
                        segmentLength = MapFrame.Core.Common.Utils.GetDistance(downPoint, moveLnglat);
                        toltalLength += segmentLength;
                        ResultEventArgs(string.Format("当前线段长度为:{0} 千米 \n总线段长度为:{1}千米", segmentLength, toltalLength));
                        toltalLength -= segmentLength;
                        break;

                    case "area":

                        measurePolygon.UpdatePosition(listMapPoints);
                        IPolygon             polygon     = new PolygonClass();
                        IGeometry            geometry    = null;
                        ITopologicalOperator topo        = null;
                        IPointCollection     pointCollec = new PolygonClass();
                        for (int i = 0; i < listMapPoints.Count; i++)
                        {
                            pointCollec.AddPoint(new PointClass()
                            {
                                X = listMapPoints[i].Lng, Y = listMapPoints[i].Lat
                            });
                        }
                        polygon = pointCollec as IPolygon;
                        if (polygon != null)
                        {
                            polygon.Close();
                            geometry = polygon as IGeometry;
                            topo     = geometry as ITopologicalOperator;
                            topo.Simplify();
                            geometry.Project(mapControl.Map.SpatialReference);
                            IArea area = geometry as IArea;

                            if (area != null)
                            {
                                measureArea = area.Area;
                                ResultEventArgs(string.Format("面积为:{0} 万平方千米", measureArea));
                                polygon = null;
                            }
                        }
                        break;
                    }
                    listMapPoints.Remove(moveLnglat);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// 鼠标移动事件  实时绘制线
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
 {
     if (listMapPoints.Count != 0 && !isControl)
     {
         if (!isControl)//若没有按下空格
         {
             MapLngLat moveLnglat = new MapLngLat(e.mapX, e.mapY);
             listMapPoints.Add(moveLnglat);
             lineElement.UpdatePosition(listMapPoints);
             listMapPoints.Remove(moveLnglat);
         }
     }
 }
Beispiel #7
0
        private void 更新位置ToolStripMenuItem1_Click(object sender, System.EventArgs e)
        {
            if (lineElement == null)
            {
                return;
            }
            MapLngLat        map1    = new MapLngLat(56, 48);
            MapLngLat        map2    = new MapLngLat(101, 69);
            List <MapLngLat> listMap = new List <MapLngLat>();

            listMap.Add(map1);
            listMap.Add(map2);
            lineElement.UpdatePosition(listMap);
        }
Beispiel #8
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 #9
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();
        }