From bea0c8b0c015ef0a5c136b904d63ad7f4a4427bf Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Sat, 25 Nov 2017 01:40:37 +0100 Subject: Overhaul ellipsoid handling (#682) Improve error messaging for cct and gie, and do some clean ups in the ellipsoid handling - partially to squash bugs, partially to improve naming consistency which, in turn, improves the readability of the ellipsoid handling code. Renamed functions: pj_inherit_ellipsoid_defs has been renamed pj_inherit_ellipsoid_def, while pj_calc_ellps_params has been renamed pj_calc_ellipsoid_params. The code in get_opt (part of pj_init.c), which handles whether or not an ellipsoid definition should be dragged in from proj_def.dat, has been rewritten. I suspect this was buggy beforehand, and at least the new code is easier to follow (although it may be slightly slower, which is not really a problem as it sits in the setup code, and hence is executed only once). --- src/cct.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/cct.c') diff --git a/src/cct.c b/src/cct.c index bd507863..a1c275b5 100644 --- a/src/cct.c +++ b/src/cct.c @@ -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,13 +261,17 @@ 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 (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 */ if (proj_angular_output (P, direction)) { -- cgit v1.2.3