aboutsummaryrefslogtreecommitdiff
path: root/src/cct.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-02-19 22:39:17 +0100
committerKristian Evers <kristianevers@gmail.com>2018-02-19 22:39:17 +0100
commit43d811d20598abde95a8d177123e9f26fe5229ab (patch)
treec66684d7975798109a072b52bce5e7c5f9bd5182 /src/cct.c
parenta9e08ad008b1ff16d6139aab5e813058c922eef8 (diff)
parentefa636e0d9e0cef5a5fff1b7ed76d0368d20121b (diff)
downloadPROJ-43d811d20598abde95a8d177123e9f26fe5229ab.tar.gz
PROJ-43d811d20598abde95a8d177123e9f26fe5229ab.zip
Merge remote-tracking branch 'osgeo/master' into docs-release-4.10.0
Diffstat (limited to 'src/cct.c')
-rw-r--r--src/cct.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/cct.c b/src/cct.c
index a1c275b5..dc68122d 100644
--- a/src/cct.c
+++ b/src/cct.c
@@ -71,20 +71,23 @@ Thomas Knudsen, thokn@sdfe.dk, 2016-05-25/2017-10-26
***********************************************************************/
-#include "optargpm.h"
-#include "proj_internal.h"
-#include <proj.h>
-#include "projects.h"
+#include <ctype.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <string.h>
-#include <math.h>
+
+#include <proj.h>
+#include "proj_internal.h"
+#include "projects.h"
+#include "optargpm.h"
+/* Prototypes for functions in proj_strtod.c */
double proj_strtod(const char *str, char **endptr);
double proj_atof(const char *str);
+/* Prototypes from functions in this file */
char *column (char *buf, int n);
PJ_COORD parse_input_line (char *buf, int *columns, double fixed_height, double fixed_time);
@@ -148,13 +151,14 @@ static const char usage[] = {
int main(int argc, char **argv) {
PJ *P;
PJ_COORD point;
+ PJ_PROJ_INFO info;
OPTARGS *o;
FILE *fout = stdout;
char *buf;
int nfields = 4, direction = 1, verbose;
double fixed_z = HUGE_VAL, fixed_time = HUGE_VAL;
int columns_xyzt[] = {1, 2, 3, 4};
- const char *longflags[] = {"v=verbose", "h=help", "I=inverse", 0};
+ const char *longflags[] = {"v=verbose", "h=help", "I=inverse", "version", 0};
const char *longkeys[] = {"o=output", "c=columns", "z=height", "t=time", 0};
o = opt_parse (argc, argv, "hvI", "cozt", longflags, longkeys);
@@ -170,6 +174,11 @@ int main(int argc, char **argv) {
direction = opt_given (o, "I")? -1: 1;
verbose = opt_given (o, "v");
+ if (opt_given (o, "version")) {
+ fprintf (stdout, "%s: %s\n", o->progname, pj_get_release ());
+ return 0;
+ }
+
if (opt_given (o, "o"))
fout = fopen (opt_arg (o, "output"), "wt");
if (0==fout) {
@@ -193,7 +202,7 @@ int main(int argc, char **argv) {
}
if (opt_given (o, "c")) {
- int ncols = sscanf (opt_arg (o, "c"), "%d,%d,%d,%d", columns_xyzt, columns_xyzt+1, columns_xyzt+3, columns_xyzt+3);
+ int ncols = sscanf (opt_arg (o, "c"), "%d,%d,%d,%d", columns_xyzt, columns_xyzt+1, columns_xyzt+2, columns_xyzt+3);
if (ncols != nfields) {
fprintf (stderr, "%s: Too few input columns given: '%s'\n", o->progname, opt_arg (o, "c"));
free (o);
@@ -214,9 +223,20 @@ 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 (verbose > 4) {
+ info = proj_pj_info (P);
+ fprintf (stdout, "Final: %s argc=%d pargc=%d\n", info.definition, argc, o->pargc);
+ }
+
+ 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 */