public static void Build(ref GMapOverlay OverlayOut)
        {
            // Here loop through defined sectors and display them on the map
            foreach (SystemAdaptationDataSet.SectorBorder Sector in SystemAdaptationDataSet.SectorBorderDataSet)
            {
                System.Collections.Generic.List<PointLatLng> SectorPointList = new System.Collections.Generic.List<PointLatLng>();
                foreach (GeoCordSystemDegMinSecUtilities.LatLongClass SectorPoint in Sector.SectorBorderPoints)
                {
                    SectorPointList.Add(new PointLatLng(SectorPoint.GetLatLongDecimal().LatitudeDecimal, SectorPoint.GetLatLongDecimal().LongitudeDecimal));
                }

                // Get sector border display attributes
                DisplayAttributes.DisplayAttributesType SectorBorderDisplayAttribute = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.SectorBorder);

                GMapPolygon SectorPolygon = new GMapPolygon(SectorPointList, Sector.SectorName);
                SectorPolygon.Stroke = new Pen(SectorBorderDisplayAttribute.LineColor, SectorBorderDisplayAttribute.LineWidth);

                Type brushType = typeof(Brushes);

                Brush myBrush = (Brush)brushType.InvokeMember(SectorBorderDisplayAttribute.AreaPolygonColor.Name,
                 BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty,
                 null, null, new object[] { });

                SectorPolygon.Fill = myBrush;
                OverlayOut.Polygons.Add(SectorPolygon);

            }
        }
        public GMapMarkerPhoto(MAVLink.mavlink_camera_feedback_t mark, bool shotBellowMinInterval = false)
            : base(new PointLatLng(mark.lat/1e7, mark.lng/1e7))
        {
            local = mark;
            this.shotBellowMinInterval = shotBellowMinInterval;
            Offset = new Point(-localcache1.Width/2, -localcache1.Height/2);
            Size = localcache1.Size;
            Alt = mark.alt_msl;
            ToolTipMode = MarkerTooltipMode.OnMouseOver;

            Roll = local.roll - rolltrim;
            Pitch = local.pitch - pitchtrim;
            Yaw = local.yaw - yawtrim;

            ToolTipText = "Photo" + "\nAlt: " + mark.alt_msl + "\nNo: "+ mark.img_idx + "\nRoll: "+Roll.ToString("0.00");

            Tag = mark.time_usec;

            var footprint = ImageProjection.calc(new PointLatLngAlt(Position.Lat, Position.Lng, Alt), Roll,
                Pitch, Yaw, hfov, vfov);

            footprintpoly = new GMapPolygon(footprint.ConvertAll(x => x.Point()), "FP"+mark.time_usec);

            footprintpoly.Fill = Brushes.Transparent;
            footprintpoly.Stroke = Pens.Crimson;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 绘制多边形
        /// </summary>
        /// <param name="name"></param>
        /// <param name="points"></param>
        public void DrawPolygon(string name, List<PointLatLng> points)
        {
            this.RemovePolygon(name);

            GMapPolygon polygon = new GMapPolygon(points, name);
            polygon.Stroke = new Pen(new SolidBrush(Color.FromArgb(255, 255, 0, 0)), 2);
            polygon.Fill = new SolidBrush(Color.FromArgb(30, 100, 100, 100));
            overlay.Polygons.Add(polygon);
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {


            // Initialize map:
            gMapControl.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gMapControl.Position = new GMap.NET.PointLatLng(0.06,34);
            // gMapControl.SetPositionByKeywords("Embu, kenya");

            //Placing a marker on a certain position
            GMapOverlay markersOverlay = new GMapOverlay("markers");
            GMarkerGoogle marker = new GMarkerGoogle(new  PointLatLng(0.06, 34.2),
              GMarkerGoogleType.green);            
            marker.ToolTipText = "This is the first marker we put up";
            marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            markersOverlay.Markers.Add(marker);
            gMapControl.Overlays.Add(markersOverlay);

            GMapOverlay markersOverlaymaseno = new GMapOverlay("markers");
            GMarkerGoogle masenomarker = new GMarkerGoogle(new PointLatLng(45, 45),
              GMarkerGoogleType.blue);
            masenomarker.ToolTipText = "This is the second marker we put up";
            masenomarker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            markersOverlay.Markers.Add(masenomarker);
            gMapControl.Overlays.Add(markersOverlay);

            markersOverlay.Markers.Add(marker);
            gMapControl.Overlays.Add(markersOverlay);

            GMapOverlay markersOverlaythird = new GMapOverlay("markers");
            GMarkerGoogle thirdmarker = new GMarkerGoogle(new PointLatLng(-45, 45),
              GMarkerGoogleType.red);
            thirdmarker.ToolTipText = "This is the third marker we put up";
            thirdmarker.ToolTipMode = MarkerTooltipMode.OnMouseOver;

            markersOverlay.Markers.Add(thirdmarker);
            gMapControl.Overlays.Add(markersOverlay);



            GMapOverlay polyOverlay = new GMapOverlay("polygons");
            List<PointLatLng> points = new List<PointLatLng>();
            points.Add(new PointLatLng(-25.969562, 32.585789));
            points.Add(new PointLatLng(-25.966205, 32.588171));
            points.Add(new PointLatLng(-25.968134, 32.591647));
            points.Add(new PointLatLng(-25.971684, 32.589759));
            GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
            polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gMapControl.Overlays.Add(polyOverlay);


        }
Exemplo n.º 5
0
        private void MapControl_OnPolygonEnter(GMapPolygon item)
        {
            if (marker != null)
                item.Overlay.Markers.Remove(marker);

            var point = item.Overlay.Control.PointToClient(Control.MousePosition);
            var pos = item.Overlay.Control.FromLocalToLatLng(point.X, point.Y);

            marker = new GMapMarkerRect(pos) { ToolTipMode = MarkerTooltipMode.Always, ToolTipText = createMessage(item.Tag), IsHitTestVisible = false };
            item.Overlay.Markers.Add(marker);
        }
Exemplo n.º 6
0
        void refreshRoute() {
            List<PointLatLng> linePoints = new List<PointLatLng>();

            foreach (GMapMarker m in routes.Markers) {                
                m.Tag = linePoints.Count;
                linePoints.Add(m.Position);
                m.ToolTipMode = MarkerTooltipMode.Never;
            }
            
            if (linePoints.Count > 0) {
                GMapPolygon route = new GMapPolygon(linePoints, "qytj");
                route.Stroke = new Pen(Color.Green);
                route.Stroke.Width = 2;
                routes.Polygons.Clear();
                routes.Polygons.Add(route);
            }
        }
            public Polygon(FlightPlanner host, string name, GMarkerGoogleType markerType, Color color, Brush brush, string tag = "")
            {
                this.markerType = markerType;
                this.color = color;
                this.brush = brush;

                //setup drawnpolygon
                List<PointLatLng> list = new List<PointLatLng>();
                polygon = new GMapPolygon(list, name + "poly");
                polygon.Stroke = new Pen(color, 2);
                polygon.Fill = brush;

                overlay = new GMapOverlay(name + "polygonoverlay");
                this.host = host;
                host.MainMap.Overlays.Add(this.overlay);
                this.tag = tag;
            }
        public static void DrawS2Cells(List<ulong> cellsIds, GMapOverlay mapLayer)
        {
            for (int i=0; i<cellsIds.Count; i++)
            {
                S2CellId cellId = new S2CellId(cellsIds[i]);
                S2Cell cell = new S2Cell(cellId);

                List<PointLatLng> points = new List<PointLatLng>();
                for (int j=0; j<4; j++)
                {
                    S2LatLng point = new S2LatLng(cell.GetVertex(j));
                    points.Add(new PointLatLng(point.LatDegrees, point.LngDegrees));
                }
                GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
                polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
                polygon.Stroke = new Pen(Color.Red, 1);
                mapLayer.Polygons.Add(polygon);
            }
        }
Exemplo n.º 9
0
        private void Control_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
                return;

            if (item.Overlay.Control.IsDragging)
                return;

            if (_mapControl.Overlays.First(x => x.Polygons.Any(i => i.Name == item.Name)) != null)
            {
                if (item.Tag is Feature)
                {
                    var prop = ((Feature)item.Tag).Properties;

                    var display = prop["display"] as Newtonsoft.Json.Linq.JObject;

                    var sections = display["sections"];

                    string title;
                    string text;

                    if (sections.Count() == 0)
                    {
                        title = prop["detailedCategory"].ToString();
                        text = "";
                    }
                    else
                    {
                        var section1 = sections[0];

                        var iconURL = section1["iconUrl"].ToString();
                        title = section1["title"].ToString();
                        text = section1["text"].ToString();
                    }

                    var st = String.Format("{0} is categorised as a {1}\n\n{2}", prop["name"], title, text);

                    CustomMessageBox.Show(st, "Info", MessageBoxButtons.OK);
                }
            }
        }
 public void AddOrUpdatePolygon(string name, List <PointLatLng> points, ColorInfo colorInfo, Feature featureInfo)
 {
     try
     {
         _context.Send(_ =>
         {
             var polygon = _overlay.Polygons.FirstOrDefault(p => p.Name == name);
             if (polygon == null)
             {
                 polygon = new GMapPolygon(points, name);
                 _overlay.Polygons.Add(polygon);
             }
             polygon.Fill             = new SolidBrush(Color.FromArgb((int)colorInfo.FillColor));
             polygon.Stroke           = new Pen(Color.FromArgb((int)colorInfo.StrokeColor), colorInfo.StrokeWidth);
             polygon.IsHitTestVisible = true;
             polygon.Tag = featureInfo;
         }, null);
     }
     catch (InvalidAsynchronousStateException)
     {
     }
 }
Exemplo n.º 11
0
        public void Add(GMapPolygon footprint)
        {
            DateTime start = DateTime.Now;

            // if the same name footprint exists exit
            if (footprintpolys.Any(p => p.Name == footprint.Name))
            {
                return;
            }

            // if this is the first entry reset area
            if (footprintpolys.Count == 0)
            {
                Position = footprint.Points[0];
                area     = new RectLatLng(footprint.Points[0], new SizeLatLng(0, 0));
            }

            // add the new footprint
            footprintpolys.Add(footprint);

            // recalc the area
            foreach (var point in footprint.Points)
            {
                if (!area.Contains(point))
                {
                    double tllat = Math.Max(area.Lat, point.Lat);
                    double tllng = Math.Min(area.Lng, point.Lng);
                    double brlat = Math.Min(area.Bottom, point.Lat);
                    double brlng = Math.Max(area.Right, point.Lng);
                    // enlarge the area
                    area = RectLatLng.FromLTRB(tllng, tllat, brlng, brlat);
                }
            }

            generateCoverageFP(footprint);

            Console.WriteLine("Add " + (DateTime.Now - start));
        }
Exemplo n.º 12
0
        private void DisplayCaptures(List <Capture> captures)
        {
            rtbResult.Text += "Area requires " + captures.Count + " captures\n\n";

            foreach (Capture capture in captures)
            {
                GMapMarker captureMarker = new GMarkerGoogle(new PointLatLng(capture.Coordinate[0], capture.Coordinate[1]), GMarkerGoogleType.blue);
                captureMarker.ToolTipText = capture.URL + "\nDouble-click to copy to clipboard";
                captureOverlay.Markers.Add(captureMarker);

                double[] captureSize = GetCaptureDimensions(capture.Altitude, capture.Overlap);
                double   topLat      = capture.Coordinate[0] + DistanceToLat(captureSize[1] / 2);
                double   topLng      = capture.Coordinate[1] - DistanceToLng(topLat, captureSize[0] / 2);
                double   bottomLat   = capture.Coordinate[0] - DistanceToLat(captureSize[1] / 2);
                double   bottomLng   = capture.Coordinate[1] + DistanceToLng(bottomLat, captureSize[0] / 2);

                GMapPolygon capturePoly = new GMapPolygon(new List <PointLatLng>()
                {
                    new PointLatLng(topLat, topLng), new PointLatLng(topLat, bottomLng),
                    new PointLatLng(bottomLat, bottomLng), new PointLatLng(bottomLat, topLng)
                }, "");

                if (capture.Completed)
                {
                    capturePoly.Stroke = new Pen(Color.Red, 2);
                }
                else
                {
                    capturePoly.Stroke = new Pen(Color.Blue, 2);
                }

                capturePoly.Fill = new SolidBrush(Color.Empty);
                captureOverlay.Polygons.Add(capturePoly);

                rtbResult.Text += capture.URL + "\n";
            }
            rtbResult.Text += "\n";
        }
Exemplo n.º 13
0
        /// <summary>
        /// Set wind turbines on the map + rings around each wind turbine to see the checkin limit
        /// </summary>
        private void Setmarkers()
        {
            MapControl mapc = new MapControl();

            GMap.NET.WindowsForms.GMapOverlay markersOverlay = new GMapOverlay("markersSim");

            gMapSim.Overlays.Add(markersOverlay);

            GMapOverlay polyOverlay = new GMapOverlay("polygons");
            int         Points      = 50;
            double      radius      = 0.005;
            double      point       = Math.PI * 2 / Points;


            foreach (GMap.NET.WindowsForms.GMapMarker mark in mapc.DrawMarkers())
            {
                markersOverlay.Markers.Add(mark);

                List <PointLatLng> pointsList = new List <PointLatLng>();

                for (int i = 0; i < Points; i++)
                {
                    double theta          = point * i;
                    double latitudePoint  = mark.Position.Lat + Math.Cos(theta) * radius;
                    double longitudePoint = mark.Position.Lng + Math.Sin(theta) * radius;

                    PointLatLng latlongPoint = new PointLatLng(latitudePoint, longitudePoint);

                    pointsList.Add(latlongPoint);
                }

                GMapPolygon circles = new GMapPolygon(pointsList, "pol");
                polyOverlay.Polygons.Add(circles);
            }

            gMapSim.Overlays.Add(polyOverlay);
            gMapSim.Update();
        }
Exemplo n.º 14
0
        //отрисовать по данным из грида (полезно при удалении точек)
        public void highlight_district_grid(DataGridView points_grid, int zoom)
        {
            GMapOverlay        polyOverlay = new GMapOverlay("polygons");
            List <PointLatLng> points      = new List <PointLatLng>();

            for (int i = 0; i < points_grid.Rows.Count - 1; i++)
            {
                points.Add(new PointLatLng(Convert.ToDouble(points_grid.Rows[i].Cells[0].Value),
                                           Convert.ToDouble(points_grid.Rows[i].Cells[1].Value)));
            }
            GMapPolygon polygon = new GMapPolygon(points, "mypolygon");

            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            // return polyOverlay;
            gMapControl.Overlays.Add(polyOverlay);

            zoom            += 1;
            gMapControl.Zoom = zoom;
            zoom            -= 1;
            gMapControl.Zoom = zoom;
        }
Exemplo n.º 15
0
        public static GMapPolygon CreateCircle(PointLatLng point, double radius, int segments)
        {
            List <PointLatLng> gpollist = new List <PointLatLng>();

            double seg = Math.PI * 2 / segments;

            for (int i = 0; i < segments; i++)
            {
                double theta = seg * i;
                double a     = point.Lat + Math.Cos(theta) * radius * 0.0000089889;
                double b     = point.Lng + Math.Sin(theta) * radius * 0.00001424549;

                PointLatLng gpoi = new PointLatLng(a, b);

                gpollist.Add(gpoi);
            }
            GMapPolygon gpol = new GMapPolygon(gpollist, "pol");

            gpol.Stroke = new Pen(Color.Purple, 1);
            gpol.Fill   = new SolidBrush(Color.FromArgb(20, Color.Purple));

            return(gpol);
        }
Exemplo n.º 16
0
        //원 그리기
        private void addCirclePolList(PointLatLng point, double radius)
        {
            double seg = Math.PI * 2 / 1000;

            for (int i = 0; i < 1000; i++)
            {
                double theta = seg * i;
                //double a = point.Lat + (Math.Cos(theta) * radius);
                double a = point.Lat + (Math.Cos(theta) * radius * ((-(point.Lat * point.Lat) / 8100) + ((1 / 270) * point.Lat) + 1));
                double b = point.Lng + (Math.Sin(theta) * radius);

                PointLatLng p = new PointLatLng(a, b);

                polList.Add(p);
            }

            //polygon 생성하고 등록
            polygon        = new GMapPolygon(polList, "polList");
            polygon.Stroke = new Pen(Color.Blue, 1);
            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.LightSkyBlue));

            overlay.Polygons.Add(polygon);
        }
Exemplo n.º 17
0
        private void CreateCircle(PointF point, double radius, int segments)
        {
            List <PointLatLng> gpollist = new List <PointLatLng>();

            double seg = Math.PI * 2 / segments;

            for (int i = 0; i < segments; i++)
            {
                double theta = seg * i;
                double a     = point.X + Math.Cos(theta) * radius;
                double b     = point.Y + Math.Sin(theta) * radius;

                PointLatLng gpoi = new PointLatLng(a, b);

                gpollist.Add(gpoi);
            }
            GMapPolygon gpol = new GMapPolygon(gpollist, "pol");

            overlayOne.Polygons.Add(gpol);
            this.gMapControl1.Overlays.Add(overlayOne);
            overlayOne.IsVisibile = false;
            overlayOne.IsVisibile = true;
        }
Exemplo n.º 18
0
        public void gambarpolygonKomoditi(string _komoditi)
        {
            gmap.MapProvider             = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
            gmap.Position = new PointLatLng(3.945651, 108.142867);

            GMapOverlay        polyOverlay = new GMapOverlay("polygons");
            List <PointLatLng> points      = new List <PointLatLng>();

            List <string>[] list;
            list = dbConnect.SelectLokasiKota(_komoditi);
            for (int i = 0; i < list[0].Count; i++)
            {
                points.Add(new PointLatLng(Convert.ToDouble(list[0][i]), Convert.ToDouble(list[1][i])));
            }
            GMapPolygon polygon = new GMapPolygon(points, "PT. Sukses");

            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gmap.Overlays.Add(polyOverlay);
            gmap.Zoom = 7;
        }
Exemplo n.º 19
0
        private void CreateCircle(PointLatLng point, double radius, int segments)
        {
            List <PointLatLng> gpollist = new List <PointLatLng>();
            double             seg      = Math.PI * 2 / segments;

            radius /= 100000;

            for (int i = 0; i < segments; i++)
            {
                double theta = seg * i;
                double a     = point.Lat + Math.Cos(theta) * radius * 0.9;
                double b     = point.Lng + Math.Sin(theta) * radius;

                gpollist.Add(new PointLatLng(a, b));
            }
            GMapPolygon gpol = new GMapPolygon(gpollist, "Hot");

            gpol.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            gpol.Stroke = new Pen(Color.Red, 1);

            mapOverlay.Polygons.Add(gpol);
            gMapControl.Overlays.Add(mapOverlay);
        }
Exemplo n.º 20
0
        private void CreateCircle(Double lat, Double lon, double radius)
        {
            PointLatLng point    = new PointLatLng(lat, lon);
            int         segments = 1000;

            List <PointLatLng> gpollist = new List <PointLatLng>();

            for (int i = 0; i < segments; i++)
            {
                gpollist.Add(FindPointAtDistanceFrom(point, i, radius / 1000));
            }

            GMapPolygon gpol        = new GMapPolygon(gpollist, "pol");
            GMapOverlay gMapOverlay = new GMapOverlay("markers");

            //add marker
            //gMapOverlay.Markers.Add(gMapMarker1);
            //gMapOverlay.Markers.Add(gMapMarkerPlane);
            gMapOverlay.Polygons.Add(gpol);


            gMapControl1.Overlays.Add(gMapOverlay);
        }
        private void CreateHeatmap(PointLatLng pllTopLeft, PointLatLng pllBottomRight, Brush bColor)
        {
            List <PointLatLng> points = new List <PointLatLng>
            {
                pllTopLeft,
                new PointLatLng(pllBottomRight.Lat, pllTopLeft.Lng),
                pllBottomRight,
                new PointLatLng(pllTopLeft.Lat, pllBottomRight.Lng),
            };

            GMapPolygon mp = new GMapPolygon(points);

            mp.RegenerateShape(this.mcMapControl);

            if (mp.Shape is System.Windows.Shapes.Path path)
            {
                path.Stroke          = Brushes.Black;
                path.StrokeThickness = 0.1;
                path.Fill            = bColor;
            }

            this.mcMapControl.Markers.Add(mp);
        }
        private void DrawMapPolygon(Coordinate[] coordinates)
        {
            //Declare List for pointlatlang
            List <PointLatLng> pointlatlang = new List <PointLatLng>();

            foreach (var coord in coordinates)
            {
                pointlatlang.Add(new PointLatLng(coord.Y, coord.X));
            }
            //Declare polygon in gmap
            GMapPolygon polygon = new GMapPolygon(pointlatlang);

            MainMap.RegenerateShape(polygon, false);
            //setting line style
            //polygon.Shape.SetValue(UIElement.OpacityProperty, 1.0);
            //(polygon.Shape as System.Windows.Shapes.Path).Stroke = Brushes.DarkRed;
            //(polygon.Shape as System.Windows.Shapes.Path).StrokeThickness = 3.5;
            //(polygon.Shape as System.Windows.Shapes.Path).Effect = null;
            (polygon.Shape as System.Windows.Shapes.Path).Fill = Brushes.Transparent;

            //To add polygon in gmap
            MainMap.Markers.Add(polygon);
        }
Exemplo n.º 23
0
        public GMapOverlay DrawGridSquare(AFS2GridSquare gridSquare, GridSquareDisplayType gridSquareDisplayType)
        {
            GMapPolygon polygon = new GMapPolygon(gridSquare.Coordinates, gridSquare.Name);

            switch (gridSquareDisplayType)
            {
            case GridSquareDisplayType.Selected:
                polygon.Fill   = new SolidBrush(Color.FromArgb(40, Color.Blue));
                polygon.Stroke = new Pen(Color.Blue, 1);
                break;

            case GridSquareDisplayType.Active:
                polygon.Fill   = new SolidBrush(Color.FromArgb(40, Color.Blue));
                polygon.Stroke = new Pen(Color.DeepSkyBlue, 2);
                break;

            case GridSquareDisplayType.Downloaded:
                polygon.Fill   = new SolidBrush(Color.FromArgb(40, Color.Orange));
                polygon.Stroke = new Pen(Color.Orange, 1);
                break;

            default:
                break;
            }


            GMapOverlay polygonOverlay = new GMapOverlay(gridSquare.Name);

            polygonOverlay.Polygons.Add(polygon);
            this.GMapControl.Overlays.Add(polygonOverlay);

            this.GMapControl.Refresh();
            polygonOverlay.IsVisibile = false;
            polygonOverlay.IsVisibile = true;

            return(polygonOverlay);
        }
Exemplo n.º 24
0
        private void drawDrops(string beatNumber)
        {
            GMapOverlay   polyOverlay = new GMapOverlay("drops");
            List <string> drops       = new List <string>();

            foreach (EsriDrops.esriDrop d in EsriDrops.dropPolygons)
            {
                if (!drops.Contains(d.BeatID) && d.BeatID != "NO BEAT ID")
                {
                    drops.Add(d.BeatID);
                }
            }

            var dList = from d in EsriDrops.dropPolygons
                        where d.BeatID == beatNumber
                        select d;

            foreach (EsriDrops.esriDrop ed in dList)
            {
                ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)ed.dropData.Geometry;
                List <PointLatLng> points             = new List <PointLatLng>();
                foreach (PointCollection pc in p.Rings)
                {
                    for (int i = 0; i < pc.Count; i++)
                    {
                        points.Add(new PointLatLng(pc[i].Y, pc[i].X));
                    }
                    points.Add(new PointLatLng(pc[0].Y, pc[0].X));
                }
                GMapPolygon poly = new GMapPolygon(points, "Drop " + beatNumber);
                poly.Fill   = new SolidBrush(Color.FromArgb(50, Color.Orange));
                poly.Stroke = new Pen(Color.Orange, 1);
                polyOverlay.Polygons.Add(poly);

                gMapControl1.Overlays.Add(polyOverlay);
            }
        }
Exemplo n.º 25
0
        private void drawBeats(string beatNumber)
        {
            GMapOverlay   polyOverlay = new GMapOverlay("beats");
            List <string> beats       = new List <string>();

            foreach (esriBeat b in EsriBeats.beatPolygons)
            {
                if (!beats.Contains(b.BeatID) && b.BeatID != "NO BEAT ID")
                {
                    beats.Add(b.BeatID);
                }
            }

            List <PointLatLng> points = new List <PointLatLng>();
            var bList = from b in EsriBeats.beatPolygons
                        where b.BeatID == beatNumber
                        select b;

            foreach (esriBeat eb in bList)
            {
                ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)eb.beatData.Geometry;
                foreach (PointCollection pc in p.Rings)
                {
                    for (int i = 0; i < pc.Count; i++)
                    {
                        points.Add(new PointLatLng(pc[i].Y, pc[i].X));
                    }
                    points.Add(new PointLatLng(pc[0].Y, pc[0].X));
                }
                GMapPolygon poly = new GMapPolygon(points, "Beat " + beatNumber);
                poly.Fill   = new SolidBrush(Color.FromArgb(50, Color.Blue));
                poly.Stroke = new Pen(Color.Red, 1);
                polyOverlay.Polygons.Add(poly);

                gMapControl1.Overlays.Add(polyOverlay);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 鼠标单击,开始测量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gmapControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (isFinish == true)
                {
                    ReleaseCommond();
                    return;
                }

                string name   = string.Format("point_{0}", pointIndex);
                var    lngLat = gmapControl.FromLocalToLatLng(e.X, e.Y);

                if (pointIndex == 0)   // 第一个点生成面
                {
                    //加点
                    marker = new EditMarker(lngLat);
                    gmapOverlay.Markers.Add(marker);
                    //多边形
                    pointList.Add(lngLat);
                    gmapPolygon = new GMapPolygon(pointList, PolygonName);
                    gmapOverlay.Polygons.Add(gmapPolygon);
                    gmapControl.UpdatePolygonLocalPosition(gmapPolygon);
                    pointIndex++;
                }
                else//面对象生成以后添加面的点
                {
                    pointIndex++;

                    marker = new EditMarker(lngLat);
                    gmapOverlay.Markers.Add(marker);
                    pointList.Add(lngLat);
                    gmapPolygon.Points.Add(lngLat);
                    gmapControl.UpdatePolygonLocalPosition(gmapPolygon);
                }
            }
        }
Exemplo n.º 27
0
        private void CreateCircle(Double lat, Double lon, double Radious, string caption)
        {
            var point    = new PointLatLng(lat, lon);
            var segments = 2 * Math.PI;

            var polygonPoints = new List <PointLatLng>();

            for (double i = 0; i < segments; i += 0.1)
            {
                polygonPoints.Add(FindPointAtDistanceFrom(point, i, Radious / 1000));
            }

            var fakeRoute = new GMapRoute(polygonPoints, "fake");

            fakeRoute.Tag    = new Place(caption);
            fakeRoute.Stroke = new System.Drawing.Pen(System.Drawing.Color.Transparent);
            var gpol = new GMapPolygon(polygonPoints, "circle");

            gpol.Stroke = new System.Drawing.Pen(System.Drawing.Color.Orchid);
            var overlay = new GMapOverlay(StandardOverlayName);

            _gmapControl.Overlays.Add(overlay);
            overlay.Markers.Add(
                new GMarkerGoogle(new PointLatLng(lat, lon), GMarkerGoogleType.yellow_pushpin)
            {
                ToolTipMode = MarkerTooltipMode.Always,
                ToolTipText = caption,
                ToolTip     =
                {
                    Font = new Font("Calibri", 9)
                },
                Tag = new Place(caption)
            }
                );
            overlay.Routes.Add(fakeRoute);
            overlay.Polygons.Add(gpol);
        }
Exemplo n.º 28
0
        public void gMapControl2_MouseClick(object sender, MouseEventArgs e)
        {
            if (sayac <= 1)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    double lat = gMapControl2.FromLocalToLatLng(e.X, e.Y).Lat;
                    double lng = gMapControl2.FromLocalToLatLng(e.X, e.Y).Lng;
                    koseler.Add(new PointLatLng(lat, lng));
                    array[sayac, 0] = lat.ToString();
                    array[sayac, 1] = lng.ToString();

                    sayac++;
                }
            }

            if (sayac == 2)
            {
                koseler.Add(new PointLatLng(ConvertToDouble(array[0, 0]), ConvertToDouble(array[1, 1])));
                koseler.Add(new PointLatLng(ConvertToDouble(array[1, 0]), ConvertToDouble(array[0, 1])));
                List <PointLatLng> koseler1 = new List <PointLatLng>();
                koseler1.Add(new PointLatLng(ConvertToDouble(array[0, 0]), ConvertToDouble(array[0, 1])));
                koseler1.Add(new PointLatLng(ConvertToDouble(array[1, 0]), ConvertToDouble(array[0, 1])));
                koseler1.Add(new PointLatLng(ConvertToDouble(array[1, 0]), ConvertToDouble(array[1, 1])));
                koseler1.Add(new PointLatLng(ConvertToDouble(array[0, 0]), ConvertToDouble(array[1, 1])));


                GMapOverlay polyOverlay = new GMapOverlay("polygon");
                GMapPolygon polygon     = new GMapPolygon(koseler1, "mypolygon");

                polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
                polygon.Stroke = new Pen(Color.Red, 1);
                polyOverlay.Polygons.Add(polygon);
                gMapControl2.Overlays.Add(polyOverlay);
                sayac++;
            }
        }
Exemplo n.º 29
0
        public void CheckChangedPosition(GMapMarker marker)
        {
            var previewOverlay = main.GetOverlay("previewOverlay");

            for (int i = 0; i < markerList.Count; i++)
            {
                if ((GMarkerGoogle)markerList[i] == marker)
                {
                    var temp = cacheList[i];
                    temp.Lat     = marker.Position.Lat;
                    temp.Lng     = marker.Position.Lng;
                    cacheList[i] = temp;
                    var polygon = new GMapPolygon(cacheList, "polygon");
                    previewOverlay.Polygons.Clear();
                    previewOverlay.Polygons.Add(polygon);
                    lbPoints.Items.Clear();
                    foreach (var j in cacheList)
                    {
                        this.SetListBox(j);
                    }
                    count = 1;
                }
            }
        }
Exemplo n.º 30
0
        private IList <Order> GetSelectedOrders()
        {
            List <Order> orders = new List <Order>();

            //Добавление заказов из кликов по маркеру
            orders.AddRange(selectedMarkers.Select(m => m.Tag).OfType <Order>().ToList());
            //Добавление заказов из квадратного выделения
            orders.AddRange(addressesOverlay.Markers
                            .Where(m => gmapWidget.SelectedArea.Contains(m.Position))
                            .Select(x => x.Tag).OfType <Order>().ToList());
            //Добавление закзаов через непрямоугольную область
            GMapOverlay overlay  = gmapWidget.Overlays.FirstOrDefault(o => o.Id.Contains(selectionOverlay.Id));
            GMapPolygon polygons = overlay?.Polygons.FirstOrDefault(p => p.Name.ToLower().Contains("выделение"));

            if (polygons != null)
            {
                var temp = addressesOverlay.Markers
                           .Where(m => polygons.IsInside(m.Position))
                           .Select(x => x.Tag).OfType <Order>().ToList();
                orders.AddRange(temp);
            }

            return(orders);
        }
 public static GMapPolygon GetRegionPolygon(string name, string rings)
 {
     if (string.IsNullOrEmpty(rings))
     {
         return(null);
     }
     else
     {
         List <PointLatLng> pointList  = new List <PointLatLng>();
         string[]           pairPoints = rings.Split(',');
         foreach (var points in pairPoints)
         {
             string[] point = points.Split(' ');
             if (point.Length == 2)
             {
                 PointLatLng p = new PointLatLng(double.Parse(point[1]), double.Parse(point[0]));
                 pointList.Add(p);
             }
         }
         GMapPolygon polygon = new GMapPolygon(pointList, name);
         polygon.Fill = new SolidBrush(Color.FromArgb(0, Color.White));
         return(polygon);
     }
 }
Exemplo n.º 32
0
        private void btnPolygono_Click(object sender, EventArgs e)
        {
            GMapOverlay        Polygono = new GMapOverlay("Poligono");
            List <PointLatLng> puntos   = new List <PointLatLng>();

            //variables para almacenar los datos.
            double lng, lat;

            //Agarramos los datos del grid
            for (int filas = 0; filas < dtgListaUbicacion.Rows.Count; filas++)
            {
                lat = Convert.ToDouble(dtgListaUbicacion.Rows[filas].Cells[1].Value);
                lng = Convert.ToDouble(dtgListaUbicacion.Rows[filas].Cells[2].Value);
                puntos.Add(new PointLatLng(lat, lng));
            }
            GMapPolygon PolygonoPuntos = new GMapPolygon(puntos, "Poligono");

            Polygono.Polygons.Add(PolygonoPuntos);
            gmapControl1.Overlays.Add(Polygono);

            //Actualizar el mapa
            gmapControl1.Zoom = gmapControl1.Zoom + 1;
            gmapControl1.Zoom = gmapControl1.Zoom - 1;
        }
Exemplo n.º 33
0
        private void Control_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }

            if (item.Overlay.Control.IsDragging)
            {
                return;
            }

            if (_mapControl.Overlays.First(x => x.Polygons.Any(i => i.Name == item.Name)) != null)
            {
                if (item.Tag is Feature)
                {
                    var prop = ((Feature)item.Tag).Properties;

                    var st = String.Format("{0} is categorised as {1}", prop["name"], prop["detailedCategory"]);

                    CustomMessageBox.Show(st, "Info", MessageBoxButtons.OK);
                }
            }
        }
Exemplo n.º 34
0
 public void paintSector3()
 {
     if (Sector3.Checked == true)
     {
         markerOverlay3 = new GMapOverlay("Poligon");
         List <PointLatLng> points = new List <PointLatLng>();
         PointLatLng        p1     = new PointLatLng(3.448809, -76.514622);
         PointLatLng        p2     = new PointLatLng(3.41145, -76.51855);
         PointLatLng        p3     = new PointLatLng(3.42927, -76.49795);
         PointLatLng        p4     = new PointLatLng(3.44344, -76.49409);
         points.Add(p1);
         points.Add(p2);
         points.Add(p3);
         points.Add(p4);
         poligonos3 = new GMapPolygon(points, "Poligono");
         markerOverlay3.Polygons.Add(poligonos3);
         gMapControl1.Overlays.Add(markerOverlay3);
         refreshMap();
     }
     else
     {
         markerOverlay3.Clear();
     }
 }
Exemplo n.º 35
0
        private void Demo_Load(object sender, EventArgs e)
        {
            gmap.MapProvider             = GMap.NET.MapProviders.GoogleMapProvider.Instance;
            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            // gmap.SetPositionByKeywords("Mexico  Distrito Federal");



            GMapOverlay   markersOverlay = new GMapOverlay("markers");
            GMarkerGoogle marker         = new GMarkerGoogle(new PointLatLng(-25.969562, 32.585789), GMarkerGoogleType.green);

            markersOverlay.Markers.Add(marker);
            gmap.Overlays.Add(markersOverlay);



            GMapOverlay        polyOverlay = new GMapOverlay("polygons");
            List <PointLatLng> points      = new List <PointLatLng>();

            points.Add(new PointLatLng(-25.969562, 32.585789));
            points.Add(new PointLatLng(-25.966205, 32.588171));
            points.Add(new PointLatLng(-25.968134, 32.591647));
            points.Add(new PointLatLng(-25.971684, 32.589759));

            GMapPolygon polygon = new GMapPolygon(points, "mypolygon");



            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gmap.Overlays.Add(polyOverlay);


            gmap.Position = new PointLatLng(-25.969562, 32.585789);
        }
Exemplo n.º 36
0
        private void Area_Click(object sender, EventArgs e)
        {
            GMapOverlay polyOverlay = new GMapOverlay("Мак");



            List <PointLatLng> points = new List <PointLatLng>();
            CPoint             point1 = new CPoint(47.219538, 38.919806);
            CPoint             point2 = new CPoint(47.219350, 38.919666);
            CPoint             point3 = new CPoint(47.219283, 38.919865);
            CPoint             point4 = new CPoint(47.219473, 38.920003);

            points.Add(new PointLatLng(point1.x, point1.y)); // левый вверх
            points.Add(new PointLatLng(point2.x, point2.y)); // левый низ
            points.Add(new PointLatLng(point3.x, point3.y)); // правый низ
            points.Add(new PointLatLng(point4.x, point4.y)); // правый вверх

            GMapPolygon polygon = new GMapPolygon(points, "МакДональдс");

            polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
            polygon.Stroke = new Pen(Color.Red, 1);
            polyOverlay.Polygons.Add(polygon);
            gmap.Overlays.Add(polyOverlay);
        }
        public GMapPolygon CreatePolygon(string name, List <PointLatLng> points, int property)
        {
            AdjustPoints(points);
            GMapPolygon polygon = new GMapPolygon(points, name);

            polygon.Fill   = new SolidBrush(Color.FromArgb(30, Color.DarkGray));
            polygon.Stroke = new Pen(Color.Red, 2);
            if (property == 1)
            {
                polygon.Stroke.DashStyle = DashStyle.Dot;
            }
            polygon.IsHitTestVisible = true;

            Bitmap      pic    = (Bitmap)Image.FromFile("Img/point/em.png");
            PointLatLng center = GetZoneCenter(points);
            mainForm    main   = mainForm.GetInstance();
            GMapControl map    = main.GetmainMap();
            double      zoom   = map.Zoom;
            double      pr     = ((zoom - 5) * 10) / 100;

            if (pr == 0)
            {
                pr = 1;
            }
            var labelMarker = new GmapMarkerWithLabel(center, name, pic, (int)(20 * pr));

            labelMarker.Offset = new System.Drawing.Point(((-labelMarker.Size.Width / 2) + 25), (-labelMarker.Size.Height / 2));

            GMapOverlay overlay = Main.GetOverlay("polygons");

            overlay.Polygons.Add(polygon);
            overlay.Markers.Add(labelMarker);

            polygon.Tag = labelMarker;
            return(polygon);
        }
Exemplo n.º 38
0
 public void paintSector8()
 {
     if (Sector8.Checked == true)
     {
         markerOverlay8 = new GMapOverlay("Poligon");
         List <PointLatLng> points = new List <PointLatLng>();
         PointLatLng        p1     = new PointLatLng(3.467794, -76.512240);
         PointLatLng        p2     = new PointLatLng(3.41145, -76.51855);
         PointLatLng        p3     = new PointLatLng(3.40974, -76.5491);
         PointLatLng        p4     = new PointLatLng(3.447095, -76.546208);
         points.Add(p1);
         points.Add(p2);
         points.Add(p3);
         points.Add(p4);
         poligonos8 = new GMapPolygon(points, "Poligono");
         markerOverlay8.Polygons.Add(poligonos8);
         gMapControl1.Overlays.Add(markerOverlay8);
         refreshMap();
     }
     else
     {
         markerOverlay8.Clear();
     }
 }
        private void drawCircle(PointLatLng p, double coverRange)
        {
            List <PointLatLng> points = new List <PointLatLng>();
            double             pNum   = 30;
            double             seg    = Math.PI * 2 / pNum;

            stationOverlay.Polygons.Clear();
            eventMap.Overlays.Clear();

            for (int i = 0; i < pNum; i++)
            {
                double theta = seg * i;
                double y     = p.Lat + Math.Cos(theta) / 0.030828 / 60 / 60 * coverRange;
                double x     = p.Lng + Math.Sin(theta) / 0.024697 / 60 / 60 * coverRange;

                points.Add(new PointLatLng(y, x));
            }

            GMapPolygon gpol = new GMapPolygon(points, "pol");

            gpol.Fill   = new SolidBrush(Color.FromArgb(20, Color.Cyan));
            gpol.Stroke = new Pen(Color.DarkCyan, (float)0.5);
            stationOverlay.Polygons.Add(gpol);
        }
Exemplo n.º 40
0
        // Do Work
        private void domainUpDown1_ValueChanged(object sender, EventArgs e)
        {
            if (CMB_camera.Text != "" && sender != NUM_Distance)
                doCalc();

            // new grid system test

            grid = Grid.CreateGrid(list, CurrentState.fromDistDisplayUnit((double)NUM_altitude.Value), (double)NUM_Distance.Value, (double)NUM_spacing.Value, (double)NUM_angle.Value, (double)NUM_overshoot.Value, (double)NUM_overshoot2.Value, (Grid.StartPosition)Enum.Parse(typeof(Grid.StartPosition), CMB_startfrom.Text), false, (float)NUM_Lane_Dist.Value, (float)NUM_leadin.Value);

            List<PointLatLng> list2 = new List<PointLatLng>();

            grid.ForEach(x => { list2.Add(x); });

            map.HoldInvalidation = true;

            routesOverlay.Routes.Clear();
            routesOverlay.Polygons.Clear();
            routesOverlay.Markers.Clear();

            if (grid.Count == 0)
            {
                return;
            }

            if (CHK_boundary.Checked)
                AddDrawPolygon();

            int strips = 0;
            int images = 0;
            int a = 1;
            PointLatLngAlt prevpoint = grid[0];
            float routetotal = 0;
            List<PointLatLng> segment = new List<PointLatLng>();

            foreach (var item in grid)
            {
                if (item.Tag == "M")
                {
                    images++;

                    if (CHK_internals.Checked)
                    {
                        routesOverlay.Markers.Add(new GMarkerGoogle(item, GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver });
                        a++;

                        segment.Add(prevpoint);
                        segment.Add(item);
                        prevpoint = item;
                    }
                    try
                    {
                        if (TXT_fovH.Text != "")
                        {
                            double fovh = double.Parse(TXT_fovH.Text);
                            double fovv = double.Parse(TXT_fovV.Text);

                            double startangle = 0;

                            if (!CHK_camdirection.Checked)
                            {
                                startangle = 90;
                            }

                            double angle1 = startangle - (Math.Tan((fovv / 2.0) / (fovh / 2.0)) * rad2deg);
                            double dist1 = Math.Sqrt(Math.Pow(fovh / 2.0, 2) + Math.Pow(fovv / 2.0, 2));

                            double bearing = (double)NUM_angle.Value;// (prevpoint.GetBearing(item) + 360.0) % 360;

                            List<PointLatLng> footprint = new List<PointLatLng>();
                            footprint.Add(item.newpos(bearing + angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 - angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 + angle1, dist1));
                            footprint.Add(item.newpos(bearing - angle1, dist1));

                            GMapPolygon poly = new GMapPolygon(footprint, a.ToString());
                            poly.Stroke = new Pen(Color.FromArgb(250 - ((a * 5) % 240), 250 - ((a * 3) % 240), 250 - ((a * 9) % 240)), 1);
                            poly.Fill = new SolidBrush(Color.FromArgb(40, Color.Purple));
                            if (CHK_footprints.Checked)
                                routesOverlay.Polygons.Add(poly);
                        }
                    }
                    catch { }
                }
                else
                {
                    strips++;
                    if (CHK_markers.Checked)
                    {
                        var marker = new GMapMarkerWP(item, a.ToString()) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver };
                        routesOverlay.Markers.Add(marker);
                    }

                    segment.Add(prevpoint);
                    segment.Add(item);
                    prevpoint = item;
                    a++;
                }
                GMapRoute seg = new GMapRoute(segment, "segment" + a.ToString());
                seg.Stroke = new Pen(Color.Yellow, 4);
                seg.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
                seg.IsHitTestVisible = true;
                if (CHK_grid.Checked)
                    routesOverlay.Routes.Add(seg);
                routetotal = routetotal + (float)seg.Distance;
                segment.Clear();
            }

            /*      Old way of drawing route, incase something breaks using segments
            GMapRoute wproute = new GMapRoute(list2, "GridRoute");
            wproute.Stroke = new Pen(Color.Yellow, 4);
            if (chk_grid.Checked)
                routesOverlay.Routes.Add(wproute);
            */

            // turn radrad = tas^2 / (tan(angle) * G)
            float v_sq = (float)(((float)NUM_UpDownFlySpeed.Value / CurrentState.multiplierspeed) * ((float)NUM_UpDownFlySpeed.Value / CurrentState.multiplierspeed));
            float turnrad = (float)(v_sq / (float)(9.808f * Math.Tan(35 * deg2rad)));

            // Update Stats 
            if (DistUnits == "Feet")
            {
                // Area
                float area = (float)calcpolygonarea(list) * 10.7639f; // Calculate the area in square feet
                lbl_area.Text = area.ToString("#") + " ft^2";
                if (area < 21780f)
                {
                    lbl_area.Text = area.ToString("#") + " ft^2";
                }
                else
                {
                    area = area / 43560f;
                    if (area < 640f)
                    {
                        lbl_area.Text = area.ToString("0.##") + " acres";
                    }
                    else
                    {
                        area = area / 640f;
                        lbl_area.Text = area.ToString("0.##") + " miles^2";
                    }
                }

                // Distance
                float distance = routetotal * 3280.84f; // Calculate the distance in feet
                if (distance < 5280f)
                {
                    lbl_distance.Text = distance.ToString("#") + " ft";
                }
                else
                {
                    distance = distance / 5280f;
                    lbl_distance.Text = distance.ToString("0.##") + " miles";
                }

                lbl_spacing.Text = (NUM_spacing.Value * 3.2808399m).ToString("#") + " ft";
                lbl_grndres.Text = inchpixel;
                lbl_distbetweenlines.Text = (NUM_Distance.Value * 3.2808399m).ToString("0.##") + " ft";
                lbl_footprint.Text = feet_fovH + " x " + feet_fovV + " ft";
                lbl_turnrad.Text = (turnrad * 2 * 3.2808399).ToString("0") + " ft";
            }
            else
            {
                // Meters
                lbl_area.Text = calcpolygonarea(list).ToString("#") + " m^2";
                lbl_distance.Text = routetotal.ToString("0.##") + " km";
                lbl_spacing.Text = NUM_spacing.Value.ToString("#") + " m";
                lbl_grndres.Text = TXT_cmpixel.Text;
                lbl_distbetweenlines.Text = NUM_Distance.Value.ToString("0.##") + " m";
                lbl_footprint.Text = TXT_fovH.Text + " x " + TXT_fovV.Text + " m";
                lbl_turnrad.Text = (turnrad * 2).ToString("0") + " m";
            }

            double flyspeedms = CurrentState.fromSpeedDisplayUnit((double)NUM_UpDownFlySpeed.Value);

            lbl_pictures.Text = images.ToString();
            lbl_strips.Text = ((int)(strips / 2)).ToString();
            double seconds = ((routetotal * 1000.0) / ((flyspeedms) * 0.8));
            // reduce flying speed by 20 %
            lbl_flighttime.Text = secondsToNice(seconds);
            seconds = ((routetotal * 1000.0) / (flyspeedms));
            lbl_photoevery.Text = secondsToNice(((double)NUM_spacing.Value / flyspeedms));
            map.HoldInvalidation = false;
            if (!isMouseDown)
                map.ZoomAndCenterMarkers("routes");

            CalcHeadingHold();
        }
Exemplo n.º 41
0
        private void map_MouseMove(object sender, MouseEventArgs e)
        {
            var mousecurrent = map.FromLocalToLatLng(e.X, e.Y);

            if (mousedown)
            {
                mousedragging = true;

                if (currentmode == mode.panmode)
                {
                    if (e.Button == MouseButtons.Left)
                    {

                        double latdif = mousestart.Lat - mousecurrent.Lat;
                        double lngdif = mousestart.Lng - mousecurrent.Lng;

                        try
                        {
                            map.Position = new PointLatLng(map.Position.Lat + latdif, map.Position.Lng + lngdif);
                        }
                        catch { }
                    }
                }
                else if (currentmode == mode.drawbox)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        var rect = RectangleF.FromLTRB((float)mousestart.Lng, (float)mousestart.Lat, (float)mousecurrent.Lng, (float)mousecurrent.Lat);

                        list.Clear();

                        // tl
                        list.Add(mousestart);
                        // tr
                        list.Add(new PointLatLng(rect.Top, rect.Right));
                        // br
                        list.Add(mousecurrent);
                        // bl
                        list.Add(new PointLatLng(rect.Bottom, rect.Left));

                        if (boxpoly != null)
                            layerpolygons.Polygons.Remove(boxpoly);

                        boxpoly = null;

                        boxpoly = new GMapPolygon(list, "boxpoly");

                        boxpoly.IsHitTestVisible = true;
                        boxpoly.Stroke = new Pen(Color.Red, 2);
                        boxpoly.Fill = Brushes.Transparent;

                        layerpolygons.Polygons.Add(boxpoly);

                        map.Invalidate();
                    }
                }
                else if (currentmode == mode.movebox)
                {
                    //if (mouseinsidepoly)
                    {
                        double latdif = mousestart.Lat - mousecurrent.Lat;
                        double lngdif = mousestart.Lng - mousecurrent.Lng;

                        for (int a = 0; a < boxpoly.Points.Count; a++)
                        {
                            boxpoly.Points[a] = new PointLatLng(boxpoly.Points[a].Lat - latdif, boxpoly.Points[a].Lng - lngdif);
                        }

                        UpdateListFromBox();

                        map.UpdatePolygonLocalPosition(boxpoly);
                        map.Invalidate();

                        mousestart = mousecurrent;
                    }
                }
                else if (currentmode == mode.editbox)
                {
                    double latdif = mousestart.Lat - mousecurrent.Lat;
                    double lngdif = mousestart.Lng - mousecurrent.Lng;

                    // 2 point the create the lowest crosstrack distance
                    // extend at 90 degrees to the bearing of the points based on mouse position

                    PointLatLngAlt p0;
                    PointLatLngAlt p1;

                    PointLatLngAlt bestp0 = PointLatLngAlt.Zero;
                    PointLatLngAlt bestp1 = PointLatLngAlt.Zero;
                    double bestcrosstrack = 9999999;
                    double R = 6371000;

                    for (int a = 0; a < boxpoly.Points.Count; a++)
                    {
                        p0 = boxpoly.Points[a];
                        p1 = boxpoly.Points[(a + 1) % (boxpoly.Points.Count)];

                        var distp0p1 = p0.GetDistance(mousecurrent);
                        var bearingp0curr = p0.GetBearing(mousecurrent);
                        var bearringp0p1 = p0.GetBearing(p1);

                        var ct = Math.Asin(Math.Sin(distp0p1 / R) * Math.Sin((bearingp0curr - bearringp0p1) * deg2rad)) * R;

                        if (Math.Abs(ct) < Math.Abs(bestcrosstrack))
                        {
                            bestp0 = p0;
                            bestp1 = p1;
                            bestcrosstrack = ct;
                        }
                    }

                    var bearing = bestp0.GetBearing(bestp1);

                    layerpolygons.Markers.Clear();
                    layerpolygons.Markers.Add(new GMarkerGoogle(bestp0, GMarkerGoogleType.blue));
                    layerpolygons.Markers.Add(new GMarkerGoogle(bestp1, GMarkerGoogleType.blue));

                    bearing = ((PointLatLngAlt)mousestart).GetBearing(mousecurrent);

                    var newposp0 = bestp0.newpos(bearing, Math.Abs(bestcrosstrack));
                    var newposp1 = bestp1.newpos(bearing, Math.Abs(bestcrosstrack));

                    boxpoly.Points[boxpoly.Points.IndexOf(bestp0)] = newposp0;
                    boxpoly.Points[boxpoly.Points.IndexOf(bestp1)] = newposp1;

                    UpdateListFromBox();

                    map.UpdatePolygonLocalPosition(boxpoly);
                    map.Invalidate();

                    mousestart = mousecurrent;
                }
            }

            mousedragging = false;
        }
Exemplo n.º 42
0
      /// <summary>
      /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
      /// </summary>
      /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
      /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
      /// <exception cref="T:System.Security.SecurityException">
      /// The caller does not have the required permission.
      /// </exception>
      public void GetObjectData(SerializationInfo info, StreamingContext context)
      {
         info.AddValue("Id", this.Id);
         info.AddValue("IsVisible", this.IsVisibile);

         GMapMarker[] markerArray = new GMapMarker[this.Markers.Count];
         this.Markers.CopyTo(markerArray, 0);
         info.AddValue("Markers", markerArray);

         GMapRoute[] routeArray = new GMapRoute[this.Routes.Count];
         this.Routes.CopyTo(routeArray, 0);
         info.AddValue("Routes", routeArray);

         GMapPolygon[] polygonArray = new GMapPolygon[this.Polygons.Count];
         this.Polygons.CopyTo(polygonArray, 0);
         info.AddValue("Polygons", polygonArray);
      }
Exemplo n.º 43
0
 private void map_OnPolygonLeave(GMapPolygon item)
 {
     mouseinsidepoly = false;
 }
Exemplo n.º 44
0
Arquivo: GCS.cs Projeto: kkouer/PcGcs
        private void gMapControl1_Load(object sender, EventArgs e)
        {
            quickadd = true;

            config(false);

            quickadd = false;

            POI.POIModified += POI_POIModified;

            if (MainV2.config["WMSserver"] != null)
                WMSProvider.CustomWMSURL = MainV2.config["WMSserver"].ToString();

            //// setup geofence
            List<PointLatLng> polygonPoints = new List<PointLatLng>();
            geofencepolygon = new GMapPolygon(polygonPoints, "geofence");
            geofencepolygon.Stroke = new Pen(Color.Pink, 5);
            geofencepolygon.Fill = Brushes.Transparent;

            //setup drawnpolgon
            List<PointLatLng> polygonPoints2 = new List<PointLatLng>();
            drawnpolygon = new GMapPolygon(polygonPoints2, "drawnpoly");
            drawnpolygon.Stroke = new Pen(Color.Red, 2);
            drawnpolygon.Fill = Brushes.Transparent;

            updateCMDParams();


            writeKML();

            timer1.Start();
        }
Exemplo n.º 45
0
        private void btnPolyEnd_Click(object sender, EventArgs e)
        {
            endPoly();
            //Geometry.ConvexHull(lPointsPoly);
            GMapPolygon poly = new GMapPolygon(lPointsPoly, "Poly");
            PolyOverlay.Clear();
            PolyOverlay.Polygons.Add(poly);

            GenerateSurvey();
        }
Exemplo n.º 46
0
        //http://www.chrobotics.com/library/understanding-euler-angles

        // x = north / roll
        // y = pitch / east
        // z = yaw / down

        public static List<PointLatLngAlt> calc(PointLatLngAlt plla, double R, double P, double Y, double hfov, double vfov)
        {
            // alt should be asl
            // P pitch where the center os pointing ie -80
            // R roll 

            GMapPolygon poly = new GMapPolygon(new List<PointLatLng>(), "rect");

            double frontangle = (P*0) + vfov/2;
            double backangle = (P*0) - vfov/2;
            double leftangle = (R*0) + hfov/2;
            double rightangle = (R*0) - hfov/2;

            var fovh = Math.Tan(hfov/2.0 * deg2rad)*2.0;
            var fovv = Math.Tan(vfov/2.0 * deg2rad)*2.0;

            //DoDebug();

            addtomap(plla, "plane");

            Matrix3 dcm = new Matrix3();

            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.normalize();

            Vector3 center1 = new Vector3(0, 0, 10000);

            var test = dcm * center1;

            var bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            var newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var cen = calcIntersection(plla, newpos2);

            var dist = plla.GetDistance(cen);

            addtomap(cen, "center "+ dist.ToString("0"));

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(rightangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = (Math.Atan2(test.y, test.x) * rad2deg);

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            //addtomap(newpos2, "tr2");

            var groundpointtr = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointtr);

            addtomap(groundpointtr, "tr");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x)*rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointtl = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointtl);

            addtomap(groundpointtl, "tl");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, backangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointbl = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointbl);

            addtomap(groundpointbl, "bl");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(rightangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, backangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointbr = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointbr);

            addtomap(groundpointbr, "br");

            //

            polygons.Polygons.Clear();
            polygons.Polygons.Add(poly);

            var ans = new List<PointLatLngAlt>();
            ans.Add(groundpointtl);
            ans.Add(groundpointtr);
            ans.Add(groundpointbr);
            ans.Add(groundpointbl);

            return ans;
        }
Exemplo n.º 47
0
        private void domainUpDown1_ValueChanged(object sender, EventArgs e)
        {
            if (CMB_camera.Text != "")
                doCalc();

            // new grid system test

            grid = Grid.CreateGrid(list, (double)NUM_altitude.Value, (double)NUM_Distance.Value, (double)NUM_spacing.Value, (double)NUM_angle.Value, (double)NUM_overshoot.Value, (double)NUM_overshoot2.Value, (Grid.StartPosition)Enum.Parse(typeof(Grid.StartPosition), CMB_startfrom.Text), false);

            List<PointLatLng> list2 = new List<PointLatLng>();

            grid.ForEach(x => { list2.Add(x); });

            map.HoldInvalidation = true;

            layerpolygons.Polygons.Clear();
            layerpolygons.Markers.Clear();

            if (grid.Count == 0)
            {
                return;
            }

            if (chk_boundary.Checked)
                AddDrawPolygon();

            int strips = 0;
            int images = 0;
            int a = 1;
            PointLatLngAlt prevpoint = grid[0];
            foreach (var item in grid)
            {
                if (item.Tag == "M")
                {
                    images++;

                    if (chk_internals.Checked)
                    {
                        layerpolygons.Markers.Add(new GMarkerGoogle(item,GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver });
                        a++;
                    }
                    try
                    {
                        if (TXT_fovH.Text != "")
                        {
                            double fovh = double.Parse(TXT_fovH.Text);
                            double fovv = double.Parse(TXT_fovV.Text);

                            double startangle = 0;

                            if (!CHK_camdirection.Checked)
                            {
                                startangle = 90;
                            }

                            double angle1 = startangle - (Math.Tan((fovv / 2.0) / (fovh / 2.0)) * rad2deg);
                            double dist1 = Math.Sqrt(Math.Pow(fovh / 2.0, 2) + Math.Pow(fovv / 2.0, 2));

                            double bearing = (double)NUM_angle.Value;// (prevpoint.GetBearing(item) + 360.0) % 360;

                            List<PointLatLng> footprint = new List<PointLatLng>();
                            footprint.Add(item.newpos(bearing + angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 - angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 + angle1, dist1));
                            footprint.Add(item.newpos(bearing - angle1, dist1));

                            GMapPolygon poly = new GMapPolygon(footprint, a.ToString());
                            poly.Stroke = new Pen(Color.FromArgb(250 - ((a * 5) % 240), 250 - ((a * 3) % 240), 250 - ((a * 9) % 240)), 1);
                            poly.Fill = new SolidBrush(Color.FromArgb(40, Color.Purple));
                            if (chk_footprints.Checked)
                                layerpolygons.Polygons.Add(poly);
                        }
                    }
                    catch { }
                }
                else
                {
                    strips++;
                    if (chk_markers.Checked)
                        layerpolygons.Markers.Add(new GMarkerGoogle(item,GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.Always });

                    a++;
                }
                prevpoint = item;
            }

            // add wp polygon
            wppoly = new GMapPolygon(list2, "Grid");
            wppoly.Stroke.Color = Color.Yellow;
            wppoly.Fill = Brushes.Transparent;
            wppoly.Stroke.Width = 4;
            if (chk_grid.Checked)
                layerpolygons.Polygons.Add(wppoly);

            Console.WriteLine("Poly Dist " + wppoly.Distance);

            if (DistUnits == "Feet")
            {
                float multiplierdist = 3.2808399f;
                lbl_area.Text = (calcpolygonarea(list) * (double)multiplierdist).ToString("#") + " ft^2";
                lbl_distance.Text = (wppoly.Distance * 0.621371).ToString("0.##") + " miles";
                lbl_spacing.Text = (NUM_spacing.Value * (decimal)multiplierdist).ToString("#") + " ft";
                lbl_grndres.Text = inchpixel;
                lbl_distbetweenlines.Text = (NUM_Distance.Value * (decimal)multiplierdist).ToString("0.##") + " ft";
                lbl_footprint.Text = feet_fovH + " x " + feet_fovV + " ft";
            }
            else
            {
                // Meters
                lbl_area.Text = calcpolygonarea(list).ToString("#") + " m^2";
                lbl_distance.Text = wppoly.Distance.ToString("0.##") + " km";
                lbl_spacing.Text = NUM_spacing.Value.ToString("#") + " m";
                lbl_grndres.Text = TXT_cmpixel.Text;
                lbl_distbetweenlines.Text = NUM_Distance.Value.ToString("0.##") + " m";
                lbl_footprint.Text = TXT_fovH.Text + " x " + TXT_fovV.Text + " m";
            }

            lbl_pictures.Text = images.ToString();
            lbl_strips.Text = ((int)(strips / 2)).ToString();
            double seconds = ((wppoly.Distance * 1000.0) / ((double)numericUpDownFlySpeed.Value * 0.8));
            // reduce flying speed by 20 %
            label28.Text = secondsToNice(seconds);
            seconds = ((wppoly.Distance * 1000.0) / ((double)numericUpDownFlySpeed.Value));
            label32.Text = secondsToNice(((double)NUM_spacing.Value / (double)numericUpDownFlySpeed.Value));
            map.HoldInvalidation = false;
            map.ZoomAndCenterMarkers("polygons");
        }
Exemplo n.º 48
0
Arquivo: GCS.cs Projeto: kkouer/PcGcs
        /// <summary>
        /// used to redraw the polygon
        /// </summary>
        void RegeneratePolygon()
        {
            List<PointLatLng> polygonPoints = new List<PointLatLng>();

            if (objectsoverlay == null)
                return;

            foreach (GMapMarker m in objectsoverlay.Markers)
            {
                if (m is GMapMarkerRect)
                {
                    if (m.Tag == null)
                    {
                        m.Tag = polygonPoints.Count;
                        polygonPoints.Add(m.Position);
                    }
                }
            }

            if (wppolygon == null)
            {
                wppolygon = new GMapPolygon(polygonPoints, "polygon test");
                polygonsoverlay.Polygons.Add(wppolygon);
            }
            else
            {
                wppolygon.Points.Clear();
                wppolygon.Points.AddRange(polygonPoints);

                wppolygon.Stroke = new Pen(Color.Yellow, 4);
                wppolygon.Stroke.DashStyle = DashStyle.Custom;
                wppolygon.Fill = Brushes.Transparent;

                if (polygonsoverlay.Polygons.Count == 0)
                {
                    polygonsoverlay.Polygons.Add(wppolygon);
                }
                else
                {
                    lock (thisLock)
                    {
                        gMapControl1.UpdatePolygonLocalPosition(wppolygon);
                    }
                }
            }
        }
Exemplo n.º 49
0
Arquivo: GCS.cs Projeto: kkouer/PcGcs
        void MainMap_MouseUp(object sender, MouseEventArgs e)
        {
            //在规划模式下生效
            if (isPlanMode)
            {
                if (isMouseClickOffMenu)
                {
                    isMouseClickOffMenu = false;
                    return;
                }
                MouseDownEnd = gMapControl1.FromLocalToLatLng(e.X, e.Y);

                if (e.Button == MouseButtons.Right)
                {
                    return;
                }
                if (isMouseDown)
                {
                    if (e.Button == MouseButtons.Left)
                        isMouseDown = false;

                    if (ModifierKeys == Keys.Control)
                    {
                        // group select wps
                        GMapPolygon poly = new GMapPolygon(new List<PointLatLng>(), "temp");

                        poly.Points.Add(MouseDownStart);
                        poly.Points.Add(new PointLatLng(MouseDownStart.Lat, MouseDownEnd.Lng));
                        poly.Points.Add(MouseDownEnd);
                        poly.Points.Add(new PointLatLng(MouseDownEnd.Lat, MouseDownStart.Lng));

                        foreach (var marker in objectsoverlay.Markers)
                        {
                            if (poly.IsInside(marker.Position))
                            {
                                try
                                {
                                    if (marker.Tag != null)
                                    {
                                        groupmarkeradd(marker);
                                    }
                                }
                                catch { }
                            }
                        }

                        isMouseDraging = false;
                        return;
                    }
                }
                if (!isMouseDraging)
                {
                    if (CurentRectMarker != null)
                    {

                    }
                    else
                    {
                        AddWPToMap(currentMarker.Position.Lat, currentMarker.Position.Lng, 0);
                    }
                }
                else
                {
                    if (groupmarkers.Count > 0)
                    {
                        Dictionary<string, PointLatLng> dest = new Dictionary<string, PointLatLng>();

                        foreach (var markerid in groupmarkers)
                        {
                            for (int a = 0; a < objectsoverlay.Markers.Count; a++)
                            {
                                var marker = objectsoverlay.Markers[a];

                                if (marker.Tag != null && marker.Tag.ToString() == markerid.ToString())
                                {
                                    dest[marker.Tag.ToString()] = marker.Position;
                                    break;
                                }
                            }
                        }

                        foreach (KeyValuePair<string, PointLatLng> item in dest)
                        {
                            var value = item.Value;
                            callMeDrag(item.Key, value.Lat, value.Lng, -1);
                        }

                        gMapControl1.SelectedArea = RectLatLng.Empty;
                        groupmarkers.Clear();
                        // redraw to remove selection
                        writeKML();

                        CurentRectMarker = null;
                    }
                    if (CurentRectMarker != null)
                    {
                        if (CurentRectMarker.InnerMarker.Tag.ToString().Contains("grid"))
                        {
                            try
                            {
                                drawnpolygon.Points[int.Parse(CurentRectMarker.InnerMarker.Tag.ToString().Replace("grid", "")) - 1] = new PointLatLng(MouseDownEnd.Lat, MouseDownEnd.Lng);
                                gMapControl1.UpdatePolygonLocalPosition(drawnpolygon);
                                gMapControl1.Invalidate();
                            }
                            catch { }
                        }
                        else
                        {
                            callMeDrag(CurentRectMarker.InnerMarker.Tag.ToString(), currentMarker.Position.Lat, currentMarker.Position.Lng, -1);
                        }
                        CurentRectMarker = null;
                    }
                }
            }
            isMouseDraging = false;
        }
Exemplo n.º 50
0
Arquivo: GCS.cs Projeto: kkouer/PcGcs
        private void measureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (startmeasure.IsEmpty)
            {
                startmeasure = MouseDownStart;
                polygonsoverlay.Markers.Add(new GMarkerGoogle(MouseDownStart, GMarkerGoogleType.red));
                gMapControl1.Invalidate();
                Common.MessageShowAgain("量尺工具", "量尺起点已经选定,再次点击量尺工具计算距离.");
            }
            else
            {
                List<PointLatLng> polygonPoints = new List<PointLatLng>();
                polygonPoints.Add(startmeasure);
                polygonPoints.Add(MouseDownStart);

                GMapPolygon line = new GMapPolygon(polygonPoints, "measure dist");
                line.Stroke.Color = Color.Green;

                polygonsoverlay.Polygons.Add(line);

                polygonsoverlay.Markers.Add(new GMarkerGoogle(MouseDownStart, GMarkerGoogleType.red));
                gMapControl1.Invalidate();
                CustomMessageBox.Show("距离: " + FormatDistance(gMapControl1.MapProvider.Projection.GetDistance(startmeasure, MouseDownStart), true) + " 方位角: " + (gMapControl1.MapProvider.Projection.GetBearing(startmeasure, MouseDownStart).ToString("0")));
                polygonsoverlay.Polygons.Remove(line);
                polygonsoverlay.Markers.Clear();
                startmeasure = new PointLatLng();
            }
        }
Exemplo n.º 51
0
        private void addPointToPoly(PointLatLng point)
        {
            lPointsPoly.Add(point);

            GMapPolygon poly = new GMapPolygon(lPointsPoly, "Poly");
            PolyOverlay.Clear();
            PolyOverlay.Polygons.Add(poly);
        }
Exemplo n.º 52
0
        void tfr_GotTFRs(object sender, EventArgs e)
        {
            Invoke((Action) delegate
            {
                foreach (var item in tfr.tfrs)
                {
                    List<List<PointLatLng>> points = item.GetPaths();

                    foreach (var list in points)
                    {
                        GMapPolygon poly = new GMapPolygon(list, item.NAME);

                        poly.Fill = new SolidBrush(Color.FromArgb(30, Color.Blue));

                        tfrpolygons.Polygons.Add(poly);
                    }
                }
                tfrpolygons.IsVisibile = MainV2.ShowTFR;
            });
        }
Exemplo n.º 53
0
        private void domainUpDown1_ValueChanged(object sender, EventArgs e)
        {
            if (CMB_camera.Text != "")
                doCalc();

            // new grid system test
            if (boxpoly == null || boxpoly.Points == null || boxpoly.Points.Count == 0)
                return;

            var newlist = new List<PointLatLngAlt>();

            boxpoly.Points.ForEach(x => { newlist.Add(x); });

            grid = Grid.CreateGrid(newlist, (double)NUM_altitude.Value, (double)NUM_Distance, (double)NUM_spacing, (double)NUM_angle.Value, 0, 0, Grid.StartPosition.Home, false, 0);

            List<PointLatLng> list2 = new List<PointLatLng>();

            grid.ForEach(x => { list2.Add(x); });

            map.HoldInvalidation = true;

            layerpolygons.Polygons.Clear();
            layerpolygons.Markers.Clear();

            layerpolygons.Polygons.Add(boxpoly);

            if (grid.Count == 0)
            {
                return;
            }

           // if (chk_boundary.Checked)
          //      AddDrawPolygon();

            int strips = 0;
            int images = 0;
            int a = 1;
            PointLatLngAlt prevpoint = grid[0];
            foreach (var item in grid)
            {
                if (item.Tag == "M")
                {
                    images++;

                    if (chk_internals.Checked)
                    {
                        layerpolygons.Markers.Add(new GMarkerGoogle(item, GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver });
                        a++;
                    }
                    try
                    {
                        if (TXT_fovH != "")
                        {
                            double fovh = double.Parse(TXT_fovH);
                            double fovv = double.Parse(TXT_fovV);

                            double startangle = 0;

                            if (!RAD_camdirectionland.Checked)
                            {
                                startangle = 90;
                            }

                            double angle1 = startangle - (Math.Tan((fovv / 2.0) / (fovh / 2.0)) * rad2deg);
                            double dist1 = Math.Sqrt(Math.Pow(fovh / 2.0, 2) + Math.Pow(fovv / 2.0, 2));

                            double bearing = (double)NUM_angle.Value;// (prevpoint.GetBearing(item) + 360.0) % 360;

                            List<PointLatLng> footprint = new List<PointLatLng>();
                            footprint.Add(item.newpos(bearing + angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 - angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 + angle1, dist1));
                            footprint.Add(item.newpos(bearing - angle1, dist1));

                            GMapPolygon poly = new GMapPolygon(footprint, a.ToString());
                            poly.Stroke.Color = Color.FromArgb(250 - ((a * 5) % 240), 250 - ((a * 3) % 240), 250 - ((a * 9) % 240));
                            poly.Stroke.Width = 1;
                            poly.Fill = new SolidBrush(Color.FromArgb(40, Color.Purple));
                            if (chk_footprints.Checked)
                                layerpolygons.Polygons.Add(poly);
                        }
                    }
                    catch { }
                }
                else
                {
                    strips++;
                    if (chk_markers.Checked)
                        layerpolygons.Markers.Add(new GMarkerGoogle(item, GMarkerGoogleType.green) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.Always });

                    a++;
                }
                prevpoint = item;
            }

            // add wp polygon
            wppoly = new GMapPolygon(list2, "Grid");
            wppoly.Stroke.Color = Color.Yellow;
            wppoly.Fill = Brushes.Transparent;
            wppoly.Stroke.Width = 4;
            if (chk_grid.Checked)
                layerpolygons.Polygons.Add(wppoly);

            Console.WriteLine("Poly Dist " + wppoly.Distance);

            quickViewarea.number = calcpolygonarea(list) / (1000.0 * 1000.0);

            lbl_distance.Text = wppoly.Distance.ToString("0.##") + " km";

            lbl_spacing.Text = NUM_spacing.ToString("#") + " m";

            quickViewgroundres.number = TXT_cmpixel;

            quickViewimagecount.number = images;

            lbl_strips.Text = ((int)(strips / 2)).ToString();
            lbl_distbetweenlines.Text = NUM_Distance.ToString("0.##") + " m";

            lbl_footprint.Text = TXT_fovH + " x " + TXT_fovV + " m";

            double seconds = ((wppoly.Distance * 1000.0) / ((double)numericUpDownFlySpeed.Value * 0.8));
            // reduce flying speed by 20 %
            label28.Text = secondsToNice(seconds);

            quickViewflighttime.number = seconds / 60.0;

            seconds = ((wppoly.Distance * 1000.0) / ((double)numericUpDownFlySpeed.Value));

            label32.Text = secondsToNice(((double)NUM_spacing / (double)numericUpDownFlySpeed.Value));

            map.HoldInvalidation = false;

            map.ZoomAndCenterMarkers("polygons");

        }
Exemplo n.º 54
0
        //http://www.chrobotics.com/library/understanding-euler-angles

        // x = north / roll
        // y = pitch / east
        // z = yaw / down

        public static List<PointLatLngAlt> calc(PointLatLngAlt plla, double R, double P, double Y, double hfov, double vfov)
        {
            // alt should be asl
            // P pitch where the center os pointing ie -80
            // R roll 

            // if roll and pitch is 0, use the quick method.
            if (R == 0 && P == 0)
            {
                // calc fov in m on the ground at 0 alt
                var fovh = Math.Tan(hfov / 2.0 * deg2rad) * plla.Alt;
                var fovv = Math.Tan(vfov / 2.0 * deg2rad) * plla.Alt;
                var fovd = Math.Sqrt(fovh * fovh + fovv * fovv);

                // where we put our footprint
                var ans2 = new List<PointLatLngAlt>();

                // calc bearing from center to corner
                var bearing1 = Math.Atan2(fovh, fovv) * rad2deg;

                // calc first corner point
                var newpos1 = plla.newpos(bearing1 + Y, Math.Sqrt(fovh * fovh + fovv * fovv));
                // set alt to 0, as we used the hypot for distance and fov is based on 0 alt
                newpos1.Alt = 0;
                // calc intersection from center to new point and return ground hit point
                var cen1 = calcIntersection(plla, newpos1);
                // add to our footprint poly
                ans2.Add(cen1);
                addtomap(cen1, "cen1");

                //repeat

                newpos1 = plla.newpos(Y - bearing1, Math.Sqrt(fovh * fovh + fovv * fovv));
                newpos1.Alt = 0;
                cen1 = calcIntersection(plla, newpos1);
                ans2.Add(cen1);
                addtomap(cen1, "cen2");

                newpos1 = plla.newpos(bearing1 + Y - 180, Math.Sqrt(fovh * fovh + fovv * fovv));
                newpos1.Alt = 0;
                cen1 = calcIntersection(plla, newpos1);
                ans2.Add(cen1);
                addtomap(cen1, "cen3");

                newpos1 = plla.newpos(Y - bearing1 - 180, Math.Sqrt(fovh * fovh + fovv * fovv));
                newpos1.Alt = 0;
                cen1 = calcIntersection(plla, newpos1);
                ans2.Add(cen1);
                addtomap(cen1, "cen4");


                addtomap(plla, "plane");

                return ans2;
            }

            
            GMapPolygon poly = new GMapPolygon(new List<PointLatLng>(), "rect");

            double frontangle = (P*0) + vfov/2;
            double backangle = (P*0) - vfov/2;
            double leftangle = (R*0) + hfov/2;
            double rightangle = (R*0) - hfov/2;


            addtomap(plla, "plane");

            Matrix3 dcm = new Matrix3();

            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.normalize();

            Vector3 center1 = new Vector3(0, 0, 10000);

            var test = dcm * center1;

            var bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            var newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var cen = calcIntersection(plla, newpos2);

            var dist = plla.GetDistance(cen);

            addtomap(cen, "center "+ dist.ToString("0"));

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(rightangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
            dcm.normalize();
            /*
            var mx = new Matrix3();
            var my = new Matrix3();
            var mz = new Matrix3();

            mx.from_euler((rightangle + R) * deg2rad, 0, 0);
            my.from_euler(0, (frontangle + P) * deg2rad, 0);
            mz.from_euler(0, 0, Y * deg2rad);

            printdcm(mx);
            printdcm(my);
            printdcm(mz);
            printdcm(my * mx);
            printdcm(mz * my * mx);

            test = mz * my * mx * center1;
            */
            test = dcm * center1;  
              
            bearing2 = (Math.Atan2(test.y, test.x) * rad2deg);

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            //addtomap(newpos2, "tr2");

            var groundpointtr = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointtr);

            addtomap(groundpointtr, "tr");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, frontangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x)*rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointtl = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointtl);

            addtomap(groundpointtl, "tl");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(leftangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, backangle * deg2rad, 0));
            dcm.normalize();

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointbl = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointbl);

            addtomap(groundpointbl, "bl");

            //
            dcm.from_euler(R * deg2rad, P * deg2rad, Y * deg2rad);
            dcm.rotate(new Vector3(rightangle * deg2rad, 0, 0));
            dcm.normalize();
            dcm.rotate(new Vector3(0, backangle * deg2rad, 0));
            dcm.normalize(); 

            test = dcm * center1;

            bearing2 = Math.Atan2(test.y, test.x) * rad2deg;

            newpos2 = plla.newpos(bearing2, Math.Sqrt(test.x * test.x + test.y * test.y));

            newpos2.Alt -= test.z;

            var groundpointbr = calcIntersection(plla, newpos2);

            poly.Points.Add(groundpointbr);

            addtomap(groundpointbr, "br");

            //

            polygons.Polygons.Clear();
            polygons.Polygons.Add(poly);

            var ans = new List<PointLatLngAlt>();
            ans.Add(groundpointtl);
            ans.Add(groundpointtr);
            ans.Add(groundpointbr);
            ans.Add(groundpointbl);

            return ans;
        }
Exemplo n.º 55
0
        /// <summary>
        /// used to redraw the polygon
        /// </summary>
        void RegeneratePolygon()
        {
            List<PointLatLng> polygonPoints = new List<PointLatLng>();

            if (routes == null)
                return;

            foreach (GMapMarker m in polygons.Markers)
            {
                if (m is GMapMarkerRect)
                {
                    m.Tag = polygonPoints.Count;
                    polygonPoints.Add(m.Position);
                }
            }

            if (polygon == null)
            {
                polygon = new GMapPolygon(polygonPoints, "polygon test");
                polygons.Polygons.Add(polygon);
            }
            else
            {
                polygon.Points.Clear();
                polygon.Points.AddRange(polygonPoints);

                polygon.Stroke = new Pen(Color.Yellow, 4);

                if (polygons.Polygons.Count == 0)
                {
                    polygons.Polygons.Add(polygon);
                }
                else
                {
                    gMapControl1.UpdatePolygonLocalPosition(polygon);
                }
            }
        }
Exemplo n.º 56
0
        private void map_OnPolygonClick(GMapPolygon item, MouseEventArgs e)
        {

        }
Exemplo n.º 57
0
        private static void processKML(SharpKml.Dom.Element Element)
        {
            try
            {
                //  log.Info(Element.ToString() + " " + Element.Parent);
            }
            catch
            {
            }

            SharpKml.Dom.Document doc = Element as SharpKml.Dom.Document;
            SharpKml.Dom.Placemark pm = Element as SharpKml.Dom.Placemark;
            SharpKml.Dom.Folder folder = Element as SharpKml.Dom.Folder;
            SharpKml.Dom.Polygon polygon = Element as SharpKml.Dom.Polygon;
            SharpKml.Dom.LineString ls = Element as SharpKml.Dom.LineString;

            if (doc != null)
            {
                foreach (var feat in doc.Features)
                {
                    //Console.WriteLine("feat " + feat.GetType());
                    //processKML((Element)feat);
                }
            }
            else if (folder != null)
            {
                foreach (SharpKml.Dom.Feature feat in folder.Features)
                {
                    //Console.WriteLine("feat "+feat.GetType());
                    //processKML(feat);
                }
            }
            else if (pm != null)
            {
            }
            else if (polygon != null)
            {
                GMapPolygon kmlpolygon = new GMapPolygon(new List<PointLatLng>(), "kmlpolygon");

                kmlpolygon.Stroke.Color = Color.Purple;

                kmlpolygon.Fill = new SolidBrush(Color.FromArgb(30, Color.Blue));

                foreach (var loc in polygon.OuterBoundary.LinearRing.Coordinates)
                {
                    kmlpolygon.Points.Add(new PointLatLng(loc.Latitude, loc.Longitude));
                }

                kmlpolygonsoverlay.Polygons.Add(kmlpolygon);
            }
            else if (ls != null)
            {
                GMapRoute kmlroute = new GMapRoute(new List<PointLatLng>(), "kmlroute");

                kmlroute.Stroke.Color = Color.Purple;

                foreach (var loc in ls.Coordinates)
                {
                    kmlroute.Points.Add(new PointLatLng(loc.Latitude, loc.Longitude));
                }

                kmlpolygonsoverlay.Routes.Add(kmlroute);
            }
        }
Exemplo n.º 58
0
        private void domainUpDown1_ValueChanged(object sender, EventArgs e)
        {
            if (CMB_camera.Text != "")
                doCalc();

            // new grid system test
            List<PointLatLngAlt> list = new List<PointLatLngAlt>();

            plugin.Host.FPDrawnPolygon.Points.ForEach(x => { list.Add(x); });

            grid = Grid.CreateGrid(list, (double)NUM_altitude.Value, (double)NUM_Distance.Value, (double)NUM_spacing.Value, (double)NUM_angle.Value, (double)NUM_overshoot.Value, (double)NUM_overshoot2.Value, (Grid.StartPosition)Enum.Parse(typeof(Grid.StartPosition), CMB_startfrom.Text), false);

            List<PointLatLng> list2 = new List<PointLatLng>();

            grid.ForEach(x => { list2.Add(x); });

            map.HoldInvalidation = true;

            layerpolygons.Polygons.Clear();
            layerpolygons.Markers.Clear();

            if (chk_boundary.Checked)
                AddDrawPolygon();

            int a = 1;
            PointLatLngAlt prevpoint = grid[0];
            foreach (var item in grid)
            {
                if (item.Tag == "M")
                {
                    if (chk_internals.Checked)
                        layerpolygons.Markers.Add(new GMapMarkerGoogleGreen(item) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.OnMouseOver });
                    try
                    {
                        if (TXT_fovH.Text != "")
                        {
                            float fovh = float.Parse(TXT_fovH.Text);
                            float fovv = float.Parse(TXT_fovV.Text);

                            float startangle = 0;

                            if (!CHK_camdirection.Checked)
                            {
                                startangle = 90;
                            }

                            float angle1 = startangle - (float)(Math.Tan((fovv / 2) / (fovh / 2)) * rad2deg);
                            float dist1 = (float)Math.Sqrt(Math.Pow(fovh / 2, 2) + Math.Pow(fovv / 2, 2));

                            float bearing = (float)prevpoint.GetBearing(item);

                            List<PointLatLng> footprint = new List<PointLatLng>();
                            footprint.Add(item.newpos(bearing + angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 - angle1, dist1));
                            footprint.Add(item.newpos(bearing + 180 + angle1, dist1));
                            footprint.Add(item.newpos(bearing - angle1, dist1));

                            GMapPolygon poly = new GMapPolygon(footprint, a.ToString());
                            poly.Stroke.Color = Color.FromArgb(250 - ((a * 5) % 240), 250 - ((a * 3) % 240), 250 - ((a * 9) % 240));
                            poly.Stroke.Width = 1;
                            poly.Fill = new SolidBrush(Color.FromArgb(40, Color.Purple));
                            if (chk_footprints.Checked)
                                layerpolygons.Polygons.Add(poly);
                        }
                    }
                    catch { }
                }
                else
                {
                    if (chk_markers.Checked)
                        layerpolygons.Markers.Add(new GMapMarkerGoogleGreen(item) { ToolTipText = a.ToString(), ToolTipMode = MarkerTooltipMode.Always });
                }
                prevpoint = item;
                a++;
            }

            // add wp polygon
            wppoly = new GMapPolygon(list2, "Grid");
            wppoly.Stroke.Color = Color.Yellow;
            wppoly.Stroke.Width = 4;
            if (chk_grid.Checked)
                layerpolygons.Polygons.Add(wppoly);

            Console.WriteLine("Poly Dist " + wppoly.Distance);

            lbl_area.Text = calcpolygonarea(plugin.Host.FPDrawnPolygon.Points).ToString("#") + " m^2";

            lbl_distance.Text = wppoly.Distance.ToString("0.##") + " km";

            lbl_spacing.Text = NUM_spacing.Value.ToString("#") + " m";

            lbl_grndres.Text = TXT_cmpixel.Text;

                map.HoldInvalidation = false;

            map.ZoomAndCenterMarkers("polygons");
        }
Exemplo n.º 59
0
        void AddDrawPolygon()
        {
            List<PointLatLng> list2 = new List<PointLatLng>();

            list.ForEach(x => { list2.Add(x); });

            var poly = new GMapPolygon(list2, "poly");
            poly.Stroke = new Pen(Color.Red, 2);
            poly.Fill = Brushes.Transparent;

            routesOverlay.Polygons.Add(poly);

            foreach (var item in list)
            {
                routesOverlay.Markers.Add(new GMarkerGoogle(item, GMarkerGoogleType.red));
            }
        }
Exemplo n.º 60
0
        void AddDrawPolygon()
        {
            List<PointLatLng> list2 = new List<PointLatLng>();

            list.ForEach(x => { list2.Add(x); });

            var poly = new GMapPolygon(list2, "poly");
            poly.Stroke.Brush = Brushes.Red;
            poly.Stroke.Color = Color.Red;
            poly.Fill = Brushes.Transparent;

            layerpolygons.Polygons.Add(poly);
        

            foreach (var item in list)
            {
                layerpolygons.Markers.Add(new GMarkerGoogle(item,GMarkerGoogleType.red));
            }
        }