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; }
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; }