public IAgAircraft CreateAircraft(string seed, bool createSensor, double sensorFOV, double speedKnots)
        {
            string      aircraftName = uniqueName(seed, AgESTKObjectType.eAircraft);
            IAgAircraft aircraft     = root.CurrentScenario.Children.New(AgESTKObjectType.eAircraft, aircraftName) as IAgAircraft;

            root.ExecuteCommand("SetAttitude */Aircraft/" + aircraftName + " Profile AircraftCoordTurn 10");
            IAgVOModel acModel = aircraft.VO.Model;

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

            if (speedKnots < 200)
            {
                modelFile.Filename = installDir + @"STKData\VO\Models\Air\single_engine.mdl";
            }
            else if (speedKnots > 200 & speedKnots < 500)
            {
                modelFile.Filename = installDir + @"STKData\VO\Models\Air\uav.mdl";
            }
            else if (speedKnots > 300 & speedKnots < 500)
            {
                modelFile.Filename = installDir + @"STKData\VO\Models\Air\e-3a_sentry_awacs.mdl";
            }
            else if (speedKnots > 500 & speedKnots < 1200)
            {
                modelFile.Filename = installDir + @"STKData\VO\Models\Air\f-117a_nighthawk.mdl";
            }
            else
            {
                modelFile.Filename = installDir + @"STKData\VO\Models\Air\f-35_jsf_stovl.mdl";
            }

            if (createSensor)
            {
                IAgSensor sensor = ((IAgStkObject)aircraft).Children.New(AgESTKObjectType.eSensor, "Sensor_" + sensorFOV.ToString() + "deg") as IAgSensor;
                sensor.SetPatternType(AgESnPattern.eSnSimpleConic);
                AgSnSimpleConicPattern conic = sensor.Pattern as AgSnSimpleConicPattern;
                conic.ConeAngle = sensorFOV;
            }

            return(aircraft);
        }
示例#2
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
        }