aboutsummaryrefslogtreecommitdiff
path: root/src/cct.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-11-27 20:21:52 +0100
committerKristian Evers <kristianevers@gmail.com>2017-11-27 20:23:25 +0100
commitf0181b0a24d9d3a8bb593811945fea008128f94a (patch)
treec4ef5fc40f00481755c86f383be839b7b81eac68 /src/cct.c
parent25b011042fdff451ca2826afe82251c06d883fb8 (diff)
parent1f48f4c333bfe135296d3be643ef4981dc401c38 (diff)
downloadPROJ-f0181b0a24d9d3a8bb593811945fea008128f94a.tar.gz
PROJ-f0181b0a24d9d3a8bb593811945fea008128f94a.zip
Merge remote-tracking branch 'osgeo/master' into docs-release-4.10.0
Diffstat (limited to 'src/cct.c')
-rw-r--r--src/cct.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/cct.c b/src/cct.c
index 1bd25f1d..a1c275b5 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);
@@ -206,7 +206,8 @@ int main(int argc, char **argv) {
/* Setup transformation */
P = proj_create_argv (0, o->pargc, o->pargv);
if ((0==P) || (0==o->pargc)) {
- fprintf (stderr, "%s: Bad transformation arguments. '%s -h' for help\n", o->progname, o->progname);
+ fprintf (stderr, "%s: Bad transformation arguments - (%s)\n '%s -h' for help\n",
+ o->progname, pj_strerrno (proj_errno(P)), o->progname);
free (o);
if (stdout != fout)
fclose (fout);
@@ -232,6 +233,7 @@ int main(int argc, char **argv) {
/* Loop over all records of all input files */
while (opt_input_loop (o, optargs_file_format_text)) {
+ int err;
void *ret = fgets (buf, 10000, o->input);
opt_eof_handler (o);
if (0==ret) {
@@ -259,20 +261,26 @@ int main(int argc, char **argv) {
point.lpzt.lam = proj_torad (point.lpzt.lam);
point.lpzt.phi = proj_torad (point.lpzt.phi);
}
+ err = proj_errno_reset (P);
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) */
- fprintf (fout, "# Record %d TRANSFORMATION ERROR: %s", (int) o->record_index, buf);
+ /* transformation error */
+ fprintf (fout, "# Record %d TRANSFORMATION ERROR: %s (%s)",
+ (int) o->record_index, buf, pj_strerrno (proj_errno(P)));
+ proj_errno_restore (P, err);
continue;
}
+ proj_errno_restore (P, err);
/* 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)