From 27ac393771dfa6ad7b5d8b3305ac6f323773b517 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Thu, 16 Nov 2017 20:57:49 +0100 Subject: Repair double cct io-blunder --- src/cct.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/cct.c') diff --git a/src/cct.c b/src/cct.c index 1bd25f1d..bd507863 100644 --- a/src/cct.c +++ b/src/cct.c @@ -171,7 +171,7 @@ int main(int argc, char **argv) { verbose = opt_given (o, "v"); if (opt_given (o, "o")) - fout = fopen (opt_arg (o, "output"), "rt"); + fout = fopen (opt_arg (o, "output"), "wt"); if (0==fout) { fprintf (stderr, "%s: Cannot open '%s' for output\n", o->progname, opt_arg (o, "output")); free (o); @@ -260,10 +260,6 @@ int main(int argc, char **argv) { point.lpzt.phi = proj_torad (point.lpzt.phi); } point = proj_trans (P, direction, point); - if (proj_angular_output (P, direction)) { - point.lpzt.lam = proj_todeg (point.lpzt.lam); - point.lpzt.phi = proj_todeg (point.lpzt.phi); - } if (HUGE_VAL==point.xyzt.x) { /* transformation error (TODO provide existing internal errmsg here) */ @@ -272,7 +268,13 @@ int main(int argc, char **argv) { } /* Time to print the result */ - fprintf (fout, "%20.15f %20.15f %20.15f %20.15f\n", point.xyzt.x, point.xyzt.y, point.xyzt.z, point.xyzt.t); + if (proj_angular_output (P, direction)) { + point.lpzt.lam = proj_todeg (point.lpzt.lam); + point.lpzt.phi = proj_todeg (point.lpzt.phi); + fprintf (fout, "%14.10f %14.10f %12.4f %12.4f\n", point.xyzt.x, point.xyzt.y, point.xyzt.z, point.xyzt.t); + } + else + fprintf (fout, "%13.4f %13.4f %12.4f %12.4f\n", point.xyzt.x, point.xyzt.y, point.xyzt.z, point.xyzt.t); } if (stdout != fout) -- cgit v1.2.3