aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_pipeline.c
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-11-25 01:40:37 +0100
committerGitHub <noreply@github.com>2017-11-25 01:40:37 +0100
commitbea0c8b0c015ef0a5c136b904d63ad7f4a4427bf (patch)
tree6ba55090efcbb1f0f3223e9eede71016b13d65c0 /src/PJ_pipeline.c
parenta7a2c3d62570cf78c95650586ce36b522128892b (diff)
downloadPROJ-bea0c8b0c015ef0a5c136b904d63ad7f4a4427bf.tar.gz
PROJ-bea0c8b0c015ef0a5c136b904d63ad7f4a4427bf.zip
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).
Diffstat (limited to 'src/PJ_pipeline.c')
-rw-r--r--src/PJ_pipeline.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/PJ_pipeline.c b/src/PJ_pipeline.c
index 19b8e18d..35f79213 100644
--- a/src/PJ_pipeline.c
+++ b/src/PJ_pipeline.c
@@ -305,6 +305,7 @@ static char **argv_params (paralist *params, size_t argc) {
/* re-initialize P->geod. */
static void set_ellipsoid(PJ *P) {
paralist *cur, *attachment;
+ int err = proj_errno_reset (P);
/* Break the linked list after the global args */
attachment = 0;
@@ -320,13 +321,21 @@ static void set_ellipsoid(PJ *P) {
if (0 != pj_ellipsoid (P)) {
P->a = 6378137.0;
P->es = .00669438002290341575;
+
+ /* reset an "unerror": In this special use case, the errno is */
+ /* not an error signal, but just a reply from pj_ellipsoid, */
+ /* telling us that "No - there was no ellipsoid definition in */
+ /* the PJ you provided". */
+ proj_errno_reset (P);
}
- pj_calc_ellps_params(P, P->a, P->es);
+ pj_calc_ellipsoid_params (P, P->a, P->es);
+
geod_init(P->geod, P->a, (1 - sqrt (1 - P->es)));
/* Re-attach the dangling list */
cur->next = attachment;
+ proj_errno_restore (P, err);
}
@@ -345,7 +354,7 @@ PJ *OPERATION(pipeline,0) {
P->opaque = pj_calloc (1, sizeof(struct pj_opaque));
if (0==P->opaque)
- return pj_default_destructor(P, ENOMEM);
+ return destructor(P, ENOMEM);
argc = (int)argc_params (P->params);
P->opaque->argv = argv = argv_params (P->params, argc);
@@ -396,6 +405,7 @@ PJ *OPERATION(pipeline,0) {
for (i_current_step = i_first_step, i = 0; i < nsteps; i++) {
int j;
int current_argc = 0;
+ int err;
PJ *next_step = 0;
/* Build a set of setup args for the current step */
@@ -415,14 +425,22 @@ PJ *OPERATION(pipeline,0) {
for (j = 1; j < current_argc; j++)
proj_log_trace (P, " %s", current_argv[j]);
- next_step = pj_init_ctx (P->ctx, current_argc, current_argv);
+ err = proj_errno_reset (P);
+ next_step = proj_create_argv (P->ctx, current_argc, current_argv);
proj_log_trace (P, "Pipeline: Step %d at %p", i, next_step);
+
if (0==next_step) {
- proj_log_error (P, "Pipeline: Bad step definition: %s", current_argv[0]);
- return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: bad pipeline def */
+ /* The step init failed, but possibly without setting errno. If so, we say "malformed" */
+ int err_to_report = proj_errno(P);
+ if (0==err_to_report)
+ err_to_report = PJD_ERR_MALFORMED_PIPELINE;
+ proj_log_error (P, "Pipeline: Bad step definition: %s (%s)", current_argv[0], pj_strerrno (err_to_report));
+ return destructor (P, err_to_report); /* ERROR: bad pipeline def */
}
+ proj_errno_restore (P, err);
+
/* Is this step inverted? */
for (j = 0; j < current_argc; j++)
if (0==strcmp("inv", current_argv[j]))
@@ -430,7 +448,7 @@ PJ *OPERATION(pipeline,0) {
P->opaque->pipeline[i+1] = next_step;
- proj_log_trace (P, "Pipeline: step done");
+ proj_log_trace (P, "Pipeline at [%p]: step at [%p] done", P, next_step);
}
proj_log_trace (P, "Pipeline: %d steps built. Determining i/o characteristics", nsteps);
@@ -440,7 +458,5 @@ PJ *OPERATION(pipeline,0) {
/* Now, correspondingly determine forward output (= reverse input) data type */
P->right = pj_right (P->opaque->pipeline[nsteps]);
-
return P;
}
-