-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipeline and cct inverse fixes #739
Conversation
Similar to proj and cs2cs, cct now returns immediately when trying to do an inverse operation that is not possible, for example using proj=urm5 which doesn't have an inverse: $ cct.exe -I +proj=pipeline +step +proj=urm5 +n=0.5 Inverse operation not available
… exist. Some projections do not have an inverse mapping. If such a projection is used as a (forward) step in a pipeline we won't be able to perform an inverse operation using the pipeline. By setting the inv, inv3d and inv4d pointers to zero we signal to the caller that an inverse mapping is not available.
b6c8e41
to
57c1491
Compare
Very nice that you are repairing this long standing bug, but I think, for backward compatibility you will also have to require that a forward method exists: It could be non-existing in the corner case, where at least one step is non-invertible, but have the My imagination is not sufficient to dream up cases where this could be the intention, so I think it is safe to consider it an error: If using the new API one can always work around it by putting But if I understand the PR correctly, it also needs to take into consideration the case where the pipeline itself is To check that all the double inversions work correctly, you should probably also add a few test cases, making sure they fail as intended. EDIT: I see that you have filed an issue about a gie bug that prevents this. I'll look into it. |
If I understand you correctly, I take care of that particular situation in the first part of:
A comment might be warrantedt though.
Yes. So that'll have to wait a bit. Also, the |
I'm not sure: the situation I talk about is when the entire pipeline is inverted. When done at init, putting an +inv at the pipeline top level will actually lead to all steps getting inverted, and the test will work. But if done later by switching P->inverted (which happens at least one place in the source code, with a comment that we miss an inversion API call), it will not work anymore. This is why we should require the forward method to exist at the top level of the pipeline. |
Still not sure I understand correctly. You want to check that a forward operation of the pipeline as a whole is possible? Or that every step-operation has a forward definition? |
Whereas When
|
Probably the problem can be solved by providing an API-entry for inverting an operation, and make that entry check whether inversion is possible. Note that the inversion operator should not be idempotent (i.e. just setting the In that case we will probably need two extra operators I say "probably", because there is probably apps in the wild expecting that "a forward method is always available". With old API elements (pj_fwd, pj_inv) being reimplemented using new API building bricks (proj_trans), this is not always the case. I'm not entirely sure about how this should work. |
57c1491
to
d21a0cc
Compare
Okay, I have made a few changes. Multiple inversions are now taken care of properly and a forward path through a pipeline MUST exist. See the commit text for more details. I think this is as far as I can go without adding additional API functions that control this stuff. |
…tion. "+proj=pipeline +inv +step +urm5 +n=0.5 +inv" now works as expected, returning the forward operation of urm5. In principle adding more +inv's should also work, resulting in the forward operation when an even number of +inv's are present, and the inverse when an odd number of +inv's are present. "+proj=pipeline +step +urm5 +n=0.5 +inv" fails at initialization since no forward operation can be performed. This is a new requirement, but aligns perfectly with the rest of the library since no operation without a forward method exists.
277415a
to
046ce54
Compare
This PR makes two changes:
Similar to proj and cs2cs, cct now returns immediately when trying to
do an inverse operation that is not possible, for example using
proj=urm5 which doesn't have an inverse:
Some projections do not have an inverse mapping. If such a projection is used
as a (forward) step in a pipeline we won't be able to perform an inverse
operation using the pipeline. By setting the inv, inv3d and inv4d pointers to
zero we signal to the caller that an inverse mapping is not available.