aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-01-17 16:10:34 +0100
committerGitHub <noreply@github.com>2018-01-17 16:10:34 +0100
commit33a7216aea7bacf8cff72a5e6bb59b25e7d931f7 (patch)
treeff2eafe33befd8fe38f63a83a0b8562f1304a8f2 /src
parent53b30f10c6e8d74a79b5d0763a53c5e1732e34b7 (diff)
parent046ce54719f3224b1b9299ee8d370cc92b0929af (diff)
downloadPROJ-33a7216aea7bacf8cff72a5e6bb59b25e7d931f7.tar.gz
PROJ-33a7216aea7bacf8cff72a5e6bb59b25e7d931f7.zip
Merge pull request #739 from kbevers/pipeline-inverse
Pipeline and cct inverse fixes
Diffstat (limited to 'src')
-rw-r--r--src/PJ_pipeline.c32
-rw-r--r--src/cct.c10
2 files changed, 38 insertions, 4 deletions
diff --git a/src/PJ_pipeline.c b/src/PJ_pipeline.c
index af9c5394..befc8557 100644
--- a/src/PJ_pipeline.c
+++ b/src/PJ_pipeline.c
@@ -429,14 +429,42 @@ PJ *OPERATION(pipeline,0) {
/* Is this step inverted? */
for (j = 0; j < current_argc; j++)
- if (0==strcmp("inv", current_argv[j]))
- next_step->inverted = 1;
+ if (0==strcmp("inv", current_argv[j])) {
+ /* if +inv exists in both global and local args the forward operation should be used */
+ next_step->inverted = next_step->inverted == 0 ? 1 : 0;
+ }
P->opaque->pipeline[i+1] = next_step;
proj_log_trace (P, "Pipeline at [%p]: step at [%p] done", P, next_step);
}
+ /* Require a forward path through the pipeline */
+ for (i = 1; i <= nsteps; i++) {
+ PJ *Q = P->opaque->pipeline[i];
+ if ( ( Q->inverted && (Q->inv || Q->inv3d || Q->fwd4d) ) ||
+ (!Q->inverted && (Q->fwd || Q->fwd3d || Q->fwd4d) ) ) {
+ continue;
+ } else {
+ proj_log_error (P, "Pipeline: A forward operation couldn't be constructed");
+ return destructor (P, PJD_ERR_MALFORMED_PIPELINE);
+ }
+ }
+
+ /* determine if an inverse operation is possible */
+ for (i = 1; i <= nsteps; i++) {
+ PJ *Q = P->opaque->pipeline[i];
+ if ( ( Q->inverted && (Q->fwd || Q->fwd3d || Q->fwd4d) ) ||
+ ( Q->inv || Q->inv3d || Q->inv4d) ) {
+ continue;
+ } else {
+ P->inv = 0;
+ P->inv3d = 0;
+ P->inv4d = 0;
+ break;
+ }
+ }
+
proj_log_trace (P, "Pipeline: %d steps built. Determining i/o characteristics", nsteps);
/* Determine forward input (= reverse output) data type */
diff --git a/src/cct.c b/src/cct.c
index f315ae1a..7e48311a 100644
--- a/src/cct.c
+++ b/src/cct.c
@@ -217,9 +217,15 @@ int main(int argc, char **argv) {
return 1;
}
- /* We have no API call for inverting an operation, so we brute force it. */
- if (direction==-1)
+ if (direction==-1) {
+ /* fail if an inverse operation is not available */
+ if (!proj_pj_info(P).has_inverse) {
+ fprintf (stderr, "Inverse operation not available\n");
+ return 1;
+ }
+ /* We have no API call for inverting an operation, so we brute force it. */
P->inverted = !(P->inverted);
+ }
direction = 1;
/* Allocate input buffer */