Exemplo n.º 1
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.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);

            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_pictures.Text = images.ToString();

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

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

            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");
        }