本文整理汇总了C++中SolarSystem::initializeWithBinaryFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SolarSystem::initializeWithBinaryFile方法的具体用法?C++ SolarSystem::initializeWithBinaryFile怎么用?C++ SolarSystem::initializeWithBinaryFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolarSystem
的用法示例。
在下文中一共展示了SolarSystem::initializeWithBinaryFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
try {
clock_t totaltime; // for timing
totaltime = clock();
// locals
int i,iret=0;
DayTime CurrEpoch; // defaults to current local time
SolarSystem SSEphemeris;
// program name, title and version
PrgmName = string("testSSEph");
Title = PrgmName + ", test program for JPL ephemeris, version "
+ Version + ", " + CurrEpoch.printf("Run %04Y/%02m/%02d at %02H:%02M:%02S");
// default command line input
bool verbose=false,debug=false;
string inputFilename,testFilename,logFilename;
// parse the command line input
for(i=0; i<argc; i++) {
string word = string(argv[i]);
if(argc == 1 || word == "-h" || word == "--help") {
cout << "Program " << PrgmName
<< " reads a binary JPL planetary ephemeris file, created by "
<< "convertSSEph,\n and a test file, downloaded from the JPL ftp site, "
<< "containing times and planets\n with JPL-generated ephemeris "
<< "coordinate values. The coordinates are computed using\n the binary "
<< "file and the SolarSystem class, and compared with the JPL values;\n "
<< "any difference larger than 10^-13 is noted with the word 'Failure' "
<< "at EOL.\n Note that some large coordinate values may differ at the "
<< "level of 10^-13 because the\n size of double precision is barely "
<< "able to hold that much precision; compare the\n computed value "
<< "with the JPL value (copied as a string) in the output file.\n"
<< "\n Usage: " << PrgmName << " [options]\n Options are:\n"
<< " --log <file> name of optional log file (otherwise stderr)\n"
<< " --file <file> name of binary SS ephemeris file\n"
<< " --test <file> name of JPL test file (e.g. testpo.403)\n"
<< " --verbose print info to the log file.\n"
<< " --debug print debugging info to the log file.\n"
<< " --help print this and quit.\n"
;
return 0;
}
else if(i == 0) continue;
else if(word == "-d" || word == "--debug") debug = true;
else if(word == "-v" || word == "--verbose") verbose = true;
else if(word == "--log") logFilename = string(argv[++i]);
else if(word == "--file") inputFilename = string(argv[++i]);
else if(word == "--test") testFilename = string(argv[++i]);
}
// test input
if(inputFilename.empty()) {
LOG(ERROR) << "Must specify an input binary file name";
return -1;
}
if(testFilename.empty()) {
LOG(ERROR) << "Must specify an input test file name";
return -1;
}
if(!logFilename.empty()) {
// choose the log file
logstrm.open(logFilename.c_str(),ios_base::out);
ConfigureLOG::Stream() = &logstrm;
// if not the above, output is to stderr
cout << Title << endl;
cout << "Output is logged to file " << logFilename << endl;
}
// set the maximum level to be logged
ConfigureLOG::ReportLevels() = ConfigureLOG::ReportTimeTags() = true;
if(debug)
ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString("DEBUG");
else if(verbose)
ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString("VERBOSE");
else
ConfigureLOG::ReportingLevel() = ConfigureLOG::FromString("INFO");
// = any of ERROR,WARNING,INFO,VERBOSE,DEBUG,DEBUGn (n=1,2,3,4,5,6,7)
//cout << "Reporting in main is "
// << ConfigureLOG::ToString(ConfigureLOG::ReportingLevel()) << endl;
// display title in the log file
LOG(INFO) << Title;
// now read the binary file, and read selected records
// use the binary to test using the JPL file testpo.<EPH#>
LOG(VERBOSE) << "Initialize with file " << inputFilename;
SSEphemeris.initializeWithBinaryFile(inputFilename);
LOG(VERBOSE) << "End Initialize";
LOG(INFO) << "Ephemeris number is " << SSEphemeris.JPLNumber();
bool foundEOT=false;
int target,center,coord;
double JD,PV[6],value,diff;
SolarSystem::Planet Target,Center;
//.........这里部分代码省略.........