public void Add_gMapPOI(POIPoints point)
        {
            string pnt_name = point.name;
            //_mapcontrol.Position = new global::GMap.NET.PointLatLng(point.lat, point.lon);
            GMapMarker marker = new GMarkerGoogle(
                new PointLatLng(point.lat, point.lon),
                GMarkerGoogleType.blue_pushpin);

            marker.ToolTipText      = pnt_name;
            marker.Tag              = pnt_name;
            marker.IsVisible        = false;
            marker.IsHitTestVisible = false;
            _overmarkers.Markers.Add(marker);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            POIPoints pnt = new POIPoints();

            pnt.name     = txtPOIName.Text;
            pnt.lat      = Convert.ToDouble(txtPOILatitude.Text);
            pnt.lon      = Convert.ToDouble(txtPOILongitude.Text);
            pnt.elev     = Convert.ToDouble(txtPOIElevation.Text);
            pnt.alt      = Convert.ToDouble(txtPOIAltitude.Text);
            pnt.cam_alt  = Convert.ToDouble(txtPOICameraAlt.Text);
            pnt.visible  = true;
            pnt.selected = true;
            _wpg.ReplacePOI(_poi_index, pnt);
            GMAPTree.Update_GMapTree(_wpg, _treeview);
            _gmap.ReDrawgMap();
            this.Close();
        }
        public void Delete_gMapPOI(POIPoints point)
        {
            string pnt_name = point.name;

            int mark_count = _overmarkers.Markers.Count;

            for (int i = 0; i < mark_count; i++)
            {
                GMapMarker marker   = _overmarkers.Markers.ElementAt(i);
                string     markname = Convert.ToString(marker.Tag);
                if (pnt_name == markname)
                {
                    _overmarkers.Markers.RemoveAt(i);
                    break;
                }
            }
        }
        // Add POI at this location

        private void btnAddPOI_Click(object sender, EventArgs e)
        {
            // Get the POI Name

            string poi_name = txtAddPOIName.Text;

            if (poi_name == null | poi_name == "")
            {
                MessageBox.Show("Enter a POI Name");
                return;
            }

            // Make sure POI Name is Unique

            for (int i = 0; i < _wpg.POICount(); i++)
            {
                POIPoints pnt = _wpg.POIPointAt(i);
                if (poi_name == pnt.name)
                {
                    MessageBox.Show("Name previously used, Enter a unique name");
                    return;
                }
            }

            POIPoints poipoint = new POIPoints();

            poipoint.name     = poi_name;
            poipoint.lat      = _lat;
            poipoint.lon      = _lon;
            poipoint.elev     = Convert.ToDouble(txtAddPOIElev.Text);
            poipoint.alt      = Convert.ToDouble(txtAddPOIAlt.Text);
            poipoint.cam_alt  = Convert.ToDouble(txtAddPOICamAlt.Text);
            poipoint.visible  = true;
            poipoint.selected = false;
            _wpg.AddPOI(poipoint);
            _gmap.Add_gMapPOI(poipoint);
            //_gmap.ReDrawgMap();
            this.Close();
        }
        private void buildCircPath()
        {
            if (!_build)
            {
                return;
            }

            // Get Parameters

            double lat_home          = _lat;
            double lon_home          = _lon;
            double lat_center        = _lat;
            double lon_center        = _lon;
            double altitude          = Convert.ToDouble(txtDiaAddCircPathAlt.Text);
            double circle_radius     = Convert.ToDouble(txtDiaAddCircPathRadius.Text);
            double start_angle       = Convert.ToDouble(txtCircStartAngle.Text);
            double circle_span       = Convert.ToDouble(txtCircSpan.Text);
            int    circle_num_points = Convert.ToInt16(txtCircNumPoints.Text);
            bool   startend          = chkCircHome.Checked;

            int[,] no_actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };
            int[,] actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };

            // Get Camera Location

            double lat_camera   = lat_center;
            double lon_camera   = lon_center;
            String cam_poi_name = cmbCircPOI.GetItemText(cmbCircPOI.SelectedItem);

            for (int i = 0; i < _wpg.POICount(); i++)
            {
                POIPoints tmp_point = _wpg.POIPointAt(i);
                string    name      = tmp_point.name;
                if (cam_poi_name == name)
                {
                    lat_camera = tmp_point.lat;
                    lon_camera = tmp_point.lon;
                }
            }

            // Generate Full 360 degree circle

            LinkedList <WayPoints> new_list = new LinkedList <WayPoints>();
            int    gimblemode  = 0;
            double gimplepitch = -GPS.RadiansToDegrees(Math.Atan(altitude / circle_radius));
            double curvesize   = 0;
            double rotdir      = 0;

            if (startend)
            {
                _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, 0.0, curvesize, rotdir, 0, 0.0, no_actions);
            }
            int    count   = 0;
            double heading = 0;
            double distance;
            double angle           = start_angle;
            double angle_increment = circle_span / (circle_num_points);
            bool   full_circle     = chkFullCircle.Checked;

            if (circle_span == 360.0)
            {
                full_circle = true;
            }
            double circ_lat;
            double circ_lon;
            double start_lat  = 0;
            double start_lon  = 0;
            double start_head = 0;

            if (full_circle)
            {
                angle_increment = 360.0 / circle_num_points;
            }
            if (radioCCW.Checked)
            {
                angle_increment = -angle_increment;
            }
            int num_points = circle_num_points;

            if (!full_circle)
            {
                num_points++;
            }
            do
            {
                circ_lat = GPS.GPS_Lat_BearDist(lat_center, lon_center, angle, circle_radius, Form1.Globals.gps_radius);
                circ_lon = GPS.GPS_Lon_BearDist(lat_center, lon_center, circ_lat, angle, circle_radius, Form1.Globals.gps_radius);

                if (chkCircPOI.Checked)
                {
                    heading     = GPS.GPS_Bearing(circ_lat, circ_lon, lat_camera, lon_camera);
                    distance    = GPS.GPS_Distance(circ_lat, circ_lon, lat_camera, lon_camera, Form1.Globals.gps_radius);
                    gimplepitch = -GPS.RadiansToDegrees(Math.Atan(altitude / distance));
                    gimblemode  = 2;
                }
                else
                {
                    heading = GPS.Mod_Angle(angle + 90);
                    if (radioCCW.Checked)
                    {
                        heading = GPS.Mod_Angle(heading + 180.0);
                    }
                    gimplepitch = 0;
                    gimblemode  = 0;
                }

                if (count == 0)
                {
                    start_lat = circ_lat; start_lon = circ_lon; start_head = heading;
                }

                _wp.Add_Waypoint_List(new_list, circ_lat, circ_lon, altitude, heading, curvesize, rotdir, gimblemode, gimplepitch, actions);

                angle = angle + angle_increment;
                count++;
            } while (count < num_points);

            if (full_circle)
            {
                _wp.Add_Waypoint_List(new_list, start_lat, start_lon, altitude, start_head, curvesize, rotdir, gimblemode, gimplepitch, actions);
            }
            ;

            if (startend)
            {
                _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, 0.0, curvesize, rotdir, gimblemode, 0.0, no_actions);
            }

            // Save Path

            if (_new_path & _first_pass)
            {
                string path_name = txtDiaAddCircPathName.Text;
                if (path_name == "")
                {
                    path_name = "Untitled - Circular";
                }
                _path.Add_Path(_wpg, _gmap, path_name, "Circular", new_list);
                _path       = _wpg.PathAt(_wpg.PathCount() - 1);
                _first_pass = false;
                //Models.Path newpath = _wpg.PathAt(_current_path_index);
                //newpath.visible = true;
                //newpath.selected = true;
            }
            else
            {
                _path.waypoints = new_list;
                //_wpg.ChangePathWP(_path, new_list);
                //Models.Path path = _wpg.PathAt(_current_path_index);
                //_gmap.Delete_gMapPath(path);
                //_gmap.Add_gMapPath(path, false);
            }
            _path.visible  = true;
            _path.selected = false;
            //_gmap.BuildgMap();
            _gmap.ReDrawgMap();
        }
        private void BuildRectPath()
        {
            if (!_build)
            {
                return;
            }

            // Get center position

            double lat_home   = _lat;
            double lon_home   = _lon;
            double lat_center = _lat;
            double lon_center = _lon;
            string path_name  = txtRectPathName.Text;

/*
 *          int poi_count = _wpg.POICount();
 *          POIPoints tmp_point;
 *          for (int i = 0; i < poi_count; i++)
 *          {
 *              tmp_point = _wpg.POIPointAt(i);
 *              string name = tmp_point.name;
 *              if (home_name == name)
 *              {
 *
 *                  lat_home = tmp_point.lat;
 *                  lon_home = tmp_point.lon;
 *              }
 *          }
 */
            double lat_camera;
            double lon_camera;

            LinkedList <WayPoints> new_list = new LinkedList <WayPoints>();

            // Get Values from input Boxes

            _video = radioVideo.Checked;
            bool OnePass   = chkOnePass.Checked;
            bool startend  = chkRectHome.Checked;
            bool camerapoi = chkRectCamPOI.Checked;
            int  poi_count;

            if (camerapoi)
            {
                string poi_name = cmbRectCamPOI.GetItemText(cmbRectCamPOI.SelectedItem);
                poi_count = _wpg.POICount();

                for (int i = 0; i < poi_count; i++)
                {
                    POIPoints tmp_point = _wpg.POIPointAt(i);
                    string    name      = tmp_point.name;
                    if (poi_name == name)
                    {
                        lat_camera = tmp_point.lat;
                        lon_camera = tmp_point.lon;
                    }
                }
            }

            double box_width  = Convert.ToDouble(txtGridLength.Text);
            double box_height = Convert.ToDouble(txtGridWidth.Text);
            double altitude   = Convert.ToDouble(txtPathAlt.Text);

            _camera_width  = (2 * (Math.Tan(GPS.DegreesToRadians(_camera_angle_hor / 2)) * altitude));
            _camera_height = (2 * (Math.Tan(GPS.DegreesToRadians(_camera_angle_ver / 2)) * altitude));

            if (!Form1.Globals.UnitsMetric)
            {
                box_width      = FeetToMeters(box_width);
                box_height     = FeetToMeters(box_height);
                _camera_width  = FeetToMeters(_camera_width);
                _camera_height = FeetToMeters(_camera_height);
            }
            //double box_rotate = Convert.ToDouble(txtGridRotation.Text);
            double box_rotate = Convert.ToDouble(txtGridRotation.Text) - 90.0;
            //double box_rotate = 0.0;

            double hor_overlap = _overlap_width / 100;
            double ver_overlap = _overlap_height / 100;



            double gps_radius = Form1.Globals.gps_radius;

            int[,] actions = new int[, ] {
                { 0, 2000 }, { 1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };
            int[,] no_actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };

            /* Start Calculating */


            double diagonal_length = Math.Sqrt((box_width / 2) * (box_width / 2) + (box_height / 2) * (box_height / 2));
            double diagonal_angle  = GPS.RadiansToDegrees(Math.Atan((box_width / 2) / (box_height / 2)));



            /* Calculate Top, Bottom, Left & Right Center Positions */

            double lat_top;
            double lon_top;
            double lat_bottom;
            double lon_bottom;
            double lat_left;
            double lon_left;
            double lat_right;
            double lon_right;

            lat_top = GPS.GPS_Lat_BearDist(lat_center, lon_center, 0, box_height / 2, gps_radius);
            lon_top = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, 0, box_height / 2, gps_radius);

            lat_bottom = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180, box_height / 2, gps_radius);
            lon_bottom = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_bottom, 180, box_height / 2, gps_radius);

            lat_left = GPS.GPS_Lat_BearDist(lat_center, lon_center, 270, box_width / 2, gps_radius);
            lon_left = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_left, 270, box_width / 2, gps_radius);

            lat_right = GPS.GPS_Lat_BearDist(lat_center, lon_center, 90, box_width / 2, gps_radius);
            lon_right = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_right, 90, box_width / 2, gps_radius);

            /* Calculate 4 corner locations */

            double lat_top_left;
            double lon_top_left;
            double lat_bottom_left;
            double lon_bottom_left;
            double lat_top_right;
            double lon_top_right;
            double lat_bottom_right;
            double lon_bottom_right;

            double[,] polypnt = new double[4, 2];

            lat_top_left  = GPS.GPS_Lat_BearDist(lat_center, lon_center, -diagonal_angle, diagonal_length, gps_radius);
            lon_top_left  = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, -diagonal_angle, diagonal_length, gps_radius);
            polypnt[0, 0] = lat_top_left;
            polypnt[0, 1] = lon_top_left;

            lat_top_right = GPS.GPS_Lat_BearDist(lat_center, lon_center, diagonal_angle, diagonal_length, gps_radius);
            lon_top_right = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, diagonal_angle, diagonal_length, gps_radius);
            polypnt[1, 0] = lat_top_right;
            polypnt[1, 1] = lon_top_right;

            lat_bottom_right = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180 - diagonal_angle, diagonal_length, gps_radius);
            lon_bottom_right = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, 180 - diagonal_angle, diagonal_length, gps_radius);
            polypnt[2, 0]    = lat_bottom_right;
            polypnt[2, 1]    = lon_bottom_right;

            lat_bottom_left = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180 + diagonal_angle, diagonal_length, gps_radius);
            lon_bottom_left = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, 180 + diagonal_angle, diagonal_length, gps_radius);
            polypnt[3, 0]   = lat_bottom_left;
            polypnt[3, 1]   = lon_bottom_left;

            // Rotate Points

            double new_lat, new_lon;


            for (int i = 0; i < 4; i++)
            {
                double rot_bearing  = GPS.GPS_Bearing(lat_center, lon_center, polypnt[i, 0], polypnt[i, 1]);
                double rot_distance = GPS.GPS_Distance(lat_center, lon_center, polypnt[i, 0], polypnt[i, 1], gps_radius);

                // Calculate a new location by increasing the bearing

                new_lat       = GPS.GPS_Lat_BearDist(lat_center, lon_center, rot_bearing + box_rotate, rot_distance, gps_radius);
                new_lon       = GPS.GPS_Lon_BearDist(lat_center, lon_center, new_lat, rot_bearing + box_rotate, rot_distance, gps_radius);
                polypnt[i, 0] = new_lat;
                polypnt[i, 1] = new_lon;
            }

            // Generate Rectangle Polygon


            _poly.name    = "temp";
            _poly.visible = true;
            LinkedList <PolyPoint> shape_points = new LinkedList <PolyPoint>();

            for (int i = 0; i <= 3; i++)
            {
                PolyPoint newpnt = new PolyPoint();
                newpnt.lat = polypnt[i, 0];
                newpnt.lon = polypnt[i, 1];
                newpnt.alt = 10;
                shape_points.AddLast(newpnt);
            }
            PolyPoint pnt = new PolyPoint();

            pnt.lat = polypnt[0, 0];
            pnt.lon = polypnt[0, 1];
            pnt.alt = 10;
            shape_points.AddLast(pnt);
            _poly.points = shape_points;

            // Get Direction Flags

            double drone_heading = 90.0;
            int    ver_dir_flag  = 1;

            if (radioUpLeft.Checked)
            {
                ver_dir_flag = 1;
            }
            if (radioUpRight.Checked)
            {
                ver_dir_flag = 1; drone_heading = 270;
            }
            if (radioLowLeft.Checked)
            {
                ver_dir_flag = -1;
            }
            if (radioLowRight.Checked)
            {
                ver_dir_flag = -1; drone_heading = 270;
            }

            // Grid Calculations

            double lat_next;
            double next_lon_start;
            double next_lon_end;
            double lon_tmp;
            double row_increment = _camera_width * (1.0 - hor_overlap);
            int    num_rows      = Convert.ToInt16(box_height / row_increment);

            box_rotate = 0.0;

            // Create Waypoints

            int    gimblemode  = 2;
            double gimblepitch = -90.0;
            double curvesize   = 0;
            double rotdir      = 0;

            if (OnePass | num_rows == 1)
            {
                if (startend)
                {
                    _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                }

                if (radioUpLeft.Checked | radioLowLeft.Checked)
                {
                    _wp.Add_Leg_List(new_list, lat_left, lon_left, lat_right, lon_right,
                                     altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                }
                else
                {
                    _wp.Add_Leg_List(new_list, lat_right, lon_right, lat_left, lon_left,
                                     altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                }

                if (startend)
                {
                    _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                }
            }
            else
            {
                /* More than one row */

                if (num_rows == 2)
                {
                    double offset            = row_increment;
                    double diagonal_length_2 = Math.Sqrt((box_width / 2) * (box_width / 2) + (offset / 2) * (offset / 2));
                    double diagonal_angle_2  = GPS.RadiansToDegrees(Math.Atan((box_width / 2) / (offset / 2)));

                    lat_top_left = GPS.GPS_Lat_BearDist(lat_center, lon_center, -diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);
                    lon_top_left = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, -diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);

                    lat_top_right = GPS.GPS_Lat_BearDist(lat_center, lon_center, diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);
                    lon_top_right = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);

                    lat_bottom_left = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180 + diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);
                    lon_bottom_left = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, 180 + diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);

                    lat_bottom_right = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180 - diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);
                    lon_bottom_right = GPS.GPS_Lon_BearDist(lat_center, lon_center, lat_top, 180 - diagonal_angle_2 + box_rotate, diagonal_length_2, gps_radius);

                    if (startend)
                    {
                        _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                    }
                    if (radioLowLeft.Checked)
                    {
                        _wp.Add_Leg_List(new_list, lat_bottom_left, lon_bottom_left, lat_bottom_right, lon_bottom_right,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                        _wp.Add_Leg_List(new_list, lat_top_right, lon_top_right, lat_top_left, lon_top_left,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                    }

                    if (radioLowRight.Checked)
                    {
                        _wp.Add_Leg_List(new_list, lat_bottom_right, lon_bottom_right, lat_bottom_left, lon_bottom_left,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                        _wp.Add_Leg_List(new_list, lat_top_left, lon_top_left, lat_top_right, lon_top_right,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                    }

                    if (radioUpLeft.Checked)
                    {
                        _wp.Add_Leg_List(new_list, lat_top_left, lon_top_left, lat_top_right, lon_top_right,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                        _wp.Add_Leg_List(new_list, lat_bottom_right, lon_bottom_right, lat_bottom_left, lon_bottom_left,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                    }

                    if (radioUpRight.Checked)
                    {
                        _wp.Add_Leg_List(new_list, lat_top_right, lon_top_right, lat_top_left, lon_top_left,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                        _wp.Add_Leg_List(new_list, lat_bottom_left, lon_bottom_left, lat_bottom_right, lon_bottom_right,
                                         altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                    }

                    if (startend)
                    {
                        _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                    }
                }
                else
                {
                    /* More than 2 rows */

                    double row_span = (num_rows - 1) * row_increment;
                    lat_top    = GPS.GPS_Lat_BearDist(lat_center, lon_center, 0 + box_rotate, row_span / 2, gps_radius);
                    lat_bottom = GPS.GPS_Lat_BearDist(lat_center, lon_center, 180 + box_rotate, row_span / 2, gps_radius);
                    double degrees_per_foot = (lat_top - lat_bottom) / row_span;

                    if (startend)
                    {
                        _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                    }

                    int row_count = 0;
                    next_lon_start = 0.0;
                    next_lon_end   = 0.0;
                    double lat_current = 0.0;

                    do
                    {
                        /* First Row */

                        if (row_count == 0)
                        {
                            if (radioLowLeft.Checked)
                            {
                                _wp.Add_Leg_List(new_list, lat_bottom, lon_left, lat_bottom, lon_right,
                                                 altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                                lat_current    = lat_bottom;
                                next_lon_start = lon_right;
                                next_lon_end   = lon_left;
                            }
                            if (radioLowRight.Checked)
                            {
                                _wp.Add_Leg_List(new_list, lat_bottom, lon_right, lat_bottom, lon_left,
                                                 altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                                lat_current    = lat_bottom;
                                next_lon_start = lon_left;
                                next_lon_end   = lon_right;
                            }
                            if (radioUpLeft.Checked)
                            {
                                _wp.Add_Leg_List(new_list, lat_top, lon_left, lat_top, lon_right,
                                                 altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                                lat_current    = lat_top;
                                next_lon_start = lon_right;
                                next_lon_end   = lon_left;
                            }
                            if (radioUpRight.Checked)
                            {
                                _wp.Add_Leg_List(new_list, lat_top, lon_right, lat_top, lon_left,
                                                 altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                                lat_current    = lat_top;
                                next_lon_start = lon_left;
                                next_lon_end   = lon_right;
                            }
                        }
                        else
                        {
                            /* Output 2nd, 3rd, etc. */

                            //lat_current = Globals.waypoints[Globals.waypoint_count - 1, 0];
                            lat_next = lat_current + (-ver_dir_flag * (degrees_per_foot * row_increment));
                            _wp.Add_Leg_List(new_list, lat_next, next_lon_start, lat_next, next_lon_end,
                                             altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, actions, _video, _camera_height, _overlap_height);
                            lon_tmp        = next_lon_start;
                            next_lon_start = next_lon_end;
                            next_lon_end   = lon_tmp;
                            lat_current    = lat_next;
                        }
                        row_count++;
                    } while (row_count < num_rows);

                    if (startend)
                    {
                        _wp.Add_Waypoint_List(new_list, lat_home, lon_home, altitude, drone_heading, curvesize, rotdir, gimblemode, gimblepitch, no_actions);
                    }
                }
            }


            // Rotate WayPoints about Center

            int    count = 0;
            double lat, lon, alt, head, bearing, distance;
            double lat_first = lat_center;
            double lon_first = lon_center;
            LinkedListNode <WayPoints> node = new_list.First;
            //LinkedListNode<WayPoints> next_node = node.Next;
            LinkedListNode <WayPoints> save_node;

            //lat_first = node.Value.lat;
            //lon_first = node.Value.lon;
            //alt_first = node.Value.alt;
            //head_first = node.Value.head;

            while (node != null)
            {
                if (count != 0)
                {
                    // Get Waypoint values

                    lat         = node.Value.lat;
                    lon         = node.Value.lon;
                    alt         = node.Value.alt;
                    head        = node.Value.head;
                    gimblemode  = node.Value.gimblemode;
                    gimblepitch = node.Value.gimblepitch;
                    curvesize   = node.Value.curvesize;
                    rotdir      = node.Value.rotationdir;
                    actions     = node.Value.actions;
                    box_rotate  = Convert.ToDouble(txtGridRotation.Text) - 90.0;

                    // Calculate Bearing and distance from first waypoint

                    bearing  = GPS.GPS_Bearing(lat_first, lon_first, lat, lon);
                    distance = GPS.GPS_Distance(lat_first, lon_first, lat, lon, gps_radius);

                    // Calculate a new location by increasing the bearing

                    new_lat = GPS.GPS_Lat_BearDist(lat_first, lon_first, bearing + box_rotate, distance, gps_radius);
                    new_lon = GPS.GPS_Lon_BearDist(lat_first, lon_first, new_lat, bearing + box_rotate, distance, gps_radius);

                    // Set new waypoint

                    WayPoints new_wp = new WayPoints();
                    new_wp.lat         = new_lat;
                    new_wp.lon         = new_lon;
                    new_wp.alt         = alt;
                    new_wp.head        = head + box_rotate;
                    new_wp.gimblemode  = gimblemode;
                    new_wp.gimblepitch = gimblepitch;
                    new_wp.curvesize   = curvesize;
                    new_wp.rotationdir = rotdir;
                    new_wp.actions     = actions;
                    save_node          = node;
                    new_list.AddBefore(node, new_wp);
                    node = node.Next;
                    new_list.Remove(save_node);
                }
                count++;
            }

            // Redo start and end points

            if (startend)
            {
                WayPoints wp = new_list.First.Value;
                new_list.RemoveFirst();
                wp.lat = lat_home;
                wp.lon = lon_home;
                new_list.AddFirst(wp);
                wp = new_list.Last.Value;
                new_list.RemoveLast();
                wp.lat = lat_home;
                wp.lon = lon_home;
                new_list.AddLast(wp);
            }

            // Save Path

            if (_new_path & _first_pass)
            {
                path_name = txtRectPathName.Text;
                if (path_name == "")
                {
                    path_name = "Untitled - Rectangular";
                }
                _path.Add_Path(_wpg, _gmap, path_name, "Rectangular", new_list);
                Path newpath = _wpg.PathAt(_wpg.PathCount() - 1);
                _current_intid = newpath.internal_id;
                _first_pass    = false;
            }
            else
            {
                _wpg.ChangePathWPIntId(_current_intid, new_list);
                //Models.Path path = _wpg.PathAt(_current_path_index);
                //_gmap.Delete_gMapPath(path);
                //_gmap.Add_gMapPath(path, false);
            }

            _gmap.ReDrawgMap();
            _gmap.Add_gMapPoly(_poly, true);
        }
Exemple #7
0
        private void buildHelicalPath()
        {
            if (!_build)
            {
                return;
            }

            bool   startend           = chkHelicalHome.Checked;
            double lat_home           = _lat;
            double lon_home           = _lon;
            double lat_center         = _lat;
            double lon_center         = _lon;
            double helix_start_alt    = Convert.ToDouble(txtHelixStartAlt.Text);
            double helix_end_alt      = Convert.ToDouble(txtHelixEndAlt.Text);
            double helix_start_radius = Convert.ToDouble(txtHelixStartRadius.Text);
            double helix_end_radius   = Convert.ToDouble(txtHelixEndRadius.Text);
            double helix_start_angle  = Convert.ToDouble(txtHelixStartAngle.Text);
            double helix_span         = Convert.ToDouble(txtHelixSpan.Text);
            int    helix_num_points   = Convert.ToInt16(txtHelixNumPoints.Text);

            int[,] no_actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };
            int[,] actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };

            double cw = 1.0;

            if (radioCCW.Checked)
            {
                cw = -1.0;
            }

            double lat_camera   = lat_center;
            double lon_camera   = lon_center;
            String cam_poi_name = cmbHelixPOI.GetItemText(cmbHelixPOI.SelectedItem);

            for (int i = 0; i < _wpg.POICount(); i++)
            {
                POIPoints tmp_point = _wpg.POIPointAt(i);
                string    name      = tmp_point.name;
                if (cam_poi_name == name)
                {
                    lat_camera = tmp_point.lat;
                    lon_camera = tmp_point.lon;
                }
            }

            LinkedList <WayPoints> new_list = new LinkedList <WayPoints>();
            int    count           = 0;
            double angle           = helix_start_angle;
            double angle_increment = cw * helix_span / helix_num_points;
            double circ_lat;
            double circ_lon;
            //if (chkFullCircle.Checked) angle_increment = 360.0 / helix_num_points;
            //if (radioCCW.Checked) angle_increment = -angle_increment;
            double alt_diff = helix_end_alt - helix_start_alt;
            int    alt_dir;

            if (helix_start_alt > helix_end_alt)
            {
                alt_dir = -1;
            }
            else
            {
                alt_dir = 1;
            }
            double alt_increment    = (helix_end_alt - helix_start_alt) / helix_num_points;
            double radius_increment = (helix_end_radius - helix_start_radius) / helix_num_points;
            double helix_radius;
            double helix_altitude;
            int    gimblemode  = 0;
            double gimplepitch = 0;
            double distance;
            double curvesize = 0;
            double rotdir    = 0;

            if (startend)
            {
                _wp.Add_Waypoint_List(new_list, lat_home, lon_home, helix_start_alt, 0.0, curvesize, rotdir, gimblemode, gimplepitch, no_actions);
            }
            do
            {
                double heading = GPS.Mod_Angle(angle + 180.0);
                helix_radius   = helix_start_radius + (count * radius_increment);
                helix_altitude = helix_start_alt + (count * alt_increment);
                //norm_angle = 180.0*(angle / (helix_end_angle - helix_start_angle));
                //helix_altitude = helix_start_alt + (alt_diff * alt_dir * (1+Math.Cos(DegreesToRadians(norm_angle)))/2);
                circ_lat = GPS.GPS_Lat_BearDist(lat_center, lon_center, angle, helix_radius, Form1.Globals.gps_radius);
                circ_lon = GPS.GPS_Lon_BearDist(lat_center, lon_center, circ_lat, angle, helix_radius, Form1.Globals.gps_radius);

                if (chkHelixPOI.Checked)
                {
                    heading     = GPS.GPS_Bearing(circ_lat, circ_lon, lat_camera, lon_camera);
                    distance    = GPS.GPS_Distance(circ_lat, circ_lon, lat_camera, lon_camera, Form1.Globals.gps_radius);
                    gimplepitch = -GPS.RadiansToDegrees(Math.Atan(helix_altitude / distance));
                    gimblemode  = 2;
                }
                else
                {
                    heading = GPS.Mod_Angle(angle + 90);
                    if (radioCCW.Checked)
                    {
                        heading = GPS.Mod_Angle(heading + 180.0);
                    }
                }

                _wp.Add_Waypoint_List(new_list, circ_lat, circ_lon, helix_altitude, heading, curvesize, rotdir, gimblemode, gimplepitch, actions);

                angle = angle + angle_increment;
                count++;
            } while (count <= helix_num_points);

            if (startend)
            {
                _wp.Add_Waypoint_List(new_list, lat_home, lon_home, helix_start_alt, 0.0, curvesize, rotdir, gimblemode, gimplepitch, no_actions);
            }

            // Save Path

            if (_new_path & _first_pass)
            {
                string path_name = txtAddHelixPathName.Text;
                if (path_name == "")
                {
                    path_name = "Untitled - Helical";
                }
                _path.Add_Path(_wpg, _gmap, path_name, "Helical", new_list);
                _path       = _wpg.PathAt(_wpg.PathCount() - 1);
                _first_pass = false;
            }
            else
            {
                _path.waypoints = new_list;
                //_gmap.Delete_gMapPath(_path);
                //_gmap.Add_gMapPath(_path, false);
            }

            /*
             * if (_current_path_index != -1)
             * {
             *  _wpg.DeletePath(_wpg.PathAt(_current_path_index));
             * }
             * string path_name = txtAddHelixPathName.Text;
             * if (path_name == "") path_name = "Untitled - Helical";
             * _path.Add_Path(_wpg, _gmap, path_name, "Helical", new_list);
             * int index = _wpg.PathCount() - 1;
             * _current_path_index = index;
             * Models.Path path = _wpg.PathAt(index);
             * _path = path;
             * string exist_type = path.type;
             * bool exist_select = path.selected;
             * bool exist_visible = path.visible;
             * if (exist_type == "Helical")
             * {
             *  _wpg.ChangePathWP(index, new_list);
             *  string pathname = path.name;
             *  int id = path.id;
             *  string type = path.type;
             *  _gmap.Delete_gMapPath(path);
             *  Models.Path newpath = new Models.Path();
             *  newpath.name = pathname;
             *  newpath.id = id;
             *  newpath.type = type;
             *  newpath.selected = exist_select;
             *  newpath.visible = exist_visible;
             *  newpath.waypoints = new_list;
             *  _gmap.Add_gMapPath(path, false);
             * }
             */

            _gmap.ReDrawgMap();
            //_wpg.ChangePathWP(index, new_list);
            //cmbCircReuse.ResetText();
        }
        private void BuildKMLPath()
        {
            // Create Path

            if (_current_path_index != -1)
            {
                _wpg.DeletePath(_wpg.PathAt(_current_path_index));
            }

            string path_name = txtKMLName.Text;

            if (path_name == "")
            {
                path_name = _kml_filename;
            }

            LinkedList <WayPoints> wp_list = new LinkedList <WayPoints>();

            double lat, lon, alt;
            int    gimblemode  = 0;
            double gimblepitch = 0;
            double curvesize   = 0;
            double rotdir      = 0;

            int[,] actions = new int[, ] {
                { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
            };

            LinkedList <WayPoints> new_list = new LinkedList <WayPoints>();

            /* Generate Waypoints for each coordinate */

            for (int i = 0; i < _kml_point_count; i++)
            {
                lat = _kml_points[i, 0];
                lon = _kml_points[i, 1];
                alt = _kml_points[i, 2];
                double heading = 0.0;
                double poi_lat = 0;
                double poi_lon = 0;

                /* Calculate Heading for each Waypoint */
                if (chKLMPOI.Checked)
                {
                    int poi_index = cmbKLMPOI.SelectedIndex;
                    if (poi_index == -1)
                    {
                        poi_lat = _lat;
                        poi_lon = _lon;
                    }
                    else
                    {
                        POIPoints tmp_point = _wpg.POIPointAt(poi_index);
                        poi_lat = tmp_point.lat;
                        poi_lon = tmp_point.lon;
                    }
                    heading    = GPS.GPS_Bearing(lat, lon, poi_lat, poi_lon);
                    gimblemode = 2;
                    double distance = GPS.GPS_Distance(lat, lon, poi_lat, poi_lon, Form1.Globals.gps_radius);
                    gimblepitch = -GPS.RadiansToDegrees(Math.Atan(alt / distance));
                    gimblemode  = 2;
                }
                else
                {
                    if (i != _kml_point_count - 1)
                    {
                        double lat_next = _kml_points[i + 1, 0];
                        double lon_next = _kml_points[i + 1, 1];
                        heading = GPS.GPS_Bearing(lat, lon, lat_next, lon_next);
                    }
                }
                _wp.Add_Waypoint_List(new_list, lat, lon, alt, heading, curvesize, rotdir, gimblemode, gimblepitch, actions);
                //dgvWaypoints.Rows.Add(Globals.waypoint_count + i+1, Convert.ToString(lat), Convert.ToString(lon), Convert.ToString(alt));
            }

            _path.Add_Path(_wpg, _gmap, path_name, "KML", new_list);
            int index = _wpg.PathCount() - 1;

            _current_path_index = index;

            Models.Path path          = _wpg.PathAt(index);
            string      exist_type    = path.type;
            bool        exist_select  = path.selected;
            bool        exist_visible = path.visible;

            if (exist_type == "KML")
            {
                _wpg.ChangePathWP(index, new_list);
                string pathname = path.name;
                int    id       = path.id;
                string type     = path.type;
                _gmap.Delete_gMapPath(path);
                Models.Path newpath = new Models.Path();
                newpath.name      = pathname;
                newpath.id        = id;
                newpath.type      = type;
                newpath.selected  = exist_select;
                newpath.visible   = exist_visible;
                newpath.waypoints = new_list;
                _gmap.Add_gMapPath(path, false);
            }

            _gmap.ReDrawgMap();
            GMAPTree.Update_GMapTree(_wpg, _treeview);
        }
        public void BuildgMap()
        {
            /*
             * switch (index)
             * {
             *  case 0:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.BingSatelliteMapProvider.Instance;
             *      break;
             *  case 1:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleMapProvider.Instance;
             *      break;
             *  case 2:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleTerrainMapProvider.Instance;
             *      break;
             *  case 3:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleHybridMapProvider.Instance;
             *      break;
             *  case 4:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.ArcGIS_Topo_US_2D_MapProvider.Instance;
             *      break;
             *  case 5:
             *      _mapcontrol.MapProvider = global::GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance;
             *      break;
             * }
             *
             *
             *
             * global::GMap.NET.GMaps.Instance.Mode = global::GMap.NET.AccessMode.ServerOnly;
             */
            _markers.Clear();
            _mapcontrol.Overlays.Clear();
            //_mapcontrol.ShowCenter = false;
            _overmarkers = new GMapOverlay("markers");
            _overroutes  = new GMapOverlay("routes");
            _overpolys   = new GMapOverlay("polygons");
            _mapcontrol.Overlays.Add(_overmarkers);
            _mapcontrol.Overlays.Add(_overroutes);
            _mapcontrol.Overlays.Add(_overpolys);

            _drone_image_notselected = (Bitmap)Image.FromFile("drone.png", true);
            _drone_image_selected    = (Bitmap)Image.FromFile("drone_selected.png", true);


            // Map POI

            int poicount = _wpg.POICount();

            for (int i = 0; i < poicount; i++)
            {
                GMapMarker marker;
                POIPoints  pnt     = _wpg.POIPointAt(i);
                string     poiname = pnt.name;
                if (i == 0)
                {
                    _mapcontrol.Position = new global::GMap.NET.PointLatLng(pnt.lat, pnt.lon);
                }
                if (pnt.selected)
                {
                    marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_selected_image);
                }
                else
                {
                    marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_image);
                }

                //    GMarkerGoogleType.blue_pushpin);

                //marker.Size = new Size(32, 32);
                marker.Offset           = new Point(-16, -16);
                marker.ToolTipText      = poiname;
                marker.Tag              = poiname;
                marker.IsVisible        = pnt.visible;
                marker.IsHitTestVisible = true;
                _overmarkers.Markers.Add(marker);
            }

            // Map Path

            int pathcount = _wpg.PathCount();


            for (int i = 0; i < pathcount; i++)
            {
                Path   path    = _wpg.PathAt(i);
                string name    = path.name;
                bool   visible = path.visible;
                LinkedList <WayPoints> wplist = path.waypoints;
                int wpcount = wplist.Count;

                List <PointLatLng> points = new List <PointLatLng>();
                int count = 0;
                foreach (WayPoints wp in wplist)
                {
                    bool selected = wp.selected;
                    points.Add(new PointLatLng(wp.lat, wp.lon));
                    GMapMarker marker;

                    if (selected)
                    {
                        _drone_image = _drone_image_selected;
                        _drone_image = RotateImage(_drone_image_selected, wp.head);
                        marker       = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image);
                        //GMarkerGoogleType.red_pushpin);
                    }
                    else
                    {
                        _drone_image = _drone_image_notselected;
                        _drone_image = RotateImage(_drone_image_notselected, wp.head);
                        marker       = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image);
                        //GMarkerGoogleType.blue_pushpin);
                    }
                    //marker.Size = new Size(64,64);
                    marker.Position    = new PointLatLng(wp.lat, wp.lon);
                    marker.Offset      = new Point(-16, -16);
                    marker.Tag         = Convert.ToString(i) + "." + Convert.ToString(count);
                    marker.IsVisible   = visible;
                    marker.ToolTipText = "WP(" + Convert.ToString(count) + ") - Alt:" + Convert.ToString(wp.alt);
                    _overmarkers.Markers.Add(marker);
                    wp.marker = marker;
                    GMAPWPMarker wpmarker = new GMAPWPMarker();
                    wpmarker.path     = i;
                    wpmarker.wp       = count;
                    wpmarker.marker   = marker;
                    wpmarker.selected = wp.selected;
                    _markers.Add(wpmarker);
                    count++;
                }
                GMapRoute route = new GMapRoute(points, name);
                route.Stroke           = new Pen(Color.Blue, 2);
                route.Tag              = i;
                route.IsVisible        = visible;
                route.IsHitTestVisible = true;
                _overroutes.Routes.Add(route);
                //mapcontrol.Overlays.Add(overroutes);
                //mapcontrol.Overlays.Add(markers);
            }

            //mapcontrol.Overlays.Add(markers);

            // Map Polygon

            int polycount = _wpg.ShapeCount();

            for (int i = 0; i < polycount; i++)
            {
                Shape  polyshape = _wpg.ShapeAt(i);
                string name      = polyshape.name;
                bool   visible   = polyshape.visible;
                LinkedList <PolyPoint> wplist = polyshape.points;
                int wpcount = wplist.Count;


                List <PointLatLng> points = new List <PointLatLng>();
                foreach (PolyPoint wp in wplist)
                {
                    points.Add(new PointLatLng(wp.lat, wp.lon));
                }
                GMapPolygon poly = new GMapPolygon(points, name);
                if (polyshape.selected)
                {
                    poly.Stroke = new Pen(Color.Red, 1);
                }
                else
                {
                    poly.Stroke = new Pen(Color.Yellow, 1);
                }
                poly.Fill      = new SolidBrush(Color.FromArgb(25, Color.Yellow));
                poly.Tag       = polyshape.name;
                poly.IsVisible = visible;

                _overpolys.Polygons.Add(poly);
            }

            if (!Form1.Globals.Map_FirstDraw)
            {
                _mapcontrol.Position        = Form1.Globals.map_center;
                Form1.Globals.Map_FirstDraw = false;
            }
            _center = _mapcontrol.Position;
        }
Exemple #10
0
        public void ReDrawgMap()
        {
            string lat, lon, poiname;

            PointLatLng center_position = _mapcontrol.Position;

            //_markers.Clear();
            _mapcontrol.Overlays.Clear();
            _mapcontrol.Position = center_position;
            //_mapcontrol.ShowCenter = false;
            _overmarkers = new GMapOverlay("markers");
            _overroutes  = new GMapOverlay("routes");
            _overpolys   = new GMapOverlay("polygons");

            _mapcontrol.Overlays.Add(_overmarkers);
            _mapcontrol.Overlays.Add(_overroutes);
            _mapcontrol.Overlays.Add(_overpolys);

            // Map POI

            int poicount = _wpg.POICount();

            for (int i = 0; i < poicount; i++)
            {
                GMapMarker marker;
                POIPoints  pnt = _wpg.POIPointAt(i);
                poiname = pnt.name;
                //if (i == 0) _mapcontrol.Position = new global::GMap.NET.PointLatLng(pnt.lat, pnt.lon);
                if (pnt.selected)
                {
                    marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_selected_image);
                }
                else
                {
                    marker = new GMarkerGoogle(new PointLatLng(pnt.lat, pnt.lon), _poi_image);
                }

                //GMarkerGoogleType.blue_pushpin);
                marker.Offset      = new Point(-16, -16);
                marker.ToolTipText = poiname;
                marker.Tag         = poiname;
                marker.IsVisible   = pnt.visible;
                //marker.IsVisible = true;
                marker.IsHitTestVisible = true;
                _overmarkers.Markers.Add(marker);
            }

            // Map Path

            int pathcount = _wpg.PathCount();


            for (int i = 0; i < pathcount; i++)
            {
                Models.Path            path          = _wpg.PathAt(i);
                bool                   path_visible  = path.visible;
                bool                   path_selected = path.selected;
                string                 name          = path.name;
                LinkedList <WayPoints> wplist        = path.waypoints;
                if (wplist != null)
                {
                    int wpcount = wplist.Count;

                    List <PointLatLng> points = new List <PointLatLng>();
                    int count = 0;
                    foreach (WayPoints wp in wplist)
                    {
                        points.Add(new PointLatLng(wp.lat, wp.lon));
                        GMapMarker marker;
                        if (path_selected | wp.selected)
                        {
                            _drone_image = _drone_image_selected;
                            _drone_image = RotateImage(_drone_image_selected, wp.head);
                            marker       = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image);
                            //GMarkerGoogleType.red_pushpin);
                        }
                        else
                        {
                            _drone_image = _drone_image_notselected;
                            _drone_image = RotateImage(_drone_image_notselected, wp.head);
                            marker       = new GMarkerGoogle(new PointLatLng(wp.lat, wp.lon), _drone_image);
                            //GMarkerGoogleType.blue_pushpin);
                        }
                        //marker.Size = new Size(64,64);
                        marker.Offset      = new Point(-16, -16);
                        marker.Tag         = Convert.ToString(i) + "." + Convert.ToString(count);
                        marker.IsVisible   = path_visible;
                        marker.ToolTipText = "WP(" + Convert.ToString(count) + ") - Alt:" + Convert.ToString(wp.alt);
                        _overmarkers.Markers.Add(marker);
                        GMAPWPMarker wpmarker = new GMAPWPMarker();
                        wpmarker.path     = i;
                        wpmarker.wp       = count;
                        wpmarker.marker   = marker;
                        wpmarker.selected = wp.selected;
                        _markers.Add(wpmarker);

                        count++;
                    }
                    GMapRoute route = new GMapRoute(points, name);
                    route.Stroke           = new Pen(Color.Blue, 2);
                    route.Tag              = i;
                    route.IsVisible        = path_visible;
                    route.IsHitTestVisible = true;
                    _overroutes.Routes.Add(route);
                }
                //gMap.Overlays.Add(overroutes);
                //gMap.Overlays.Add(markers);
            }

            //gMap.Overlays.Add(markers);

            // Map Polygon

            int polycount = _wpg.ShapeCount();

            for (int i = 0; i < polycount; i++)
            {
                Models.Shape           polyshape = _wpg.ShapeAt(i);
                string                 name      = polyshape.name;
                LinkedList <PolyPoint> wplist    = polyshape.points;
                int wpcount = wplist.Count;


                List <PointLatLng> points = new List <PointLatLng>();
                foreach (PolyPoint wp in wplist)
                {
                    points.Add(new PointLatLng(wp.lat, wp.lon));
                }
                GMapPolygon poly = new GMapPolygon(points, name);
                if (polyshape.selected)
                {
                    poly.Stroke = new Pen(Color.Red, 1);
                }
                else
                {
                    poly.Stroke = new Pen(Color.Yellow, 1);
                }
                poly.Fill             = new SolidBrush(Color.FromArgb(25, Color.Yellow));
                poly.Tag              = polyshape.name;
                poly.IsVisible        = polyshape.visible;
                poly.IsHitTestVisible = true;
                _overpolys.Polygons.Add(poly);
            }
            _mapcontrol.Position = center_position;
        }