Beispiel #1
0
        public ElevationProfile(List <PointLatLngAlt> locs, double homealt, FlightPlanner.altmode altmode)
        {
            InitializeComponent();

            this.altmode = altmode;

            planlocs = locs;

            for (int a = 0; a < planlocs.Count; a++)
            {
                if (planlocs[a] == null || planlocs[a].Tag != null && planlocs[a].Tag.Contains("ROI"))
                {
                    planlocs.RemoveAt(a);
                    a--;
                }
            }

            if (planlocs.Count <= 1)
            {
                CustomMessageBox.Show("Please plan something first", Strings.ERROR);
                return;
            }

            // get total distance
            distance = 0;
            PointLatLngAlt lastloc = null;

            foreach (PointLatLngAlt loc in planlocs)
            {
                if (loc == null)
                {
                    continue;
                }

                if (lastloc != null)
                {
                    distance += (int)loc.GetDistance(lastloc);
                }
                lastloc = loc;
            }

            this.homealt = homealt;

            Form frm = Common.LoadingBox("Loading", "using alt data");

            gelocs = getGEAltPath(planlocs);

            srtmlocs = getSRTMAltPath(planlocs);

            frm.Close();

            MissionPlanner.Utilities.Tracking.AddPage(this.GetType().ToString(), this.Text);
        }
Beispiel #2
0
        public static List <PointLatLngAlt> CreateCorridor(List <PointLatLngAlt> polygon, double height, double camViewHeight, double camVertSpacing, double distance, double angle,
                                                           double camPitch, bool flipDirection, double bermDepth, int numBenches, double toeHeight, double toepoint, double toepoint_runs, bool pathHome, double homeAlt, FlightPlanner.altmode altmode)
        {
            int direction = (flipDirection == true ? -1 : 1);

            if (camVertSpacing < 0.1)
            {
                camVertSpacing = 0.1;
            }

            if (polygon.Count == 0 || numBenches < 1)
            {
                return(new List <PointLatLngAlt>());
            }

            List <PointLatLngAlt> ans = new List <PointLatLngAlt>();

            // utm zone distance calcs will be done in
            int utmzone = polygon[0].GetUTMZone();

            // utm position list
            List <utmpos> utmpositions = utmpos.ToList(PointLatLngAlt.ToUTM(utmzone, polygon), utmzone);

            double vertOffset          = 0;
            double horizOffset         = 0;
            double toepoint_runs_count = 0;

            //calculate number of lanes with a starting altitude of half the calculated cam view height
            // double initialAltitude = camViewHeight * Math.Sin(angle * deg2rad) / 3;
            double initialAltitude = toepoint;
            var    vertIncrement   = camVertSpacing * Math.Sin(angle * deg2rad);
            var    lanes           = Math.Round((height - initialAltitude) / vertIncrement) + toepoint_runs + 1;

            //repeat for each bench, applying height/berm depth offsets
            for (int bench = 0; bench < numBenches; bench++)
            {
                //repeat for each increment up face
                for (int lane = 0; lane < lanes; lane++)
                {
                    if (toepoint_runs_count < toepoint_runs)
                    {
                        //calculate offset from the base of the face based on toe angle, camera pitch, camera overlap % and bench offset
                        vertOffset  = distance * Math.Sin(camPitch * deg2rad) + (initialAltitude + (bench * height) + toeHeight);
                        horizOffset = distance * Math.Cos(camPitch * deg2rad) - ((initialAltitude) / Math.Tan(angle * deg2rad)) - bench * (bermDepth + height / Math.Tan(angle * deg2rad));
                        toepoint_runs_count++;
                    }
                    else
                    {
                        //calculate offset from the base of the face based on toe angle, camera pitch, camera overlap % and bench offset
                        vertOffset  = distance * Math.Sin(camPitch * deg2rad) + (initialAltitude + ((lane - toepoint_runs) * vertIncrement) + (bench * height) + toeHeight);
                        horizOffset = distance * Math.Cos(camPitch * deg2rad) - ((initialAltitude + ((lane - toepoint_runs) * vertIncrement)) / Math.Tan(angle * deg2rad)) - bench * (bermDepth + height / Math.Tan(angle * deg2rad));
                    }

                    // THIS IS COMMENTED OUT BECAUSE IT'S INSANE NONSENSE THAT SHOULD NEVER HAVE BEEN IN HERE.
                    //
                    //    //convert to absolute if flight planner is set to absolute mode (shift up by home alt)
                    //    if (altmode == FlightPlanner.altmode.Absolute)
                    //    {
                    //        vertOffset += homeAlt;
                    //    }

                    //if this is the first lane of a bench, climb to the altitude of the first waypoint of the lane before moving to the waypoint
                    if (lane == 0 && ans.Count > 0)
                    {
                        PointLatLngAlt intermediateWP = new PointLatLngAlt(ans.Last().Lat, ans.Last().Lng, vertOffset)
                        {
                            Tag = "S"
                        };
                        ans.Add(intermediateWP);
                    }

                    GenerateOffsetPath(utmpositions, horizOffset * direction, utmzone)
                    .ForEach(pnt => { ans.Add(pnt); ans.Last().Alt = vertOffset; });

                    //reverse the order of waypoints and direction of offset on the way back
                    utmpositions.Reverse();
                    direction = -direction;
                }
            }

            //if an odd number of lanes were specified create one last run along the path back to home
            if (pathHome && ((lanes * numBenches) % 2) == 1)
            {
                GenerateOffsetPath(utmpositions, horizOffset * direction, utmzone)
                .ForEach(pnt => { ans.Add(pnt); ans.Last().Alt = vertOffset; ans.Last().Tag = "R"; });
            }
            return(ans);
        }