aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-01-11 16:34:47 +0100
committerKristian Evers <kristianevers@gmail.com>2018-01-11 16:34:47 +0100
commitfb69e67f8694fd61943cc9f9c2da75ec35ce9841 (patch)
tree6e58a4cf7f637aea87ec3ab05838766323c4329d /src
parent07bb446ec474cf62094070a8ea848b37c911a075 (diff)
downloadPROJ-fb69e67f8694fd61943cc9f9c2da75ec35ce9841.tar.gz
PROJ-fb69e67f8694fd61943cc9f9c2da75ec35ce9841.zip
Fail gracefully when invalid inverse operation is specified in cct.
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
Diffstat (limited to 'src')
-rw-r--r--src/cct.c10
1 files changed, 8 insertions, 2 deletions
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 */