Пример #1
0
Route::Route( Airport from, Airport to ) {
    this->from = from.getPoint();
    this->from_id = from.getId();
    this->to = to.getPoint();
    this->to_id = to.getId();
    this->complete = false;
    this->parity = true;

    this->current = this->from;
    this->via_pacific = false;
    this->lon_range = fabs( this->from.y - this->to.y );
    this->sign = ( ( this->from.y - this->to.y ) > 0 ) ? -1 : 1;
    this->step_lon = 1.0f;

    this->lat1 = this->from.x * M_PI / 180;
    this->lat2 = this->to.x * M_PI / 180;
    
    // маршрут надо строить через тихий океан
    if ( ( ( this->lon_range ) > ( 360 - this->lon_range ) ) && ( this->from.y * this->to.y < 0 ) ) {
        this->via_pacific = true;
        this->sign *= -1;
        this->lon_range = 360 - this->lon_range;
        this->lon1 = ( ( this->from.y > 0 ) ? ( -180 + this->from.y ) : ( 180 + this->from.y ) ) * M_PI / 180;
        this->lon2 = ( ( this->to.y > 0 ) ? ( -180 + this->to.y ) : ( 180 + this->to.y ) ) * M_PI / 180;
        this->current = Vec2f( this->from.x, this->lon1 * 180 / M_PI );
    } else {
        this->lon1 = this->from.y * M_PI / 180;
        this->lon2 = this->to.y * M_PI / 180;
    }
    
    this->step_parity = 0;
    this->max_steps = round( lon_range / step_lon );
    this->steps = 0;
    this->step_cycle = 0;
}
Пример #2
0
int main()
{
	Airport test;
	test.Run();
	cout<<endl;
	return 0;
}
Пример #3
0
void AirportLoader::printResults(std::ostream& sout)
{
   Airport airport;
   Runway runway;
   Ils ils;
   for (int i = 0; i < nql; i++) {

      // print the AIRPORT record
      AirportKey* apk = static_cast<AirportKey*>(ql[i]);
      airport.setRecord( db->getRecord( apk->idx ) ) ;
      airport.printRecord(sout);

      // print the airport's RUNWAY records
      for (RunwayKey* rwk = apk->runways; rwk != 0; rwk = rwk->next) {

         runway.setRecord( dbGetRecord( rwk ) );
         sout << "Runway: ";
         runway.printRecord(sout);

         // print the runway's ILS records
         for (IlsKey* ilsk = rwk->ils; ilsk != 0; ilsk = ilsk->next) {
            ils.setRecord( dbGetRecord( ilsk ) );
            sout << "ILS:    ";
            ils.printRecord(sout);
         }

      }

   }
}
void WeatherParamSetupWidget::onAirportChanged(int index){
    disconnect(planeNameComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(onPlaneNameChanged(QString)));
    planeNameComboBox->clear();
    Airport airport = airportList[index];
    QStringList planeNameList = airport.planeName().split(",", QString::SkipEmptyParts);
    planeNameComboBox->addItems(planeNameList);
    connect(planeNameComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(onPlaneNameChanged(QString)));
    this->onPlaneNameChanged(planeNameList[0]);
}
void WeatherParamSetupWidget::initUI(){
    this->setWindowFlags(Qt::WindowCloseButtonHint);
    this->setFixedWidth(440);
    this->setFixedHeight(500);

    this->setWindowIcon(QIcon(":/images/weather_setup.png"));
    this->setWindowTitle("阀值设置");

    //设置机场
    airportComboBox = new QComboBox;
    airportComboBox->addItems(apNameList);
    //设置机型
    planeNameComboBox = new QComboBox;
    if(airportList.size() > 0){
        Airport airport = airportList[airportComboBox->currentIndex()];
        QStringList planeNameList = airport.planeName().split(",", QString::SkipEmptyParts);
        planeNameComboBox->addItems(planeNameList);
    }
    //设置标签
    tabWidget = new QTabWidget;
    tabWidget->setContentsMargins(5, 5, 5, 5);
    if(apNameList.size() > 0){
        multiWeatherParamWidget = new MultiWeatherParamWidget;
        multiWeatherParamWidget->onAirportChanged(apCodeList[airportComboBox->currentIndex()], planeNameComboBox->currentText());
        tabWidget->addTab(multiWeatherParamWidget, "多要素");
        singleWeatherParamWidget = new SingleWeatherParamWidget;
        singleWeatherParamWidget->onAirportChanged(apCodeList[airportComboBox->currentIndex()], planeNameComboBox->currentText());
        tabWidget->addTab(singleWeatherParamWidget, "单要素");
    }
    //布局
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(airportComboBox);
    mainLayout->addWidget(planeNameComboBox);
    mainLayout->addWidget(tabWidget);

    //设置上一步下一步按钮
    if(SharedMemory::isWelcome){
        previousButton = new QPushButton;
        previousButton->setText("上一步");

        nextButton = new QPushButton;
        nextButton->setText("下一步");

        QHBoxLayout *hlayout = new QHBoxLayout;
        hlayout->addWidget(previousButton);
        hlayout->addStretch();
        hlayout->addWidget(nextButton);

        mainLayout->addLayout(hlayout);
    }

    this->setLayout(mainLayout);
}
	RadarScreen::RadarScreen(Landmarks *Lands_i) :

		ATCScreen
			(
			RADAR_LEFT,
			RADAR_TOP,
			RADAR_LEFT + (MAX_FIELD_X  * POSITION_WIDTH),
			RADAR_TOP  + (MAX_FIELD_Y * POSITION_HEIGHT) - 1,
			ATC_TEXT_MODE,
			RADAR_TEXT_COLOUR,
			RADAR_BACK_COLOUR
			),
		AtLandmarks_c (True, 2),
		Gates_c (True, 2),
		FlightPaths_c (True, 2),
		AirportLights_c (True, 2)


		{
		int BeaconIx, AirportIx, GateIx, FltPthIx;

		AtLandmark *CrntAtLand;
		Airport *CrntAirport;
		Gate *CrntGate;
		FlightPath *CrntFltPth;

		for (BeaconIx = 0; BeaconIx < Lands_i->NoOfBeacons(); BeaconIx++)	{
			CrntAtLand = Lands_i->AllBeacons()[BeaconIx];

			AtLandmarks_c.Add (CrntAtLand, CrntAtLand->GrndPos());
		}

		for (AirportIx = 0; AirportIx < Lands_i->NoOfAirports(); AirportIx++){
			CrntAirport = Lands_i->AllAirports()[AirportIx];

			AtLandmarks_c.Add (CrntAirport, CrntAirport->GrndPos());
			AirportLights_c.Add (CrntAirport->GrndPos().NextMove
				(CrntAirport->Dir()));
		}

		for (GateIx = 0; GateIx < Lands_i->NoOfGates(); GateIx++)	{
			CrntGate = Lands_i->AllGates()[GateIx];

			Gates_c.Add (CrntGate);
		}

		for (FltPthIx = 0; FltPthIx < Lands_i->NoOfFlightPaths(); FltPthIx++){
			CrntFltPth = Lands_i->AllFlightPaths()[FltPthIx];

			FlightPaths_c.Add (CrntFltPth);
		}

	}
Пример #7
0
//------------------------------------------------------------------------------
// AirportLoader::AirportKey 
//------------------------------------------------------------------------------
AirportLoader::AirportKey::AirportKey(const long idx,
                  const Airport& airport) : Key(idx)
{
   size = AIRPORT_RECORD_LEN;
   airport.icaoCode(icao);
   airport.key(key);

   lat = airport.latitude();
   lon = airport.longitude();
   type = airport.airportType();

   runways = 0;
}
void WeatherParamSetupWidget::initData(){
    //初始化DB
    pgDb = new PgDataBase;
    //机场
    apCodeList.clear();
    apNameList.clear();
    airportList = SharedMemory::getInstance()->getAirportList();
    int airportCount = airportList.size();
    for(int i = 0;i < airportCount;i++){
        Airport airport = airportList[i];
        apCodeList.append(airport.code());
        apNameList.append(airport.name());
    }
}
bool ChartElemNavaids::addAirport(const Airport& airport,
                                  QDomElement& element, 
                                  QDomDocument& dom_doc,
                                  QString& err_msg)
{
    QString leaf_id = getLeafID(airport);

    // check for double entries
    if (containsLeaf(leaf_id)) 
    {
        err_msg = QString("Double Aiport entry detected: (%1)").arg(airport.getId());
        return false;
    }

    // process the AIRPORT

    ChartElemAirport* chart_elem_airport = new ChartElemAirport(this, m_chart_model, airport);
    MYASSERT(chart_elem_airport);

    if (!chart_elem_airport->loadFromDomElement(element, dom_doc, err_msg)) 
    {
        delete chart_elem_airport;
        return false;
    }

    addLeaf(leaf_id, chart_elem_airport);
    return true;
}
Пример #10
0
	ATCInput::ATCInput (Traffic *Traff_i, Landmarks *Lmarks_i) :

		//Screen initialisations
		ATCScreen
			(
			1,
			46,
			60,
			50,
			ATC_TEXT_MODE,
			BLACK,
			WHITE
			),
		CrntColumn_c (1),

		Traff_c (Traff_i),
		Gates_c (True),
		Airports_c (True),
		Beacons_c (True),
		NextProcess_c (&GetPlane),
		IsCmndToCollect_c (False),
		LastCmnd_c (NULL)
			{
		int GateIx, AirportIx, BeaconIx;
		Gate *CrntGate;
		Airport *CrntAirport;
		Beacon *CrntBeacon;


		for (GateIx = 0; GateIx < Lmarks_i->NoOfGates(); GateIx++)	{
			CrntGate = Lmarks_i->AllGates() [GateIx];

			Gates_c.Add (CrntGate, CrntGate->ID());
		}

		for (AirportIx = 0; AirportIx < Lmarks_i->NoOfAirports(); AirportIx++)	{
			CrntAirport = Lmarks_i->AllAirports() [AirportIx];

			Airports_c.Add (CrntAirport, CrntAirport->ID());
		}

		for (BeaconIx = 0; BeaconIx < Lmarks_i->NoOfBeacons(); BeaconIx++)	{
			CrntBeacon = Lmarks_i->AllBeacons() [BeaconIx];

			Beacons_c.Add (CrntBeacon, CrntBeacon->ID());
		}
	}
vector<Airport> LoadData::loadAirports(string nameFile) {
	// (1) fetch the waypoint vector of lines
	vector<vector<string> > airport = LoadData::loadFile(nameFile);

	// (2) add to the vector
	airports.clear();
	for (int unsigned i = 0; i < airport.size(); i++) {
		Airport *p;
		p = new Airport();
		try {
			p->setByStrings(airport[i]);
		} catch (InvalidStringsSizeException &a) {
			cout << nameFile << ", line " << i + 1 << ": invalid airport!";
		}
		LoadData::airports.push_back(*p);
	}
	return airports;
}
	CmndInput::CmndInput
		(
		Landmarks *Lmarks_i,
		Traffic *Traff_i
		) :

		Traff_c (Traff_i),
		IsCmndToCollect_c (False),
		LastCmnd_c (NULL)

			{
		int GateIx, AirportIx, BeaconIx;
		Gate *CrntGate;
		Airport *CrntAirport;
		Beacon *CrntBeacon;


		Out_c.Refresh();

		for (GateIx = 0; GateIx < Lmarks_i->NoOfGates(); GateIx++)	{
			CrntGate = Lmarks_i->AllGates() [GateIx];

			Landmarks_c.Gates.Add (CrntGate, CrntGate->ID());
		}

		for (AirportIx = 0; AirportIx < Lmarks_i->NoOfAirports(); AirportIx++)	{
			CrntAirport = Lmarks_i->AllAirports() [AirportIx];

			Landmarks_c.Airports.Add (CrntAirport, CrntAirport->ID());
		}

		for (BeaconIx = 0; BeaconIx < Lmarks_i->NoOfBeacons(); BeaconIx++)	{
			CrntBeacon = Lmarks_i->AllBeacons() [BeaconIx];

			Landmarks_c.Beacons.Add (CrntBeacon, CrntBeacon->ID());
		}
		SetForNewCmnd();

	}
Пример #13
0
void Airport::findRoute(const List <Airport> &cities, List <Flight> &route, 
                        const char *airline, const char *destination, 
                        bool *found) const
{
  int index; 
  Flight flight;

  if (strcmp(airport, destination) == 0)
  {
    strcpy(flight.airline, airline);
    strcpy(flight.destination, destination);
    route += flight;
    *found = true;
  }  // if reach destination
  else // haven't reached destination yet
  {
    for (int i = 0; i < flights.getCount(); i++)
    {
      if (strcmp(flights[i].airline, airline) == 0)
      {
        Airport city;
        city.setAirport(flights[i].destination);
  
        for (index = 0; index < cities.getCount(); index++)
          if (cities[index] == city)
            break;
      
        cities[index].findRoute(cities, route, airline, destination, found);
        
        if (*found)
        {
          strcpy(flight.destination, airport);
          strcpy(flight.airline, airline);
          route += flight;
        }  // if found destination
      } // if found match of airline
    }  // for each flight from the airport
  } // else haven't reached destination yet
}  // findRoute())
Пример #14
0
Airport normalize(Airport a){
	double q = 3.0;
	Airport normalized = Airport(a.getID(), (a.getX()-avgX)/q, (a.getY()-avgY)/q, a.getZ(), a.getName());
	normalized.setDegree(a.getDegree());
	return normalized;
}
void ModelA::fly(const Airport &destination)//子类必须实现父类的pure virtual函数.
{
	cout<<"ModelA::fly to"<<destination.getPortName()<<endl;
}
void Airplane::defaultFly(const Airport& dst_airport) {
	std::cout << "defaultFly dst_airport:" << dst_airport.name() << std::endl;
}
Пример #17
0
void Airplane::fly(const Airport& destination)
{
    cout << "Airplane::fly... : " << destination.get_dest() << endl;
}
Пример #18
0
void drawAirports(){
	for(vector<Airport>::iterator it = nodes.begin(); it != nodes.end(); it++){
		if(it->getSelected()){
			Airport normalized = normalize(*it);
			GLfloat color[4] = {normalized.getDegree()/258.0, 1.0-normalized.getDegree()/258.0, 0.0f, 1.0f};
			if(!drawColor){
				color[0] = 0.0;
				color[1] = 0.0;
			}
			//drawCircle(normalized.getX(), normalized.getY(), normalized.getZ(), normalized.getDegree()/150.0 + 0.5, color);
			drawSphere(normalized.getX(), normalized.getY(), normalized.getZ(), normalized.getDegree()/150.0 + 0.5, color);
		} else{
			Airport normalized = normalize(*it);
			GLfloat color[4] = {normalized.getDegree()/258.0, 1.0-normalized.getDegree()/258.0, 0.0f, 1.0f};
			if(!drawColor){
				color[0] = 0.0;
				color[1] = 0.0;
			}
			//drawCircle(normalized.getX(), normalized.getY(), normalized.getZ(), normalized.getDegree()/150.0 + 0.5, color);
			drawSphere(normalized.getX(), normalized.getY(), normalized.getZ(), normalized.getDegree()/150.0 + 0.5, color);
		}
	}
}
void Airplane::fly(const Airport & destination)//父类中的pure virtual函数自己的实现
{
	cout<<destination.getPortName()<<endl;
}
/**********************************************************************
 * main description
 * Creates an Airport object. Prompts user for length of simulation and
 * arrivals/takeoffs per time unit. Uses a "random" number to cycle through
 * the time units and simulate airports landing and taking off. Results
 * are then displayed. 
 ***********************************************************************/
int main()
{
   int simLength;
   float arrivalPerTime;
   float takeOffPerTime;
   Random RandomGenerator;
   int random1;
   int random2;
   Airport laGuardia;


   //User prompts with validation
   cout << "Units of time the simulation will run: ";
   cin >> simLength;

   while (cin.fail())
   {
      cin.clear();
      cin.ignore(80,'\n');
      cout << "Invalid Input. Re Enter: ";
      cin >> simLength;
   }

   cout << "Expected number of arrivals per time unit: ";
   cin >> arrivalPerTime;

   while (cin.fail() || arrivalPerTime > 1)
   {
      cin.clear();
      cin.ignore(80,'\n');
      cout << "Invalid Input. Value must be between 0 and 1. Re Enter: ";
      cin >> arrivalPerTime;
   }
   
      
   cout << "Expected number of take offs per time unit: ";
   cin >> takeOffPerTime;

   while (cin.fail() || 1 - arrivalPerTime < takeOffPerTime)
   {
      cin.clear();
      cin.ignore(80,'\n');
      cout << "Invalid Input. Value must complement previous value. "
           <<"Re Enter: ";
      cin >> takeOffPerTime;
   }


   // Airport Operations
   for (int i = 0; i < simLength; i++)
   {
      random1 = RandomGenerator.poissonRandom(arrivalPerTime);
      for (int j = 0; j < random1; j++)
      {
         Airplane *plane = new Airplane;
         if (laGuardia.landing.full())
         {
            laGuardia.planesRefused++;
            laGuardia.planesProcessed++;
         }
         else
         {
            laGuardia.landing.insert(*plane);
            laGuardia.planesProcessed++;
         }
        
         delete plane;
      }
      
      random2 = RandomGenerator.poissonRandom(takeOffPerTime);
      for (int k = 0; k < random2; k++)
      {    
         Airplane *plane2 = new Airplane;
         if (laGuardia.takeOff.full())
         {
            laGuardia.planesRefused++;
            laGuardia.planesProcessed++;
         }
         else
         {
            laGuardia.takeOff.insert(*plane2);
            laGuardia.planesProcessed++;
         }
         delete plane2;
      }

      if (!laGuardia.landing.empty())
      {
         laGuardia.landing.remove();
         laGuardia.planesLanded++;
       
         if (!laGuardia.landing.empty())
            laGuardia.sumLandWaitTime += laGuardia.landing.getItems();
         if (!laGuardia.takeOff.empty())
            laGuardia.sumTakeOffWaitTime += laGuardia.takeOff.getItems();
             
      }
      else if (!laGuardia.takeOff.empty())
      {
         laGuardia.takeOff.remove();
         laGuardia.planesTakenOff++;

         if (!laGuardia.takeOff.empty())
            laGuardia.sumTakeOffWaitTime += laGuardia.takeOff.getItems();
      }
      else
         laGuardia.runwayIdleTime++;
   }

   //calculations
   laGuardia.rdyLand = laGuardia.landing.getItems();
   laGuardia.rdyTakeOff = laGuardia.takeOff.getItems();
   
   
   laGuardia.avgWaitLand = (float)(laGuardia.sumLandWaitTime -
   laGuardia.rdyLand)  / (float)laGuardia.planesLanded;
   
   laGuardia.avgWaitTakeOff = (float)(laGuardia.sumTakeOffWaitTime -
   laGuardia.rdyTakeOff) / (float)laGuardia.planesTakenOff;
   
   laGuardia.percentIdle = (float)laGuardia.runwayIdleTime / (float)simLength
   * 100;
   
   cout << endl;
   
   //display
   laGuardia.displayOperations();
   
   return 0;
}
void ModelB::fly(const Airport &destination)
{
	cout<<"ModelB::fly to"<<destination.getPortName()<<endl;
}
Пример #22
0
    virtual void fly(const Airport& destination)
    {
	cout << "ModelC fly... : " << destination.get_dest() << endl;
    }