aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-11-16 22:01:15 +0100
committerGitHub <noreply@github.com>2017-11-16 22:01:15 +0100
commit47a44d4672658f8b9e1eee7d4a412c7940e28900 (patch)
treeda1f6c82fcb35eeb85b571a733c96255397b6f8c
parent93685def8f4b23d220d04bc658a0ff27e93149e6 (diff)
parent27ac393771dfa6ad7b5d8b3305ac6f323773b517 (diff)
downloadPROJ-47a44d4672658f8b9e1eee7d4a412c7940e28900.tar.gz
PROJ-47a44d4672658f8b9e1eee7d4a412c7940e28900.zip
Merge pull request #672 from busstoptaktik/cct-io
Repair double cct io-blunder
-rw-r--r--src/cct.c14
-rw-r--r--src/optargpm.h2
2 files changed, 10 insertions, 6 deletions
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)
diff --git a/src/optargpm.h b/src/optargpm.h
index 23e375f8..950ee529 100644
--- a/src/optargpm.h
+++ b/src/optargpm.h
@@ -285,6 +285,8 @@ int opt_input_loop (OPTARGS *opt, int binary) {
/* otherwise, open next input file */
opt->input = fopen (opt->fargv[opt->input_index++], binary? "rb": "rt");
+ if (0 != opt->input)
+ return 1;
/* ignore non-existing files - go on! */
if (0==opt->input)