X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fmetar_main.cxx;h=d150b65267097f027dce01302e0db4d10a01f766;hb=7cde2e800bccd4883f03eceb5283add24755b377;hp=4519975d0936582d860617c144b14a7cc0618af8;hpb=4df8f790d592fe9a7af3e6d26a1fd6ffdc75fae7;p=flightgear.git diff --git a/src/Main/metar_main.cxx b/src/Main/metar_main.cxx index 4519975d0..d150b6526 100644 --- a/src/Main/metar_main.cxx +++ b/src/Main/metar_main.cxx @@ -16,22 +16,25 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ #include #include +#include #include +#include #include -#include #include +#include using namespace std; // text color -#if defined(__linux__) || defined( __sun__ ) ||defined(__CYGWIN__) || defined( __FreeBSD__ ) || defined ( sgi ) +#if defined(__linux__) || defined(__sun) || defined(__CYGWIN__) \ + || defined( __FreeBSD__ ) || defined ( sgi ) # define R "\033[31;1m" // red # define G "\033[32;1m" // green # define Y "\033[33;1m" // yellow @@ -74,11 +77,11 @@ const char *azimuthName(double d) double rnd(double r, int g = 0) { double f = pow(10.0, g); - return f * rint(r / f); + return f * floor(r / f + 0.5); } -ostream& operator<<(ostream& s, SGMetarVisibility& v) +ostream& operator<<(ostream& s, const SGMetarVisibility& v) { ostringstream buf; int m = v.getModifier(); @@ -133,9 +136,7 @@ void printReport(SGMetar *m) // date/time int year = m->getYear(); int month = m->getMonth(); - cout << "Report time:\t\t"; - if (year != -1 && month != -1) - cout << year << '/' << month << '/' << m->getDay(); + cout << "Report time:\t\t" << year << '/' << month << '/' << m->getDay(); cout << ' ' << m->getHour() << ':'; cout << setw(2) << setfill('0') << m->getMinute() << " UTC" << endl; @@ -155,7 +156,7 @@ void printReport(SGMetar *m) // directed visibility - SGMetarVisibility *dirvis = m->getDirVisibility(); + const SGMetarVisibility *dirvis = m->getDirVisibility(); for (i = 0; i < 8; i++, dirvis++) if (dirvis->getVisibility_m() != NaN) cout << "\t\t\t" << *dirvis << endl; @@ -265,12 +266,12 @@ void printReport(SGMetar *m) // assemble surface string vector surface; - if ((s = rwy.getDeposit()) && strlen(s)) + if ((s = rwy.getDepositString()) && strlen(s)) surface.push_back(s); if ((s = rwy.getExtentString()) && strlen(s)) surface.push_back(s); if ((d = rwy.getDepth()) != NaN) { - sprintf(buf, "%.0lf mm", d * 1000.0); + sprintf(buf, "%.1lf mm", d * 1000.0); surface.push_back(buf); } if ((s = rwy.getFrictionString()) && strlen(s)) @@ -460,7 +461,7 @@ void getproxy(string& host, string& port) } -void help() +void usage() { printf( "Usage: metar [-v] [-e elevation] [-r|-c] \n" @@ -485,7 +486,6 @@ void help() ); } - int main(int argc, char *argv[]) { bool report = true; @@ -493,7 +493,7 @@ int main(int argc, char *argv[]) double elevation = 0.0; if (argc <= 1) { - help(); + usage(); return 0; } @@ -502,7 +502,7 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) - help(); + usage(); else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) verbose = true; else if (!strcmp(argv[i], "-r") || !strcmp(argv[i], "--report")) @@ -518,13 +518,13 @@ int main(int argc, char *argv[]) } else { static bool shown = false; if (verbose && !shown) { - cout << "Proxy host: '" << proxy_host << "'" << endl; - cout << "Proxy port: '" << proxy_port << "'" << endl << endl; + cerr << "Proxy host: '" << proxy_host << "'" << endl; + cerr << "Proxy port: '" << proxy_port << "'" << endl << endl; shown = true; } try { - SGMetar *m = new SGMetar(argv[i], proxy_host, proxy_port); + SGMetar *m = new SGMetar(argv[i], proxy_host, proxy_port, "", time(0)); //SGMetar *m = new SGMetar("2004/01/11 01:20\nLOWG 110120Z AUTO VRB01KT 0050 1600N R35/0600 FG M06/M06 Q1019 88//////\n"); if (verbose) { @@ -533,7 +533,6 @@ int main(int argc, char *argv[]) const char *unused = m->getUnusedData(); if (*unused) cerr << R"UNUSED: " << unused << ""N << endl; - } if (report)