public static List <double> GetFomLimits(string oaName)
        {
            List <double> limits = new List <double>();

            double maxDouble = -99999;
            double minDouble = -99999;
            double stdDev    = -99999;

            try
            {
                IAgAnimation animationRoot = (IAgAnimation)CommonData.StkRoot;
                double       currentTime   = animationRoot.CurrentTime;
                string       time          = CommonData.StkRoot.ConversionUtility.ConvertDate("EpSec", "UTCG", currentTime.ToString());

                string          name     = "CoverageDefinition/" + oaName + "/FigureOfMerit/" + oaName + "_FOM";
                IAgStkObject    fom      = CommonData.StkRoot.GetObjectFromPath(name);
                IAgDataPrvFixed fomDp    = fom.DataProviders["Overall Value"] as IAgDataPrvFixed;
                IAgDrResult     result   = fomDp.Exec();
                Array           minLimit = result.DataSets.GetDataSetByName("Minimum").GetValues();
                minDouble = Double.Parse(minLimit.GetValue(0).ToString());

                Array maxLimit = result.DataSets.GetDataSetByName("Maximum").GetValues();
                maxDouble = Double.Parse(maxLimit.GetValue(0).ToString());

                Array std = result.DataSets.GetDataSetByName("Standard Deviation").GetValues();
                stdDev = Double.Parse(std.GetValue(0).ToString());
            }
            catch (Exception)
            {
            }
            limits.Add(Math.Round(minDouble, 3));
            limits.Add(Math.Round(maxDouble, 3));
            limits.Add(Math.Round(stdDev, 2));
            return(limits);
        }
        public static Array GetArticulations(IAgStkObject parent)

        {
            IAgDataPrvFixed articDP = parent.DataProviders["Model LOD 0 Articulations"] as IAgDataPrvFixed;
            IAgDrResult     result  = articDP.Exec();
            Array           names   = result.DataSets.ElementNames;

            return(names);
        }
Esempio n. 3
0
        // old method

        /*     public MyWaypoint Geocode(string address)
         *   {
         *       GeocodeRequest locationRequest = new GeocodeRequest();
         *
         *       // Set the credentials using a valid Bing Maps key
         *       locationRequest.Credentials = new BingGeocodeService.Credentials();
         *       locationRequest.Credentials.ApplicationId = m_bingMapKey;
         *       locationRequest.Query = address;
         *
         *       // Make the calculate route request
         *       GeocodeServiceClient geocodeService = new BingGeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
         *       GeocodeResponse geocodeResponse = geocodeService.Geocode(locationRequest);
         *
         *       MyWaypoint returnPoint = new MyWaypoint();
         *       if (geocodeResponse.Results.Length > 0)
         *       {
         *           returnPoint.Latitude = geocodeResponse.Results[0].Locations[0].Latitude;
         *           returnPoint.Longitude = geocodeResponse.Results[0].Locations[0].Longitude;
         *           //returnPoint.Altitude = GetAltitude(returnPoint.Latitude, returnPoint.Longitude);
         *           returnPoint.Altitude = 0.0;
         *       }
         *
         *       return returnPoint;
         *   } */

        // convert object location to lat/lon
        public MyWaypoint Geocode(IAgStkObject stkObject)
        {
            IAgDataPrvFixed dataprov = stkObject.DataProviders["LLA State"] as IAgDataPrvFixed;
            IAgDrResult     result   = dataprov.Exec();

            Array lat = result.DataSets.GetDataSetByName("Lat").GetValues();
            Array lon = result.DataSets.GetDataSetByName("Lon").GetValues();

            MyWaypoint returnPoint = new MyWaypoint();

            returnPoint.Latitude  = (double)lat.GetValue(0);
            returnPoint.Longitude = (double)lon.GetValue(0);
            returnPoint.Altitude  = 0.0;


            return(returnPoint);
        }
Esempio n. 4
0
        public static void AutoContour(string fomPath, string staticOrAnimation)
        {
            IAgStkObject figureofMerit = root.GetObjectFromPath(fomPath);

            IAgDataPrvFixed fomDP = (IAgDataPrvFixed)figureofMerit.DataProviders["Overall Value"];
            //Execute the data providers over the scenario interval - scen.StartTime to scen.StopTime
            IAgDrResult fomResult = fomDP.Exec();

            Array mini = fomResult.DataSets.GetDataSetByName("Minimum").GetValues();
            Array maxi = fomResult.DataSets.GetDataSetByName("Maximum").GetValues();

            double min = .99 * (double)mini.GetValue(0);
            double max = 1.01 * (double)maxi.GetValue(0);

            double step = (max - min) / 99.0;

            string staticOnOff;
            string animationOnOff;

            if (staticOrAnimation.ToLower() == "static")
            {
                staticOnOff    = "On";
                animationOnOff = "Off";
            }
            else
            {
                staticOnOff    = "Off";
                animationOnOff = "On";
            }

            root.ExecuteCommand("BatchGraphics * On");
            root.ExecuteCommand("Graphics " + fomPath + " Contours " + staticOrAnimation + " ColorRamp red blue StartStop " + min.ToString() + " " + max.ToString() + " " + step.ToString());
            root.ExecuteCommand("Graphics " + fomPath + " Contours Static Show " + staticOnOff);
            root.ExecuteCommand("Graphics " + fomPath + " Static " + staticOnOff);
            root.ExecuteCommand("Graphics " + fomPath + " Contours Animation Show " + animationOnOff);
            root.ExecuteCommand("Graphics " + fomPath + " Animation " + animationOnOff);
            root.ExecuteCommand("BatchGraphics * Off");
        }
Esempio n. 5
0
        public Waypoint LocationWaypointGenerator(string locationPath, double altitude, double speed, double turnRadius)
        {
            IAgStkObject    location       = root.GetObjectFromPath(locationPath);
            IAgDataPrvFixed locationDP     = location.DataProviders["LLA State"] as IAgDataPrvFixed;
            IAgDrResult     locationResult = locationDP.Exec();
            Array           latResults     = locationResult.DataSets.GetDataSetByName("Lat").GetValues();
            Array           lonResults     = locationResult.DataSets.GetDataSetByName("Lon").GetValues();
            Array           altResults     = locationResult.DataSets.GetDataSetByName("Ground Alt MSL").GetValues();
            double          locationLat    = (double)latResults.GetValue(0);
            double          locationLon    = (double)lonResults.GetValue(0);
            double          locationAlt    = (double)altResults.GetValue(0);

            Waypoint waypoint = new Waypoint();

            waypoint.Latitude        = locationLat;
            waypoint.Longitude       = locationLon;
            waypoint.Altitude        = altitude;
            waypoint.SurfaceAltitude = locationAlt;
            waypoint.Speed           = speed;
            waypoint.TurnRadius      = turnRadius;

            return(waypoint);
        }
Esempio n. 6
0
        public List <Waypoint> BoundingParallelTrackWaypointGenerator(
            string areaTargetPath, double speed, double altitude, double turnRadius, SwathWidthType swathType, double swathParameter)
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            IAgStkObject         areaTarget       = root.GetObjectFromPath(areaTargetPath);
            IAgDataProviderGroup boundingProvider = areaTarget.DataProviders["Bounding Rectangle"] as IAgDataProviderGroup;
            IAgDataPrvFixed      dpElements       = boundingProvider.Group["Corner Points"] as IAgDataPrvFixed;
            IAgDrResult          atDataPrvResult  = dpElements.Exec();

            Array atLats = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lat").GetValues();
            Array atLons = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lon").GetValues();

            IAgExecCmdResult cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                             atLats.GetValue(0).ToString() + " " + atLons.GetValue(0).ToString()
                                                             + " " + atLats.GetValue(1).ToString() + " " + atLons.GetValue(1).ToString());

            double regionWidth = double.Parse(cmdResult[0]);

            int numPasses = DetermineNumPasses(swathType, swathParameter, altitude, regionWidth, null);

            if (numPasses < 1)
            {
                MessageBox.Show("No Passes.  Try Adjusting Swath Width Parameters");
                return(waypoints);
            }

            double topStepLat    = (((double)atLats.GetValue(1) - (double)atLats.GetValue(0)) / (double)numPasses);
            double bottomStepLat = (((double)atLats.GetValue(2) - (double)atLats.GetValue(3)) / (double)numPasses);
            double topStepLon    = (((double)atLons.GetValue(1) - (double)atLons.GetValue(0)) / (double)numPasses);
            double bottomStepLon = (((double)atLons.GetValue(2) - (double)atLons.GetValue(3)) / (double)numPasses);

            double topLat0    = (double)atLats.GetValue(0);
            double topLon0    = (double)atLons.GetValue(0);
            double bottomLat0 = (double)atLats.GetValue(3);
            double bottomLon0 = (double)atLons.GetValue(3);

            Waypoint waypoint = new Waypoint();

            for (int i = 0; i <= numPasses; ++i)
            {
                int test = i % 2;

                double latTopEnroute = topLat0 + (double)i * topStepLat;
                double lonTopEnroute = topLon0 + (double)i * topStepLon;

                double latBottomEnroute = bottomLat0 + (double)i * bottomStepLat;
                double lonBottomEnroute = bottomLon0 + (double)i * bottomStepLon;


                if (test == 0)
                {
                    waypoint                 = new Waypoint();
                    waypoint.Latitude        = latTopEnroute;
                    waypoint.Longitude       = lonTopEnroute;
                    waypoint.Altitude        = altitude;
                    waypoint.SurfaceAltitude = 0;
                    waypoint.Speed           = speed;
                    waypoint.TurnRadius      = turnRadius;
                    waypoints.Add(waypoint);

                    waypoint            = new Waypoint();
                    waypoint.Latitude   = latBottomEnroute;
                    waypoint.Longitude  = lonBottomEnroute;
                    waypoint.Altitude   = altitude;
                    waypoint.Speed      = speed;
                    waypoint.TurnRadius = turnRadius;
                    waypoints.Add(waypoint);
                }
                else
                {
                    waypoint                 = new Waypoint();
                    waypoint.Latitude        = latBottomEnroute;
                    waypoint.Longitude       = lonBottomEnroute;
                    waypoint.Altitude        = altitude;
                    waypoint.SurfaceAltitude = 0;
                    waypoint.Speed           = speed;
                    waypoint.TurnRadius      = turnRadius;
                    waypoints.Add(waypoint);

                    waypoint            = new Waypoint();
                    waypoint.Latitude   = latTopEnroute;
                    waypoint.Longitude  = lonTopEnroute;
                    waypoint.Altitude   = altitude;
                    waypoint.Speed      = speed;
                    waypoint.TurnRadius = turnRadius;
                    waypoints.Add(waypoint);
                }
            }

            return(waypoints);
        }
Esempio n. 7
0
        public List <Waypoint> RasterSearchWaypointGenerator(
            string areaTargetPath, string heading, double speed, double altitude, double turnRadius,
            SwathWidthType swathType, double swathParameter)
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            IAgStkObject areaTarget = root.GetObjectFromPath(areaTargetPath);

            IAgAreaTarget areaTargetObj      = (IAgAreaTarget)areaTarget;
            bool          areaTargetElActive = areaTarget.AccessConstraints.IsConstraintActive(AgEAccessConstraints.eCstrElevationAngle);
            double        restoreAngle       = 0;

            if (!areaTargetElActive)
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.AddConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                elevationMin.Angle = 90;
            }
            else
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.GetActiveConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                restoreAngle       = (double)elevationMin.Angle;
                elevationMin.Angle = 90;
            }

            double minLat = 90;
            double maxLat = -90;
            double minLon = 180;
            double maxLon = -180;

            root.UnitPreferences["Angle"].SetCurrentUnit("deg");
            switch (areaTargetObj.AreaType)
            {
            case AgEAreaType.eEllipse:
                IAgDataProviderGroup boundingProvider = areaTarget.DataProviders["Bounding Rectangle"] as IAgDataProviderGroup;
                IAgDataPrvFixed      dpElements       = boundingProvider.Group["Corner Points"] as IAgDataPrvFixed;
                IAgDrResult          atDataPrvResult  = dpElements.Exec();

                Array atLats = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lat").GetValues();
                Array atLons = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lon").GetValues();
                foreach (object item in atLats)
                {
                    if ((double)item > maxLat)
                    {
                        maxLat = (double)item;
                    }
                    if ((double)item < minLat)
                    {
                        minLat = (double)item;
                    }
                }
                foreach (object item in atLons)
                {
                    if ((double)item > maxLon)
                    {
                        maxLon = (double)item;
                    }
                    if ((double)item < minLon)
                    {
                        minLon = (double)item;
                    }
                }
                break;

            case AgEAreaType.ePattern:
                IAgAreaTypePatternCollection boundary = areaTargetObj.AreaTypeData as IAgAreaTypePatternCollection;

                foreach (IAgAreaTypePattern item in boundary)
                {
                    if ((double)item.Lat > maxLat)
                    {
                        maxLat = (double)item.Lat;
                    }
                    if ((double)item.Lat < minLat)
                    {
                        minLat = (double)item.Lat;
                    }

                    if ((double)item.Lon > maxLon)
                    {
                        maxLon = (double)item.Lon;
                    }
                    if ((double)item.Lon < minLon)
                    {
                        minLon = (double)item.Lon;
                    }
                }

                break;

            default:
                break;
            }
            double deltaLat = maxLat - minLat;
            double deltaLon = maxLon - minLon;

            IAgExecCmdResult cmdResult;

            switch (heading)
            {
            case "NorthSouth":
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + minLat + " " + maxLon);
                break;

            case "EastWest":
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + maxLat + " " + minLon);
                break;

            default:
                cmdResult = root.ExecuteCommand("MeasureSurfaceDistance * " +
                                                minLat + " " + minLon + " " + maxLat + " " + minLon);
                break;
            }



            double regionWidth = double.Parse(cmdResult[0]);

            int numPasses = DetermineNumPasses(swathType, swathParameter, altitude, regionWidth, null);

            if (numPasses < 1)
            {
                MessageBox.Show("No Passes.  Try Adjusting Swath Width Parameters");
                return(waypoints);
            }
            root.BeginUpdate();

            string           gvName        = uniqueName("gridTester", AgESTKObjectType.eGroundVehicle);
            IAgGroundVehicle groundVehicle = root.CurrentScenario.Children.New(AgESTKObjectType.eGroundVehicle, gvName) as IAgGroundVehicle;

            groundVehicle.Graphics.SetAttributesType(AgEVeGfxAttributes.eAttributesBasic);
            IAgVeGfxAttributesBasic gvGfx = groundVehicle.Graphics.Attributes as IAgVeGfxAttributesBasic;

            gvGfx.Inherit   = false;
            gvGfx.IsVisible = false;

            IAgVePropagatorGreatArc route = groundVehicle.Route as IAgVePropagatorGreatArc;

            //route.ArcGranularity = 51.333;
            route.SetAltitudeRefType(AgEVeAltitudeRef.eWayPtAltRefWGS84);
            route.Method = AgEVeWayPtCompMethod.eDetermineTimeAccFromVel;

            Waypoint waypoint1 = new Waypoint();
            Waypoint waypoint2 = new Waypoint();
            bool     headEast  = true;


            double loopMin;
            double loopMax;
            double gridAngleStep;

            switch (heading)
            {
            case "NorthSouth":
                loopMin       = minLon;
                loopMax       = maxLon;
                gridAngleStep = (maxLon - minLon) / numPasses;
                break;

            case "EastWest":
                loopMin       = minLat;
                loopMax       = maxLat;
                gridAngleStep = (maxLat - minLat) / numPasses;
                break;

            default:
                loopMin       = minLat;
                loopMax       = maxLat;
                gridAngleStep = .95 * (maxLat - minLat) / numPasses;
                break;
            }

            for (double eval = loopMin; eval <= loopMax; eval += gridAngleStep)
            {
                route.Waypoints.RemoveAll();
                IAgVeWaypointsElement thisWaypoint1;
                IAgVeWaypointsElement thisWaypoint2;
                switch (heading)
                {
                case "NorthSouth":
                    thisWaypoint1           = route.Waypoints.Add();
                    thisWaypoint1.Latitude  = minLat - gridAngleStep;
                    thisWaypoint1.Longitude = eval;
                    thisWaypoint1.Altitude  = 0;

                    thisWaypoint2           = route.Waypoints.Add();
                    thisWaypoint2.Latitude  = maxLat + gridAngleStep;
                    thisWaypoint2.Longitude = eval;
                    thisWaypoint2.Altitude  = 0;
                    break;

                case "EastWest":
                default:
                    thisWaypoint1           = route.Waypoints.Add();
                    thisWaypoint1.Latitude  = eval;
                    thisWaypoint1.Longitude = minLon - gridAngleStep;
                    thisWaypoint1.Altitude  = 0;

                    thisWaypoint2           = route.Waypoints.Add();
                    thisWaypoint2.Latitude  = eval;
                    thisWaypoint2.Longitude = maxLon + gridAngleStep;
                    thisWaypoint2.Altitude  = 0;
                    break;
                }
                route.Propagate();

                IAgStkAccess access = areaTarget.GetAccessToObject((IAgStkObject)groundVehicle);
                access.ComputeAccess();

                IAgDataPrvInterval dpAccess = access.DataProviders["Access Data"] as IAgDataPrvInterval;
                IAgScenario        scen     = root.CurrentScenario as IAgScenario;
                IAgDrResult        result   = dpAccess.Exec(scen.StartTime, scen.StopTime);


                if (result.DataSets.Count > 0)
                {
                    Array startTimes = result.DataSets.GetDataSetByName("Start Time").GetValues();
                    Array stopTimes  = result.DataSets.GetDataSetByName("Stop Time").GetValues();

                    string startTime = (string)startTimes.GetValue(0);
                    string stopTime  = (string)stopTimes.GetValue(stopTimes.GetLength(0) - 1);

                    IAgDataProviderGroup dpLLA         = ((IAgStkObject)groundVehicle).DataProviders["LLA State"] as IAgDataProviderGroup;
                    IAgDataPrvTimeVar    dpElements    = dpLLA.Group["Fixed"] as IAgDataPrvTimeVar;
                    IAgDrResult          DataPrvResult = dpElements.ExecSingle(startTime);

                    Array Lats = DataPrvResult.DataSets.GetDataSetByName("Lat").GetValues();
                    Array Lons = DataPrvResult.DataSets.GetDataSetByName("Lon").GetValues();

                    waypoint1                 = new Waypoint();
                    waypoint1.Latitude        = (double)Lats.GetValue(0);
                    waypoint1.Longitude       = (double)Lons.GetValue(0);
                    waypoint1.Altitude        = altitude;
                    waypoint1.SurfaceAltitude = 0;
                    waypoint1.Speed           = speed;
                    waypoint1.TurnRadius      = turnRadius;


                    IAgDataProviderGroup dpLLA1         = ((IAgStkObject)groundVehicle).DataProviders["LLA State"] as IAgDataProviderGroup;
                    IAgDataPrvTimeVar    dpElements1    = dpLLA1.Group["Fixed"] as IAgDataPrvTimeVar;
                    IAgDrResult          DataPrvResult1 = dpElements1.ExecSingle(stopTime);

                    Array Lats1 = DataPrvResult1.DataSets.GetDataSetByName("Lat").GetValues();
                    Array Lons1 = DataPrvResult1.DataSets.GetDataSetByName("Lon").GetValues();

                    waypoint2                 = new Waypoint();
                    waypoint2.Latitude        = (double)Lats1.GetValue(0);
                    waypoint2.Longitude       = (double)Lons1.GetValue(0);
                    waypoint2.Altitude        = altitude;
                    waypoint2.SurfaceAltitude = 0;
                    waypoint2.Speed           = speed;
                    waypoint2.TurnRadius      = turnRadius;


                    if (headEast)
                    {
                        waypoints.Add(waypoint1);
                        waypoints.Add(waypoint2);
                    }
                    else
                    {
                        waypoints.Add(waypoint2);
                        waypoints.Add(waypoint1);
                    }
                    headEast = !headEast;
                }
                access.RemoveAccess();
            }

            ((IAgStkObject)groundVehicle).Unload();

            if (!areaTargetElActive)
            {
                areaTarget.AccessConstraints.RemoveConstraint(AgEAccessConstraints.eCstrElevationAngle);
            }
            else
            {
                IAgAccessCnstrAngle elevationMin = areaTarget.AccessConstraints.GetActiveConstraint(AgEAccessConstraints.eCstrElevationAngle) as IAgAccessCnstrAngle;
                root.UnitPreferences["Angle"].SetCurrentUnit("deg");
                elevationMin.Angle = restoreAngle;
            }

            root.EndUpdate();
            root.UnitPreferences.ResetUnits();
            return(waypoints);
        }
Esempio n. 8
0
        public List <Waypoint> ExpandingSquareWaypointGenerator(
            string areaTargetPath, double speed, double altitude, double turnRadius,
            SwathWidthType swathType, double swathParameter)
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            IAgStkObject areaTarget = root.GetObjectFromPath(areaTargetPath);

            IAgAreaTarget areaTargetObj = (IAgAreaTarget)areaTarget;

            double minLat = 90;
            double maxLat = -90;
            double minLon = 180;
            double maxLon = -180;

            root.UnitPreferences["Angle"].SetCurrentUnit("deg");
            switch (areaTargetObj.AreaType)
            {
            case AgEAreaType.eEllipse:
                IAgDataProviderGroup boundingProvider = areaTarget.DataProviders["Bounding Rectangle"] as IAgDataProviderGroup;
                IAgDataPrvFixed      dpElements       = boundingProvider.Group["Corner Points"] as IAgDataPrvFixed;
                IAgDrResult          atDataPrvResult  = dpElements.Exec();

                Array atLats = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lat").GetValues();
                Array atLons = atDataPrvResult.DataSets.GetDataSetByName("Geodetic-Lon").GetValues();
                foreach (object item in atLats)
                {
                    if ((double)item > maxLat)
                    {
                        maxLat = (double)item;
                    }
                    if ((double)item < minLat)
                    {
                        minLat = (double)item;
                    }
                }
                foreach (object item in atLons)
                {
                    if ((double)item > maxLon)
                    {
                        maxLon = (double)item;
                    }
                    if ((double)item < minLon)
                    {
                        minLon = (double)item;
                    }
                }
                break;

            case AgEAreaType.ePattern:
                IAgAreaTypePatternCollection boundary = areaTargetObj.AreaTypeData as IAgAreaTypePatternCollection;

                foreach (IAgAreaTypePattern item in boundary)
                {
                    if ((double)item.Lat > maxLat)
                    {
                        maxLat = (double)item.Lat;
                    }
                    if ((double)item.Lat < minLat)
                    {
                        minLat = (double)item.Lat;
                    }

                    if ((double)item.Lon > maxLon)
                    {
                        maxLon = (double)item.Lon;
                    }
                    if ((double)item.Lon < minLon)
                    {
                        minLon = (double)item.Lon;
                    }
                }

                break;

            default:
                break;
            }
            double deltaLat = maxLat - minLat;
            double deltaLon = maxLon - minLon;
            double swathWidth;
            double gridAngleStep;

            if (swathType != SwathWidthType.NumberOfPasses)
            {
                swathWidth    = DetermineSwathWidth(swathType, swathParameter, altitude);
                gridAngleStep = swathWidth / 111000; // degrees longitude...ish
            }
            else
            {
                gridAngleStep = (((maxLat - minLat) + (maxLon - minLon)) / 2) / swathParameter;
            }

            double initialLat, initialLon;

            initialLat = maxLat - ((maxLat - minLat) / 2);
            initialLon = maxLon - ((maxLon - minLon) / 2);
            //IAgPosition centroid = (areaTarget as IAgAreaTarget).Position;

            //object centroidLat;
            //object centroidLon;
            //double centroidAlt;
            //centroid.QueryPlanetodetic(out centroidLat, out centroidLon, out centroidAlt);
            //initialLat = (double)centroidLat ;
            //initialLon = (double)centroidLon  ;

            Waypoint waypointInit = new Waypoint();

            waypointInit.Latitude        = (double)initialLat;
            waypointInit.Longitude       = (double)initialLon;
            waypointInit.Altitude        = altitude;
            waypointInit.SurfaceAltitude = 0;
            waypointInit.Speed           = speed;
            waypointInit.TurnRadius      = turnRadius;

            waypoints.Add(waypointInit);
            bool     keepCircling = true;
            Waypoint waypoint1, waypoint2, waypoint3, waypoint4;
            double   multiplier = 1;

            while (keepCircling)
            {
                waypoint1                 = new Waypoint();
                waypoint1.Latitude        = waypoints[waypoints.Count - 1].Latitude + multiplier * gridAngleStep;
                waypoint1.Longitude       = waypoints[waypoints.Count - 1].Longitude;
                waypoint1.Altitude        = altitude;
                waypoint1.SurfaceAltitude = 0;
                waypoint1.Speed           = speed;
                waypoint1.TurnRadius      = turnRadius;
                waypoints.Add(waypoint1);

                waypoint2                 = new Waypoint();
                waypoint2.Latitude        = waypoints[waypoints.Count - 1].Latitude;
                waypoint2.Longitude       = waypoints[waypoints.Count - 1].Longitude + multiplier * gridAngleStep;
                waypoint2.Altitude        = altitude;
                waypoint2.SurfaceAltitude = 0;
                waypoint2.Speed           = speed;
                waypoint2.TurnRadius      = turnRadius;
                waypoints.Add(waypoint2);
                multiplier += 1.0;

                waypoint3                 = new Waypoint();
                waypoint3.Latitude        = waypoints[waypoints.Count - 1].Latitude - multiplier * gridAngleStep;
                waypoint3.Longitude       = waypoints[waypoints.Count - 1].Longitude;
                waypoint3.Altitude        = altitude;
                waypoint3.SurfaceAltitude = 0;
                waypoint3.Speed           = speed;
                waypoint3.TurnRadius      = turnRadius;
                waypoints.Add(waypoint3);

                waypoint4                 = new Waypoint();
                waypoint4.Latitude        = waypoints[waypoints.Count - 1].Latitude;
                waypoint4.Longitude       = waypoints[waypoints.Count - 1].Longitude - multiplier * gridAngleStep;
                waypoint4.Altitude        = altitude;
                waypoint4.SurfaceAltitude = 0;
                waypoint4.Speed           = speed;
                waypoint4.TurnRadius      = turnRadius;
                waypoints.Add(waypoint4);
                multiplier += 1.0;

                if ((waypoint4.Latitude > maxLat & waypoint4.Longitude > maxLon) ||
                    (waypoint4.Latitude < minLat & waypoint4.Longitude < minLon))
                {
                    keepCircling = false;
                }
            }

            return(waypoints);
        }
Esempio n. 9
0
        public Array GetDataProviders(string stkObjectPath, string DataProviderName,
                                      string GroupName, string ElementName)
        {
            string startTime = scen.StartTime.ToString();
            string stopTime  = scen.StopTime.ToString();
            double stepSize  = 60;

            IAgStkObject stkObject = root.GetObjectFromPath(stkObjectPath);

            IAgDataProviderInfo dpInfo = stkObject.DataProviders[DataProviderName];

            IAgDataProvider dataProvider = stkObject.DataProviders[DataProviderName] as IAgDataProvider;

            if (dpInfo.IsGroup())
            {
                IAgDataProviderGroup dpGroup     = dpInfo as IAgDataProviderGroup;
                IAgDataProviders     dpAvailable = dpGroup.Group;

                for (int i = 0; i < dpAvailable.Count; ++i)
                {
                    if (dpAvailable[i].Name == GroupName)
                    {
                        dataProvider = dpAvailable[i] as IAgDataProvider;
                        break;
                    }
                }
            }

            IAgDrResult dpResult = null;

            switch (dpInfo.Type)
            {
            case AgEDataProviderType.eDrFixed:
                //Fixed data doesnt change over time
                IAgDataPrvFixed dpFixed = dataProvider as IAgDataPrvFixed;
                dpResult = dpFixed.Exec();
                break;

            case AgEDataProviderType.eDrIntvl:
                //Interval data is given as a list of intervals with start, stop and duration
                IAgDataPrvInterval dpInterval = dataProvider as IAgDataPrvInterval;
                //Must provide analysis start and stop time

                dpResult = dpInterval.Exec(startTime, stopTime);
                break;

            case AgEDataProviderType.eDrTimeVar:
                //Time varyign data is given as an array of time based values
                IAgDataPrvTimeVar dpTimeVarying = dataProvider as IAgDataPrvTimeVar;
                //Must provide analysis start and stop time plus an evaluation step size
                dpResult = dpTimeVarying.Exec(startTime, stopTime, stepSize);
                break;

            default:
                break;
            }

            Array dataValues = null;

            IAgDrDataSetCollection datasets = dpResult.DataSets;

            if (datasets.Count > 0)
            {
                IAgDrDataSet thisDataset = datasets.GetDataSetByName(ElementName);

                dataValues = thisDataset.GetValues();
            }
            return(dataValues);
        }