X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Ftestgps.cxx;h=a35012f4bb144a603033f6fc959fdb777e0c37e7;hb=a9a1734f1e1d8e2e4f52309a5965624704385c8a;hp=cc73bded0efbb8468fee3a78dff97603eb7e76c3;hpb=34bbc6d974423aac314f4576b3a8a015b045e4ff;p=flightgear.git diff --git a/src/Instrumentation/testgps.cxx b/src/Instrumentation/testgps.cxx index cc73bded0..a35012f4b 100644 --- a/src/Instrumentation/testgps.cxx +++ b/src/Instrumentation/testgps.cxx @@ -1,4 +1,9 @@ +#include + +#include +#include + #include
#include
#include
@@ -6,8 +11,12 @@ #include #include #include +#include +#include +#include using std::string; +using namespace flightgear; char *homedir = ::getenv( "HOME" ); char *hostname = ::getenv( "HOSTNAME" ); @@ -45,6 +54,16 @@ void printScratch(SGPropertyNode* scratch) } } +void printRoute(const WayptVec& aRoute) +{ + SG_LOG(SG_GENERAL, SG_INFO, "route size=" << aRoute.size()); + for (unsigned int r=0; rident() << " " + << w->owner()->ident()); + } +} + void createDummyRoute(FGRouteMgr* rm) { SGPropertyNode* rmInput = fgGetNode("/autopilot/route-manager/input", true); @@ -59,6 +78,8 @@ void createDummyRoute(FGRouteMgr* rm) int main(int argc, char* argv[]) { + +try{ globals = new FGGlobals; fgInitFGRoot(argc, argv); @@ -69,6 +90,9 @@ int main(int argc, char* argv[]) fgInitNav(); + fgSetDouble("/environment/magnetic-variation-deg", 0.0); + + Airway::load(); SG_LOG(SG_GENERAL, SG_ALERT, "hello world!"); @@ -94,12 +118,15 @@ int main(int argc, char* argv[]) // globals->add_subsystem("environment", envMgr); // envMgr->init(); + fgSetBool("/sim/realism/simple-gps", true); + + // _realismSimpleGps SGPropertyNode* nd = fgGetNode("/instrumentation/gps", true); GPS* gps = new GPS(nd); globals->add_subsystem("gps", gps); - - + + const FGAirport* egph = fgFindAirportID("EGPH"); testSetPosition(egph->geod()); // startup the route manager @@ -116,6 +143,7 @@ int main(int argc, char* argv[]) // update a few times gps->update(0.05); gps->update(0.05); + gps->update(0.05); scratch->setStringValue("query", "TL"); scratch->setStringValue("type", "Vor"); @@ -221,7 +249,105 @@ int main(int argc, char* argv[]) nd->setStringValue("command", "define-user-wpt"); printScratch(scratch); +// airways + FGPositioned::TypeFilter vorFilt(FGPositioned::VOR); + FGPositionedRef tla = FGPositioned::findClosestWithIdent("TLA", pos, &vorFilt); + FGPositionedRef big = FGPositioned::findClosestWithIdent("BIG", pos, &vorFilt); + FGPositionedRef pol = FGPositioned::findClosestWithIdent("POL", pos, &vorFilt); + + const FGAirport* eddm = fgFindAirportID("EDDM"); + FGPositionedRef mun = FGPositioned::findClosestWithIdent("MUN", + eddm->geod(), &vorFilt); + + const FGAirport* ksfo = fgFindAirportID("KSFO"); + FGPositionedRef sfo = FGPositioned::findClosestWithIdent("SFO", + ksfo->geod(), &vorFilt); + + + WayptRef awy1 = new NavaidWaypoint(tla, NULL); + WayptRef awy2 = new NavaidWaypoint(big, NULL); + WayptRef awy3 = new NavaidWaypoint(pol, NULL); + WayptRef awy4 = new NavaidWaypoint(mun, NULL); + WayptRef awy5 = new NavaidWaypoint(sfo, NULL); + + WayptRef awy6 = new NavaidWaypoint( + (FGPositioned*) fgFindAirportID("KJFK"), NULL); + + SGPath p("/Users/jmt/Desktop/airways.kml"); + std::fstream f; + f.open(p.str().c_str(), fstream::out | fstream::trunc); + +// pre-amble + f << "\n" + "\n" + "\n"; + + WayptVec route; + Airway::highLevel()->route(awy1, awy3, route); + Route::dumpRouteToLineString("egph-egcc", route, f); + + Airway::lowLevel()->route(awy1, awy2, route); + Route::dumpRouteToLineString("egph-big", route, f); + Airway::lowLevel()->route(awy2, awy4, route); + Route::dumpRouteToLineString("big-mun", route, f); + Airway::highLevel()->route(awy4, awy5, route); + Route::dumpRouteToLineString("mun-sfo", route, f); + + Airway::lowLevel()->route(awy5, awy6, route); + Route::dumpRouteToLineString("sfo-jfk", route, f); + + // post-amble + f << "\n" + "" << endl; + f.close(); + +// procedures + SGPath op("/Users/jmt/Desktop/procedures.kml"); + f.open(op.str().c_str(), fstream::out | fstream::trunc); + + FGAirport* eham = (FGAirport*) fgFindAirportID("EHAM"); + FGPositioned::TypeFilter fixFilt(FGPositioned::FIX); + + WayptVec approach; + FGPositionedRef redfa = FGPositioned::findClosestWithIdent("REDFA", + eham->geod(), &fixFilt); + bool ok = eham->buildApproach(new NavaidWaypoint(redfa, NULL), + eham->getRunwayByIdent("18R"), approach); + if (!ok ) { + SG_LOG(SG_GENERAL, SG_INFO, "failed to build approach"); + } + + + FGAirport* egll = (FGAirport*) fgFindAirportID("EGLL"); + WayptVec approach2; + ok = egll->buildApproach(new NavaidWaypoint(big, NULL), + egll->getRunwayByIdent("27R"), approach2); + if (!ok ) { + SG_LOG(SG_GENERAL, SG_INFO, "failed to build approach"); + } + +// pre-amble + f << "\n" + "\n" + "\n"; + + Route::dumpRouteToLineString("REDFA 18R", approach, f); + Route::dumpRouteToLineString("EGLL 27R", approach2, f); + + // post-amble + f << "\n" + "" << endl; + f.close(); + + return EXIT_SUCCESS; + + + +} catch (sg_exception& ex) { + SG_LOG(SG_GENERAL, SG_ALERT, "exception:" << ex.getFormattedMessage()); +} + return EXIT_FAILURE; }