From fb69e67f8694fd61943cc9f9c2da75ec35ce9841 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Thu, 11 Jan 2018 16:34:47 +0100 Subject: 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 --- src/cct.c | 10 ++++++++-- 1 file 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 */ -- cgit v1.2.3