bool Airspaces::SynchroniseInRange(const Airspaces& master, const GeoPoint &location, const fixed range, const AirspacePredicate &condition) { bool changed = false; const AirspaceVector contents_master = master.ScanRange(location, range, condition); AirspaceVector contents_self; contents_self.reserve(std::max(airspace_tree.size(), contents_master.size())); task_projection = master.task_projection; // ensure these are up to date for (const auto &v : airspace_tree) contents_self.push_back(v); // find items to add for (const auto &v : contents_master) { const AbstractAirspace* other = v.GetAirspace(); bool found = false; for (auto s = contents_self.begin(); s != contents_self.end(); ++s) { const AbstractAirspace* self = s->GetAirspace(); if (self == other) { found = true; contents_self.erase(s); break; } } if (!found && other->IsActive()) { Add(v.GetAirspace()); changed = true; } } // anything left in the self list are items that were not in the query, // so delete them --- including the clearances! for (auto v = contents_self.begin(); v != contents_self.end();) { bool found = false; for (auto t = airspace_tree.begin(); t != airspace_tree.end(); ) { if (t->GetAirspace() == v->GetAirspace()) { AirspaceTree::const_iterator new_t = t; ++new_t; airspace_tree.erase_exact(*t); t = new_t; found = true; } else { ++t; } } assert(found); v->ClearClearance(); v = contents_self.erase(v); changed = true; } if (changed) Optimise(); return changed; }
int mainprog(void) { int res=0; /* Initialisation des listes */ InitChListe(&PLCs); res=OpenDb(DBHOST,USER,PASS,DB); if (res<0) {Log(LOG_CRIT,"OpenDb (%d) : %s\n",res,MysqlErrorMsg);return(res);} else { Plc_count=GetPlcList(NULL,&CONTROLLERs); if (Plc_count<0) Log(LOG_CRIT,"Get Plc count error (%d) : %s\n",Plc_count,MysqlErrorMsg); else { if (Plc_count==0) Log(LOG_NOTICE,"There is no Plcs\n"); else Log(LOG_NOTICE,"There is : %d Plcs\n",Plc_count); } Tag_count=GetCount("select * from DEFINITION"); if (Tag_count<0) Log(LOG_CRIT,"Get Tag count error (%d) : %s\n",Tag_count,MysqlErrorMsg); else { if (Tag_count==0) Log(LOG_NOTICE,"There is no Tags\n"); else Log(LOG_NOTICE,"There is : %d Tags\n",Tag_count); } if ((Plc_count>0)&&(Tag_count>0)) { Tag_count=0; Plc_count=GetPlcList(&PLCs,&CONTROLLERs); if (PLCs.Count>0) { Log(LOG_NOTICE,"There is %d PLC to create\n",PLCs.Count); ELEMENT *elt=GetFirst(&PLCs); while (elt!=NULL) { PLC *plc=elt->Data; res=GetTag(plc); if (res>0) Tag_count+=res; else { if (res==0) Log(LOG_NOTICE,"(%s) there is no Tag for PLC : %s\n",MysqlErrorMsg,plc->PlcName); else Log(LOG_CRIT,"Get Tag error (%d) : %s for PLC : %s\n",res,MysqlErrorMsg,plc->PlcName); } Optimise(plc); elt=GetNext(&PLCs,elt); } } else Log(LOG_CRIT,"Get Plc error (%d) : %s\n",res,MysqlErrorMsg); // Appel Logger if (Tag_count>0) res=Logger(&PLCs); } else Log(LOG_WARNING,"There is nothing to do. exiting...\n"); CloseDb; } return(res); }
void ClothoidPath::OptimisePath( const CarModel& cm, int step, int nIterations, int bumpMod ) { const int NSEG = m_pTrack->GetSize(); for( int j = 0; j < nIterations; j++ ) { PathPt* l0 = 0; PathPt* l1 = &m_pPath[NSEG - 3 * step]; PathPt* l2 = &m_pPath[NSEG - 2 * step]; PathPt* l3 = &m_pPath[NSEG - step]; PathPt* l4 = &m_pPath[0]; PathPt* l5 = &m_pPath[step]; PathPt* l6 = &m_pPath[2 * step]; // go forwards int i = 3 * step; int n = (NSEG + step - 1) / step; for( int count = 0; count < n; count++ ) { l0 = l1; l1 = l2; l2 = l3; l3 = l4; l4 = l5; l5 = l6; l6 = &m_pPath[i]; int idx = (i + NSEG - 3 * step) % NSEG; int fIndex = m_factors.GetSize() * idx / NSEG; double factor = m_factors[fIndex]; if( bumpMod == 2 && l3->h > 0.1 ) OptimiseLine( cm, idx, step, 0.1, l3, l2, l4 ); else Optimise( cm, factor, idx, l3, l0, l1, l2, l4, l5, l6, bumpMod ); if( (i += step) >= NSEG ) i = 0;//i -= m_nSegs; } } // now smooth the values between steps if( step > 1 ) SmoothBetween( step ); }
void Waypoints::AddTakeoffPoint(const GeoPoint& location, const fixed terrain_alt) { // remove old one first const Waypoint *old_takeoff_point = LookupName(_T("(takeoff)")); if (old_takeoff_point != NULL) Erase(*old_takeoff_point); const Waypoint *nearest_landable = GetNearestLandable(location, fixed(5000)); if (!nearest_landable) { // now add new and update database Waypoint new_waypoint = GenerateTakeoffPoint(location, terrain_alt); Append(new_waypoint); } Optimise(); }
// example int main (int argc, char** argv) { if (argc!=3) { fprintf (stderr, "usage: optimise_road iterations learning_rate\n"); exit(-1); } int iter = atoi(argv[1]); float alpha = atof(argv[2]); TrackData track_data; SegmentList track; track_data.setStep(10.0f); float width_l = 9.0f; float width_r = 9.0f; track_data.setWidth(19.0f); track_data.AddStraight (track, 50.0, width_l, width_r); //1 track_data.AddCurve (track, 90.0, 100, width_l, width_r); //2 Optimise (track, iter, alpha); return 0; }
/* * Initialize the GUI interface for the plugin - this is only called once when the plugin is * added to the plugin registry in the QGIS application. */ void QRap::initGui() { mToolBarPointer = 0; printf("QRap::initGui\n"); mPoints.clear(); mMouseType = CLEAN; // Create the action for tool cout << "VOOR DataBase Connect" << endl; openDatabaseConnection(); cout << "Na DataBase Connect" << endl; cout << "Voor new Actions" << endl; mQActionPointer = new QAction(QIcon(":/qrap/Data.png"),tr("Q-Rap Database Interface"), this); mSiteAction = new QAction(QIcon(":/qrap/Site.png"),tr("Q-Rap: Place a Site"), this); mSelectSiteAction = new QAction(QIcon(":/qrap/SiteSelect.png"),tr("Q-Rap: Select a Site"), this); mDeleteSiteAction = new QAction(QIcon(":/qrap/SiteDelete.png"),tr("Q-Rap: Delete a Site"), this); mLinkAction = new QAction(QIcon(":/qrap/Link.png"),tr("Q-Rap: Link Analysis"), this); mSelectLinkAction = new QAction(QIcon(":/qrap/LinkSelect.png"),tr("Q-Rap: Select a Link"), this); mDeleteLinkAction = new QAction(QIcon(":/qrap/LinkDelete.png"),tr("Q-Rap: Delete a Link"), this); mMultiLinkAction = new QAction(QIcon(":/qrap/MultiLink.png"),tr("Q-Rap: Establish all Links possible in set of Sites"), this); mRadioAction = new QAction(QIcon(":/qrap/Coverage.png"),tr("Q-Rap: Perform a Prediction"), this); mMeasAnalysisAction = new QAction(QIcon(":/qrap/Measurements.png"),tr("Q-Rap: Compare measurements with predictions"), this); mSpectralAction = new QAction(QIcon(":/qrap/Spectral.png"),tr("Q-Rap: Perform Spectral Interference Analysis"), this); mPreferencesAction = new QAction(QIcon(":/qrap/Preferences.png"),tr("Q-Rap Preferences"), this); mOptimisationAction = new QAction(QIcon(":/qrap/Optimisation.png"),tr("Q-Rap: Optimise link structure in selected area"), this); // mImportExportAction = new QAction(QIcon(":/qrap/ImportExport.png"),tr("Import Export"),this); // mHelpAction = new QAction(QIcon(":/qrap/Help.png"),tr("Q-Rap Help"), this); cout << "Na new Actions" << endl; // Connect the action to the run connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run())); connect(mSiteAction, SIGNAL(activated()), this, SLOT(PlaceSite())); connect(mSelectSiteAction, SIGNAL(activated()), this, SLOT(SelectSite())); connect(mDeleteSiteAction, SIGNAL(activated()), this, SLOT(DeleteSite())); connect(mLinkAction, SIGNAL(activated()), this, SLOT(CreateLinkAnalysis())); connect(mDeleteLinkAction, SIGNAL(activated()), this, SLOT(DeleteLink())); connect(mMultiLinkAction, SIGNAL(activated()), this, SLOT(MultiLink())); connect(mSelectLinkAction, SIGNAL(activated()), this, SLOT(SelectLink())); connect(mRadioAction, SIGNAL(activated()), this, SLOT(Prediction())); connect(mMeasAnalysisAction, SIGNAL(activated()), this, SLOT(Measurements())); connect(mSpectralAction, SIGNAL(activated()), this, SLOT(SpectralAnalysis())); connect(mPreferencesAction, SIGNAL(activated()), this, SLOT(Preferences())); connect(mOptimisationAction, SIGNAL(activated()), this, SLOT(Optimise())); // connect(mImportExportAction,SIGNAL(activated()), this, SLOT(ImportExport())); // connect(mHelpAction,SIGNAL(activated()), this, SLOT(Help())); cout << "Na Connect" << endl; // Add the toolbar to the main window mToolBarPointer = mQGisIface->addToolBar(tr("Q-Rap")); mToolBarPointer->setIconSize(QSize(24,24)); mToolBarPointer->setObjectName("Q-Rap"); // Add the icon to the toolbar mToolBarPointer->addAction(mSiteAction); mToolBarPointer->addAction(mSelectSiteAction); mToolBarPointer->addAction(mDeleteSiteAction); mToolBarPointer->addAction(mLinkAction); mToolBarPointer->addAction(mSelectLinkAction); mToolBarPointer->addAction(mDeleteLinkAction); mToolBarPointer->addAction(mRadioAction); mToolBarPointer->addAction(mMultiLinkAction); mToolBarPointer->addAction(mMeasAnalysisAction); mToolBarPointer->addAction(mSpectralAction); mToolBarPointer->addAction(mOptimisationAction); mToolBarPointer->addAction(mPreferencesAction); mToolBarPointer->addAction(mQActionPointer); // mToolBarPointer->addAction(mImportExportAction); // mToolBarPointer->addAction(mHelpAction); mLoaded = true; // openDatabaseConnection(); // cout << "Na DataBase Connect" << endl; // mQGisIface->addToolBarIcon( mQActionPointer ); // mQGisIface->addPluginToMenu( tr( "Q-Rap Database" ), mQActionPointer ); Mouse = new MouseEvents(mQGisIface->mapCanvas()); cout << "Na Mouse" << endl; connect(Mouse, SIGNAL(RightPoint(QgsPoint&)), this, SLOT(ReceivedRightPoint(QgsPoint&))); connect(Mouse, SIGNAL(LeftPoint(QgsPoint&)), this, SLOT(ReceivedLeftPoint(QgsPoint&))); }