コード例 #1
0
        public DialogKMLPath(Waypoint_Path_Gen wpg, GMAP gmap, TreeView treeview, double lat, double lon)
        {
            _lat                = lat;
            _lon                = lon;
            _wpg                = wpg;
            _gmap               = gmap;
            _treeview           = treeview;
            _current_path_index = -1;
            _path               = new Models.Path();
            _wp = new WayPoints();

            InitializeComponent();

            // Fill POI combobox

            cmbKLMPOI.Items.Clear();
            for (int i = 0; i < _wpg.POICount(); i++)
            {
                cmbKLMPOI.Items.Add(_wpg.POIPointAt(i).name);
            }

            // Generate EMpty Path

            _path.Add_Empty_Path(_wpg, _gmap, "Empty Path", "KML");
            _current_path_index = _wpg.PathCount() - 1;
        }
コード例 #2
0
ファイル: GMap.cs プロジェクト: bbodnyk/WaypointPathGenerator
        public void Delete_gMapPath(Models.Path path)
        {
            string name    = path.name;
            int    path_id = path.id;
            LinkedList <WayPoints> wplist = path.waypoints;
            int wpcount = wplist.Count;

            // Loop thru Paths

            int route_count = _overroutes.Routes.Count;

            for (int i = 0; i < route_count; i++)
            {
                GMapRoute route   = _overroutes.Routes.ElementAt(i);
                int       routeid = Convert.ToInt16(route.Tag);
                if (routeid == path_id)
                {
                    _overroutes.Routes.RemoveAt(i);
                    break;
                }
            }
            route_count = _overroutes.Routes.Count;

            // Loop thru Waypoints

            bool found    = false;
            int  wp_count = _overmarkers.Markers.Count;

            do
            {
                foreach (GMapMarker marker in _overmarkers.Markers)
                {
                    string id_text = Convert.ToString(marker.Tag);
                    int    index   = id_text.IndexOf(".");
                    if (index != -1)
                    {
                        int indexwp   = Convert.ToInt16(id_text.Substring(index + 1));
                        int indexpath = Convert.ToInt16(id_text.Substring(0, index));
                        if (path_id == indexpath)
                        {
                            _overmarkers.Markers.Remove(marker);
                            found = true;
                            break;
                        }
                        else
                        {
                            found = false;
                        }
                    }
                    else
                    {
                        found = false;
                    }
                }
            } while (found);
        }
コード例 #3
0
ファイル: GMap.cs プロジェクト: bbodnyk/WaypointPathGenerator
        public void Add_gMapPath(Models.Path path, bool visible)
        {
            string name = path.name;
            int    id   = path.id;
            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));
                    _drone_image = _drone_image_notselected;
                    _drone_image = RotateImage(_drone_image_notselected, wp.head);
                    GMapMarker 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(id) + "." + Convert.ToString(count);
                    marker.IsVisible        = visible;
                    marker.IsHitTestVisible = true;
                    marker.ToolTipText      = "WP(" + Convert.ToString(count) + ") - Alt:" + Convert.ToString(wp.alt);
                    _overmarkers.Markers.Add(marker);
                    wp.marker = marker;
                    count++;
                }
                GMapRoute route = new GMapRoute(points, name);
                route.Stroke    = new Pen(Color.Blue, 2);
                route.Tag       = id;
                route.IsVisible = visible;
                _overroutes.Routes.Add(route);
            }
        }
コード例 #4
0
        private void BuildPath()
        {
            int polyindex = cmbPolyPath.SelectedIndex;

            if (polyindex == -1)
            {
                return;
            }

            // Get Path

            double lat, lat_next;
            double lon, lon_next;
            double alt = Convert.ToDouble(txtAltPolyPath.Text);
            double head;
            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 }
            };
            Models.Shape           poly      = _wpg.ShapeAt(polyindex);
            LinkedList <PolyPoint> points    = poly.points;
            LinkedList <WayPoints> waypoints = new LinkedList <WayPoints>();
            string path_name = poly.name;

            for (int i = 0; i < points.Count; i++)
            {
                lat = points.ElementAt(i).lat;
                lon = points.ElementAt(i).lon;
                if (i < (points.Count - 1))
                {
                    lat_next = points.ElementAt(i + 1).lat;
                    lon_next = points.ElementAt(i + 1).lon;
                    head     = GPS.GPS_Bearing(lat, lon, lat_next, lon_next);
                }
                else
                {
                    lat_next = points.ElementAt(0).lat;
                    lon_next = points.ElementAt(0).lon;
                    head     = GPS.GPS_Bearing(lat, lon, lat_next, lon_next);
                }
                _wp.Add_Waypoint_List(waypoints, lat, lon, alt, head, curvesize, rotdir, gimblemode, gimblepitch, actions);
            }

            // Add Path

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

            int index = cmbPolyPath.SelectedIndex;

            path_name = _wpg.ShapeAt(index).name;
            if (path_name == "")
            {
                path_name = "Untitled - Perimeter";
            }
            _path.Add_Path(_wpg, _gmap, path_name, "Perimeter", waypoints);
            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 == "Perimeter")
            {
                _wpg.ChangePathWP(index, waypoints);
                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 = waypoints;
                _gmap.Add_gMapPath(path, false);
            }

            _gmap.ReDrawgMap();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: GMap.cs プロジェクト: bbodnyk/WaypointPathGenerator
        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;
        }