private void btnCancel_Click(object sender, EventArgs e)
 {
     _wpg.DeletePath(_path);
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     _gmap.ReDrawgMap();
     this.Close();
 }
Example #2
0
 private void btnAcceptChange_Click(object sender, EventArgs e)
 {
     _poly.name = txtPolyName.Text;
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     _gmap.ReDrawgMap();
     this.Close();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     _path.name = txtPathName.Text;
     _path.type = txtPathType.Text;
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     _gmap.ReDrawgMap();
     this.Close();
 }
 private void btnCancel_Click(object sender, EventArgs e)
 {
     if (_current_path_index != -1)
     {
         _wpg.DeletePath(_wpg.PathAt(_current_path_index));
     }
     _gmap.ReDrawgMap();
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     this.Close();
 }
        public DialogManualPath(Waypoint_Path_Gen wpg, GMAP gmap, TreeView treeview, Path path, Options options, double lat, double lon)
        {
            _wpg            = wpg;
            _gmap           = gmap;
            _treeview       = treeview;
            _options        = options;
            _path           = path;
            _lat            = lat;
            _lon            = lon;
            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 }
            };


            InitializeComponent();

            // Create new Path with a Single Waypoint

            _alt = _options.def_altitude;

            _handler_off           = true;
            txtManualAltitude.Text = Convert.ToString(_alt);
            _handler_off           = false;
            string name = txtPathName.Text;

            _path.name     = name;;
            _path.type     = "Manual";
            _path.visible  = true;
            _path.selected = true;
            _wp_list       = new LinkedList <WayPoints>();
            _wp            = new WayPoints();
            _wp.lat        = _lat;
            _wp.lon        = _lon;
            _wp.visible    = true;
            _wp.selected   = false;
            _wp.head       = 0;
            _wp.alt        = _alt;
            _wp.actions    = _actions;
            _wp_list.AddLast(_wp);
            _wp_list.AddLast(_wp);
            _path.waypoints = _wp_list;
            _wpg.AddPath(_path);


            GMAPTree.Update_GMapTree(_wpg, _treeview);
            _gmap.ReDrawgMap();
        }
        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();
        }
 private void txtPathName_TextChanged(object sender, EventArgs e)
 {
     _path.name = txtPathName.Text;
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     _gmap.ReDrawgMap();
 }
Example #8
0
        private void btnReadKMLPoly_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                /* Get kml filename */

                string kml_file = openFileDialog1.FileName;

                if (kml_file.Contains(".kml"))
                {
                    System.IO.TextReader    stream = System.IO.File.OpenText(kml_file);
                    SharpKml.Engine.KmlFile file   = KmlFile.Load(stream);
                    Kml _kml = file.Root as Kml;

                    SharpKml.Dom.Placemark[] tempPlaceMarks = new SharpKml.Dom.Placemark[1000];
                    SharpKml.Dom.Placemark   tmp_placemark  = new SharpKml.Dom.Placemark();
                    CoordinateCollection     coordinates    = new CoordinateCollection();
                    Form1.Globals.poly_point_count = 0;

                    if (_kml != null)
                    {
                        SharpKml.Base.Vector vector;
                        double lat;
                        double lon;
                        double alt;
                        string name = "";

                        foreach (var placemark in _kml.Flatten().OfType <SharpKml.Dom.Placemark>())
                        {
                            name = placemark.Name;
                        }

                        Models.Shape shape = new Models.Shape();
                        shape.name = name;

                        foreach (var linering in _kml.Flatten().OfType <LinearRing>())
                        {
                            coordinates = linering.Coordinates;
                            int num = coordinates.Count;

                            LinkedList <PolyPoint> shape_points = new LinkedList <PolyPoint>();

                            for (int i = 0; i < num; i++)
                            {
                                PolyPoint point = new PolyPoint();
                                vector    = coordinates.ElementAt(i);
                                lat       = vector.Latitude;
                                lon       = vector.Longitude;
                                alt       = (double)vector.Altitude;
                                point.lat = lat;
                                point.lon = lon;
                                point.alt = alt;
                                shape_points.AddLast(point);
                                //dgvWaypoints.Rows.Add(Globals.waypoint_count, Convert.ToString(lat), Convert.ToString(lon), Convert.ToString(30));
                            }
                            shape.points  = shape_points;
                            shape.visible = true;
                            _wpg.AddShape(shape);
                            _gmap.Add_gMapPoly(shape, true);
                        }
                    }
                }
                GMAPTree.Update_GMapTree(_wpg, _treeview);
                this.Close();
            }
        }
Example #9
0
 private void btnAddPath_Click(object sender, EventArgs e)
 {
     GMAPTree.Update_GMapTree(_wpg, _treeview);
     this.Close();
 }
        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);
        }