diff --git a/test_suite/FGTestApi/testGlobals.cxx b/test_suite/FGTestApi/testGlobals.cxx index 45462bc59..fb40df8ca 100644 --- a/test_suite/FGTestApi/testGlobals.cxx +++ b/test_suite/FGTestApi/testGlobals.cxx @@ -107,6 +107,33 @@ bool logPositionToKML(const std::string& testName) return true; } +bool logLinestringsToKML(const std::string& testName) +{ + // clear any previous state + if (global_loggingToKML) { + global_kmlStream.close(); + global_lineStringOpen = false; + } + + SGPath p = SGPath::desktop() / (testName + ".kml"); + global_kmlStream.open(p); + if (!global_kmlStream.is_open()) { + SG_LOG(SG_GENERAL, SG_WARN, "unable to open:" << p); + return false; + } + + // pre-amble + global_kmlStream << "\n" + "\n" + "\n"; + // need more precision for doubles when specifying lat/lon, see + // https://xkcd.com/2170/ :) + global_kmlStream.precision(12); + + global_loggingToKML = false; + return true; +} + void initStandardNasal(bool withCanvas) { fgInitAllowedPaths(); @@ -250,6 +277,16 @@ void setPosition(const SGGeod& g) globals->get_props()->setDoubleValue("position/longitude-deg", g.getLongitudeDeg()); globals->get_props()->setDoubleValue("position/altitude-ft", g.getElevationFt()); } + +const SGGeod getPosition() +{ + return SGGeod::fromDegFt( + globals->get_props()->getDoubleValue("position/latitude-deg"), + globals->get_props()->getDoubleValue("position/longitude-deg"), + globals->get_props()->getDoubleValue("position/altitude-ft")); +} + + void setPositionAndStabilise(const SGGeod& g) { diff --git a/test_suite/FGTestApi/testGlobals.hxx b/test_suite/FGTestApi/testGlobals.hxx index 995753461..e48ac24e1 100644 --- a/test_suite/FGTestApi/testGlobals.hxx +++ b/test_suite/FGTestApi/testGlobals.hxx @@ -23,6 +23,8 @@ namespace setUp { void initTestGlobals(const std::string& testName); bool logPositionToKML(const std::string& testName); +/**Don't log aircraft positions*/ +bool logLinestringsToKML(const std::string& testName); void initStandardNasal(bool withCanvas = false); @@ -39,7 +41,8 @@ void populateFPWithNasal(flightgear::FlightPlanRef f, } // End of namespace setUp. // helpers during tests - + +const SGGeod getPosition(); void setPosition(const SGGeod& g); void setPositionAndStabilise(const SGGeod& g);