Beispiel #1
0
        public static List <AgELeadTrailData> GetLeadTrailData(string objectPath, string className)
        {
            List <AgELeadTrailData> leadTrailData = new List <AgELeadTrailData>();

            if (className == "Satellite")
            {
                IAgSatellite mySat = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgSatellite;
                leadTrailData.Add(mySat.VO.Pass.TrackData.PassData.Orbit.LeadDataType);
                leadTrailData.Add(mySat.VO.Pass.TrackData.PassData.Orbit.TrailDataType);
                leadTrailData.Add(mySat.Graphics.PassData.GroundTrack.LeadDataType);
                leadTrailData.Add(mySat.Graphics.PassData.GroundTrack.TrailDataType);
            }
            else if (className == "Aircraft")
            {
                IAgAircraft myAircraft = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgAircraft;
                leadTrailData.Add(myAircraft.VO.Route.TrackData.LeadDataType);
                leadTrailData.Add(myAircraft.VO.Route.TrackData.TrailDataType);
                leadTrailData.Add(myAircraft.Graphics.PassData.Route.LeadDataType);
                leadTrailData.Add(myAircraft.Graphics.PassData.Route.TrailDataType);
            }
            else if (className == "Missile")
            {
                IAgMissile myMissile = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgMissile;
                leadTrailData.Add(myMissile.VO.Trajectory.TrackData.PassData.Trajectory.LeadDataType);
                leadTrailData.Add(myMissile.VO.Trajectory.TrackData.PassData.Trajectory.TrailDataType);
                leadTrailData.Add(myMissile.Graphics.PassData.Trajectory.LeadDataType);
                leadTrailData.Add(myMissile.Graphics.PassData.Trajectory.TrailDataType);
            }
            else if (className == "GroundVehicle")
            {
                IAgGroundVehicle myGv = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgGroundVehicle;
                leadTrailData.Add(myGv.VO.Route.TrackData.LeadDataType);
                leadTrailData.Add(myGv.VO.Route.TrackData.TrailDataType);
                leadTrailData.Add(myGv.Graphics.PassData.Route.LeadDataType);
                leadTrailData.Add(myGv.Graphics.PassData.Route.TrailDataType);
            }
            else if (className == "Ship")
            {
                IAgShip myShip = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgShip;
                leadTrailData.Add(myShip.VO.Route.TrackData.LeadDataType);
                leadTrailData.Add(myShip.VO.Route.TrackData.TrailDataType);
                leadTrailData.Add(myShip.Graphics.PassData.Route.LeadDataType);
                leadTrailData.Add(myShip.Graphics.PassData.Route.TrailDataType);
            }
            else if (className == "LaunchVehicle")
            {
                IAgLaunchVehicle myLv = CommonData.StkRoot.GetObjectFromPath(objectPath) as IAgLaunchVehicle;
                leadTrailData.Add(myLv.VO.Trajectory.TrackData.PassData.Trajectory.LeadDataType);
                leadTrailData.Add(myLv.VO.Trajectory.TrackData.PassData.Trajectory.TrailDataType);
                leadTrailData.Add(myLv.Graphics.PassData.GroundTrack.LeadDataType);
                leadTrailData.Add(myLv.Graphics.PassData.GroundTrack.TrailDataType);
            }
            else
            {
            }

            return(leadTrailData);
        }
 private void PopulateDisplayReports(ComboBox box, ComboBox ddObject)
 {
     if (ddObject.SelectedIndex != -1)
     {
         string className = SmartViewFunctions.GetClassName(ddObject.Text);
         IAgVODataDisplayCollection ddCollection = null;
         if (className == "Satellite")
         {
             IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgSatellite;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Aircraft")
         {
             IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgAircraft;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Facility")
         {
             IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgFacility;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Missile")
         {
             IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgMissile;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "GroundVehicle")
         {
             IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgGroundVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "LaunchVehicle")
         {
             IAgLaunchVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgLaunchVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Place")
         {
             IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgPlace;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Target")
         {
             IAgTarget myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + ddObject.Text) as IAgTarget;
             ddCollection = myObject.VO.DataDisplays;
         }
         box.Items.Clear();
         Array reportNames = ddCollection.AvailableData;
         foreach (var name in reportNames)
         {
             box.Items.Add(name);
         }
         box.SelectedIndex = 0;
     }
 }
Beispiel #3
0
        public static void SetLeadTrailData(ObjectData stkObject)
        {
            List <string> leadTrailData = new List <string>();

            if (stkObject.ClassName == "Satellite")
            {
                IAgSatellite mySat = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgSatellite;
                mySat.VO.Pass.TrackData.PassData.Orbit.SetLeadDataType(stkObject.LeadSetting3D);
                mySat.VO.Pass.TrackData.PassData.Orbit.SetTrailDataType(stkObject.TrailSetting3D);
                mySat.Graphics.PassData.GroundTrack.SetLeadDataType(stkObject.LeadSetting2D);
                mySat.Graphics.PassData.GroundTrack.SetTrailDataType(stkObject.TrailSetting2D);
            }
            else if (stkObject.ClassName == "Aircraft")
            {
                IAgAircraft myAircraft = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgAircraft;
                myAircraft.VO.Route.TrackData.SetLeadDataType(stkObject.LeadSetting3D);
                myAircraft.VO.Route.TrackData.SetTrailDataType(stkObject.TrailSetting3D);
                myAircraft.Graphics.PassData.Route.SetLeadDataType(stkObject.LeadSetting2D);
                myAircraft.Graphics.PassData.Route.SetTrailDataType(stkObject.TrailSetting2D);
            }
            else if (stkObject.ClassName == "Missile")
            {
                IAgMissile myMissile = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgMissile;
                myMissile.VO.Trajectory.TrackData.PassData.Trajectory.SetLeadDataType(stkObject.LeadSetting3D);
                myMissile.VO.Trajectory.TrackData.PassData.Trajectory.SetTrailDataType(stkObject.TrailSetting3D);
                myMissile.Graphics.PassData.Trajectory.SetLeadDataType(stkObject.LeadSetting2D);
                myMissile.Graphics.PassData.Trajectory.SetTrailDataType(stkObject.TrailSetting2D);
            }
            else if (stkObject.ClassName == "GroundVehicle")
            {
                IAgGroundVehicle myGv = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgGroundVehicle;
                myGv.VO.Route.TrackData.SetLeadDataType(stkObject.LeadSetting3D);
                myGv.VO.Route.TrackData.SetTrailDataType(stkObject.TrailSetting3D);
                myGv.Graphics.PassData.Route.SetLeadDataType(stkObject.LeadSetting2D);
                myGv.Graphics.PassData.Route.SetTrailDataType(stkObject.TrailSetting2D);
            }
            else if (stkObject.ClassName == "Ship")
            {
                IAgShip myShip = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgShip;
                myShip.VO.Route.TrackData.SetLeadDataType(stkObject.LeadSetting3D);
                myShip.VO.Route.TrackData.SetTrailDataType(stkObject.TrailSetting3D);
                myShip.Graphics.PassData.Route.SetLeadDataType(stkObject.LeadSetting2D);
                myShip.Graphics.PassData.Route.SetTrailDataType(stkObject.TrailSetting2D);
            }
            else if (stkObject.ClassName == "LaunchVehicle")
            {
                IAgLaunchVehicle myLv = CommonData.StkRoot.GetObjectFromPath(stkObject.SimplePath) as IAgLaunchVehicle;
                myLv.VO.Trajectory.TrackData.PassData.Trajectory.SetLeadDataType(stkObject.LeadSetting3D);
                myLv.VO.Trajectory.TrackData.PassData.Trajectory.SetTrailDataType(stkObject.TrailSetting3D);
                myLv.Graphics.PassData.GroundTrack.SetLeadDataType(stkObject.LeadSetting2D);
                myLv.Graphics.PassData.GroundTrack.SetTrailDataType(stkObject.TrailSetting2D);
            }
        }
Beispiel #4
0
 private void DisplayObject_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (DisplayObject.SelectedIndex != -1)
     {
         string className = SmartViewFunctions.GetClassName(DisplayObject.Text);
         IAgVODataDisplayCollection ddCollection = null;
         if (className == "Satellite")
         {
             IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgSatellite;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Aircraft")
         {
             IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgAircraft;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "Facility")
         {
             IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgFacility;
             ddCollection = myObject.VO.DataDisplays;
         }
         else if (className == "Missile")
         {
             IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgMissile;
             ddCollection = myObject.VO.DataDisplay;
         }
         else if (className == "GroundVehicle")
         {
             IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(className + "/" + DisplayObject.Text) as IAgGroundVehicle;
             ddCollection = myObject.VO.DataDisplay;
         }
         DisplayReport.Items.Clear();
         Array reportNames = ddCollection.AvailableData;
         foreach (var name in reportNames)
         {
             DisplayReport.Items.Add(name);
             if (name.ToString() == CommonData.SavedViewList[CommonData.SelectedIndex].DataDisplayReportName)
             {
                 DisplayReport.SelectedIndex = DisplayReport.Items.Count - 1;
             }
         }
         if (DisplayReport.SelectedIndex == -1)
         {
             DisplayReport.SelectedIndex = 0;
         }
     }
 }
Beispiel #5
0
        public static IAgVORefCrdnCollection GetRefCrdns(IAgStkObject stkObject)
        {
            switch (stkObject.ClassType)
            {
            case AgESTKObjectType.eAircraft:
                IAgAircraft _aircraft = stkObject as IAgAircraft;
                return(_aircraft.VO.Vector.RefCrdns);

            case AgESTKObjectType.eFacility:
                IAgFacility fac = stkObject as IAgFacility;
                return(fac.VO.Vector.RefCrdns);

            case AgESTKObjectType.eGroundVehicle:
                IAgGroundVehicle gv = stkObject as IAgGroundVehicle;
                return(gv.VO.Vector.RefCrdns);

            case AgESTKObjectType.eMissile:
                IAgMissile miss = stkObject as IAgMissile;
                return(miss.VO.Vector.RefCrdns);

            case AgESTKObjectType.ePlace:
                IAgPlace place = stkObject as IAgPlace;
                return(place.VO.Vector.RefCrdns);

            case AgESTKObjectType.eSatellite:
                IAgSatellite sat = stkObject as IAgSatellite;
                return(sat.VO.Vector.RefCrdns);

            case AgESTKObjectType.eSensor:
                IAgSensor sensor = stkObject as IAgSensor;
                return(sensor.VO.Vector.RefCrdns);

            case AgESTKObjectType.eShip:
                IAgShip ship = stkObject as IAgShip;
                return(ship.VO.Vector.RefCrdns);

            case AgESTKObjectType.eTarget:
                IAgTarget target = stkObject as IAgTarget;
                return(target.VO.Vector.RefCrdns);

            default:
                return(null);
            }
        }
        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);
        }
        private void AddRoute(MyWaypoint startPoint, MyWaypoint endPoint, string gvName)
        {
            List <MyWaypoint> routePoints = GetRoute(startPoint, endPoint);

            // create new GV and add the waypoints
            if (m_root.CurrentScenario.Children.Contains(AgESTKObjectType.eGroundVehicle, gvName))
            {
                MessageBox.Show(gvName + " already exists, please pick a different name");
            }
            else
            {
                if (routePoints != null && routePoints.Count > 0)
                {
                    double turnRadius  = 2.0;   // meter
                    double granularity = 1.1;   // meter

                    m_root.UnitPreferences.SetCurrentUnit("Distance", "m");

                    switch (speedUnitsComboBox.SelectedItem.ToString())
                    {
                    case "km/h":
                        //m_root.UnitPreferences.SetCurrentUnit("Distance", "km");
                        m_root.UnitPreferences.SetCurrentUnit("Time", "hr");
                        //turnRadius /= 1000.0;
                        //granularity /= 1000.0;
                        speedUnitMultiplier = 1000.0;
                        break;

                    case "mph":
                        //m_root.UnitPreferences.SetCurrentUnit("Distance", "mi");
                        m_root.UnitPreferences.SetCurrentUnit("Time", "hr");
                        //turnRadius /= 1609.44;
                        //granularity /= 1609.44;
                        speedUnitMultiplier = 1609.44;
                        break;

                    case "m/s":
                        //m_root.UnitPreferences.SetCurrentUnit("Distance", "m");
                        m_root.UnitPreferences.SetCurrentUnit("Time", "sec");
                        speedUnitMultiplier = 1.0;
                        break;
                    }

                    switch (altUnitsComboBox.SelectedItem.ToString())
                    {
                    case "m":
                        altUnitMultiplier = 1.0;
                        break;

                    case "km":
                        altUnitMultiplier = 1000.0;
                        break;

                    case "ft":
                        altUnitMultiplier = 0.3048;
                        break;
                    }


                    IAgStkObject     gvObject = m_root.CurrentScenario.Children.New(AgESTKObjectType.eGroundVehicle, gvName);
                    IAgGroundVehicle gv       = gvObject as IAgGroundVehicle;

                    gv.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
                    IAgVePropagatorGreatArc prop = gv.Route as IAgVePropagatorGreatArc;

                    foreach (MyWaypoint thisPt in routePoints)
                    {
                        IAgVeWaypointsElement thisVeWaypoint = prop.Waypoints.Add();
                        thisVeWaypoint.Latitude   = thisPt.Latitude;
                        thisVeWaypoint.Longitude  = thisPt.Longitude;
                        thisVeWaypoint.Altitude   = thisPt.Altitude * altUnitMultiplier;
                        thisVeWaypoint.Speed      = Convert.ToDouble(speedTextBox.Text) * speedUnitMultiplier;
                        thisVeWaypoint.TurnRadius = turnRadius;
                    }

                    if (terrainCheckBox.Checked)
                    {
                        prop.SetAltitudeRefType(AgEVeAltitudeRef.eWayPtAltRefTerrain);
                        IAgVeWayPtAltitudeRefTerrain altRef = prop.AltitudeRef as IAgVeWayPtAltitudeRefTerrain;
                        altRef.Granularity  = granularity;
                        altRef.InterpMethod = AgEVeWayPtInterpMethod.eWayPtEllipsoidHeight;
                    }

                    prop.Propagate();
                }
            }
        }
Beispiel #8
0
        public static void SetObjectVisibility(ObjectData objectData)
        {
            string className  = objectData.ClassName;
            string simplePath = objectData.SimplePath;

            if (className == "Satellite")
            {
                IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSatellite;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Aircraft")
            {
                IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAircraft;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Facility")
            {
                IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFacility;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Missile")
            {
                IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgMissile;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "GroundVehicle")
            {
                IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgGroundVehicle;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Sensor")
            {
                IAgSensor myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSensor;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Transmitter")
            {
                IAgTransmitter myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgTransmitter;
                //Try/Catch for when object above it is already turned off
                try
                {
                    if (objectData.HideShow)
                    {
                        myObject.Graphics.Show = true;
                    }
                    else
                    {
                        myObject.Graphics.Show = false;
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (className == "Receiver")
            {
                IAgReceiver myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgReceiver;
                //Try/Catch for when object above it is already turned off
                try
                {
                    if (objectData.HideShow)
                    {
                        myObject.Graphics.Show = true;
                    }
                    else
                    {
                        myObject.Graphics.Show = false;
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (className == "CoverageDefinition")
            {
                IAgCoverageDefinition myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCoverageDefinition;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "FigureOfMerit")
            {
                IAgFigureOfMerit myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFigureOfMerit;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "CommSystem")
            {
                IAgCommSystem myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCommSystem;
                if (objectData.HideShow)
                {
                    myObject.Graphics.Show = true;
                }
                else
                {
                    myObject.Graphics.Show = false;
                }
            }
            else if (className == "Chain")
            {
                IAgChain myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgChain;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "Place")
            {
                IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgPlace;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
            else if (className == "AreaTarget")
            {
                IAgAreaTarget myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAreaTarget;
                if (objectData.HideShow)
                {
                    myObject.Graphics.IsObjectGraphicsVisible = true;
                }
                else
                {
                    myObject.Graphics.IsObjectGraphicsVisible = false;
                }
            }
        }
Beispiel #9
0
        public static bool GetObjectVisibility(string className, string simplePath)
        {
            bool visible = false;

            if (className == "Satellite")
            {
                IAgSatellite myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSatellite;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Aircraft")
            {
                IAgAircraft myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAircraft;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Facility")
            {
                IAgFacility myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFacility;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Missile")
            {
                IAgMissile myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgMissile;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "GroundVehicle")
            {
                IAgGroundVehicle myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgGroundVehicle;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Sensor")
            {
                IAgSensor myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgSensor;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Transmitter")
            {
                IAgTransmitter myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgTransmitter;
                visible = myObject.Graphics.Show;
            }
            else if (className == "Receiver")
            {
                IAgReceiver myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgReceiver;
                visible = myObject.Graphics.Show;
            }
            else if (className == "CoverageDefinition")
            {
                IAgCoverageDefinition myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCoverageDefinition;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "FigureOfMerit")
            {
                IAgFigureOfMerit myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgFigureOfMerit;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "CommSystem")
            {
                IAgCommSystem myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgCommSystem;
                visible = myObject.Graphics.Show;
            }
            else if (className == "Chain")
            {
                IAgChain myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgChain;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "Place")
            {
                IAgPlace myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgPlace;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }
            else if (className == "AreaTarget")
            {
                IAgAreaTarget myObject = CommonData.StkRoot.GetObjectFromPath(simplePath) as IAgAreaTarget;
                visible = myObject.Graphics.IsObjectGraphicsVisible;
            }

            return(visible);
        }
Beispiel #10
0
        // old method

        /*    public List<MyWaypoint> CreateRoute(MyWaypoint startPoint, MyWaypoint endPoint)
         *  {
         *      // create route from waypointString
         *      RouteRequest routeRequest = new RouteRequest();
         *
         *      // Set the credentials using a valid Bing Maps key
         *      routeRequest.Credentials = new BingRouteService.Credentials();
         *      routeRequest.Credentials.ApplicationId = m_bingMapKey;
         *
         *      // tell them that we want points along the route
         *      routeRequest.Options = new RouteOptions();
         *      routeRequest.Options.RoutePathType = RoutePathType.Points;
         *
         *      //Parse user data to create array of waypoints
         *      BingRouteService.Waypoint[] waypoints = new BingRouteService.Waypoint[2];
         *
         *      BingRouteService.Waypoint point1 = new BingRouteService.Waypoint();
         *      BingRouteService.Location location1 = new BingRouteService.Location();
         *      location1.Latitude = startPoint.Latitude;
         *      location1.Longitude = startPoint.Longitude;
         *      point1.Location = location1;
         *      point1.Description = "Start";
         *      waypoints[0] = point1;
         *
         *      BingRouteService.Waypoint point2 = new BingRouteService.Waypoint();
         *      BingRouteService.Location location2 = new BingRouteService.Location();
         *      location2.Latitude = endPoint.Latitude;
         *      location2.Longitude = endPoint.Longitude;
         *      point2.Location = location2;
         *      point2.Description = "End";
         *      waypoints[1] = point2;
         *
         *      routeRequest.Waypoints = waypoints;
         *
         *      // Make the calculate route request
         *      RouteServiceClient routeService = new RouteServiceClient("BasicHttpBinding_IRouteService");
         *      RouteResponse routeResponse = routeService.CalculateRoute(routeRequest);
         *
         *      // pull out the lat/lon values
         *      List<MyWaypoint> returnPoints = new List<MyWaypoint>();
         *      if (routeResponse.Result.Legs.Length > 0)
         *      {
         *          //MessageBox.Show("Distance: " + routeResponse.Result.Summary.Distance.ToString()
         *          //    + " Time: " + routeResponse.Result.Summary.TimeInSeconds.ToString());
         *          foreach (BingRouteService.Location thisPt in routeResponse.Result.RoutePath.Points)
         *          {
         *              MyWaypoint thisPoint = new MyWaypoint();
         *
         *              thisPoint.Latitude = thisPt.Latitude;
         *              thisPoint.Longitude = thisPt.Longitude;
         *              //thisPoint.Altitude = GetAltitude(thisPoint.Latitude, thisPoint.Longitude);
         *              thisPoint.Altitude = 0.0;
         *
         *              returnPoints.Add(thisPoint);
         *          }
         *      }
         *
         *      return returnPoints;
         *  } */

        public void PopulateGvRoute(string gvName, List <Directions.MyWaypoint> routePoints,
                                    double speedValue, string speedUnits, bool useTerrain)
        {
            //MessageBox.Show($"Populate GvRoute method called! Name is {gvName}");// FOR DEBUGGING PURPOSES
            double turnRadius  = 15.0;  // meter
            double granularity = 100;   // meter

            switch (speedUnits)
            {
            case "km/h":
                m_root.UnitPreferences.SetCurrentUnit("Distance", "km");
                m_root.UnitPreferences.SetCurrentUnit("Time", "hr");
                turnRadius  /= 1000.0;
                granularity /= 1000.0;
                break;

            case "mph":
                m_root.UnitPreferences.SetCurrentUnit("Distance", "mi");
                m_root.UnitPreferences.SetCurrentUnit("Time", "hr");
                turnRadius  /= 1609.44;
                granularity /= 1609.44;
                break;

            case "m/s":
                m_root.UnitPreferences.SetCurrentUnit("Distance", "m");
                m_root.UnitPreferences.SetCurrentUnit("Time", "sec");
                break;
            }


            IAgStkObject     gvObject = m_root.CurrentScenario.Children.New(AgESTKObjectType.eGroundVehicle, gvName);
            IAgGroundVehicle gv       = gvObject as IAgGroundVehicle;

            gv.Graphics.WaypointMarker.IsWaypointMarkersVisible = false;
            //gv.Graphics.WaypointMarker.IsTurnMarkersVisible = false;
            IAgVOModel gvModel = gv.VO.Model;

            gvModel.ModelType = AgEModelType.eModelFile;
            IAgVOModelFile modelFile = gvModel.ModelData as IAgVOModelFile;

            if (File.Exists(installDir + @"Plugins\GreatArcPlugin\Model\mercslk.mdl"))
            {
                modelFile.Filename = installDir + @"Plugins\GreatArcPlugin\Model\mercslk.mdl";
            }

            gv.VO.Route.InheritTrackDataFrom2D = true;

            gv.SetRouteType(AgEVePropagatorType.ePropagatorGreatArc);
            IAgVePropagatorGreatArc prop = gv.Route as IAgVePropagatorGreatArc;

            foreach (Directions.MyWaypoint thisPt in routePoints)
            {
                IAgVeWaypointsElement thisVeWaypoint = prop.Waypoints.Add();
                thisVeWaypoint.Latitude  = thisPt.Latitude;
                thisVeWaypoint.Longitude = thisPt.Longitude;
                thisVeWaypoint.Altitude  = thisPt.Altitude;

                thisVeWaypoint.Speed      = speedValue;
                thisVeWaypoint.TurnRadius = turnRadius;
            }

            if (useTerrain)
            {
                prop.SetAltitudeRefType(AgEVeAltitudeRef.eWayPtAltRefTerrain);
                IAgVeWayPtAltitudeRefTerrain altRef = prop.AltitudeRef as IAgVeWayPtAltitudeRefTerrain;
                altRef.Granularity  = granularity;
                altRef.InterpMethod = AgEVeWayPtInterpMethod.eWayPtTerrainHeight;
            }

            prop.Propagate();
            //MessageBox.Show("GV route propagated!");// FOR DEBUGGING PURPOSES
        }