Skip to content

Commit

Permalink
Merge pull request #4014 from rouault/pipeline_error_msg
Browse files Browse the repository at this point in the history
Pipeline instanciation: better error message when an inverse operation is needed in forward path and not available
  • Loading branch information
rouault authored Jan 29, 2024
2 parents 03a4ee4 + 8aa3f4b commit e31195f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
18 changes: 15 additions & 3 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,24 @@ PJ *OPERATION(pipeline, 0) {
/* Require a forward path through the pipeline */
for (auto &step : pipeline->steps) {
PJ *Q = step.pj;
if ((Q->inverted && (Q->inv || Q->inv3d || Q->fwd4d)) ||
(!Q->inverted && (Q->fwd || Q->fwd3d || Q->fwd4d))) {
if (step.omit_fwd) {
continue;
}
if (Q->inverted) {
if (Q->inv || Q->inv3d || Q->inv4d) {
continue;
}
proj_log_error(
P, _("Pipeline: Inverse operation for %s is not available"),
Q->short_name);
return destructor(P, PROJ_ERR_OTHER_NO_INVERSE_OP);
} else {
if (Q->fwd || Q->fwd3d || Q->fwd4d) {
continue;
}
proj_log_error(
P, _("Pipeline: A forward operation couldn't be constructed"));
P, _("Pipeline: Forward operation for %s is not available"),
Q->short_name);
return destructor(P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX);
}
}
Expand Down
13 changes: 3 additions & 10 deletions test/gie/more_builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,10 @@ expect 5.875 55.375 0
# | | invertible step | non-invertible step |
# | flags | forward path | inverse path | forward path | inverse path |
# | -------------- | ------------ | ------------ | ------------ | ------------ |
# | +omit_fwd | omit | inv | omit | undefined |
# | +omit_fwd | omit | inv | omit | runtime err |
# | +omit_fwd +inv | omit | fwd | omit | fwd |
# | +omit_inv | fwd | omit | fwd | omit |
# | +omit_inv +inv | inv | omit | undefined | omit |
# | +omit_inv +inv | inv | omit | pipeline creation error |
#
# From the table we can see that invertible steps should work pretty much all
# the time. Non-invertible steps on the other hand make either the forward path
Expand Down Expand Up @@ -1033,20 +1033,13 @@ direction inverse
accept 1 2 3
expect 1 2 3

# Test that the forward path is not defined and inverse path does nothing.
# Test that the forward path is not defined
#
# When going through the forward path, inv specifies that we should execute the
# step in reverse. Because the affine transformation does not have an inverse,
# this means that the forward path does not exist.

operation proj=pipeline step proj=affine s11=1 s12=1 s13=1 s22=0 s33=0 omit_inv inv

direction forward
accept 1 2 3
expect failure errno no_inverse_op

direction inverse
accept 1 2 3
expect 1 2 3

</gie-strict>

0 comments on commit e31195f

Please sign in to comment.