From 69ef7449f5f26453a8b6cab1ba02cb870055615f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Feb 2019 20:42:26 +0100 Subject: typo fixes: s/Explictly/Explicitly/ and s/instanciat/instantiat/ --- src/apps/cs2cs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 150548c5..dafd06f8 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -206,10 +206,10 @@ static void process(FILE *fid) } /************************************************************************/ -/* instanciate_crs() */ +/* instantiate_crs() */ /************************************************************************/ -static PJ *instanciate_crs(const std::string &definition, +static PJ *instantiate_crs(const std::string &definition, bool &isGeog, double &toRadians, bool &isLatFirst) { PJ *crs = proj_create(nullptr, @@ -541,7 +541,7 @@ int main(int argc, char **argv) { PJ *src = nullptr; if (!fromStr.empty()) { bool ignored; - src = instanciate_crs(fromStr, srcIsGeog, + src = instantiate_crs(fromStr, srcIsGeog, srcToRadians, ignored); if (!src) { emess(3, "cannot instantiate source coordinate system"); @@ -550,7 +550,7 @@ int main(int argc, char **argv) { PJ *dst = nullptr; if (!toStr.empty()) { - dst = instanciate_crs(toStr, destIsGeog, + dst = instantiate_crs(toStr, destIsGeog, destToRadians, destIsLatLong); if (!dst) { emess(3, "cannot instantiate target coordinate system"); -- cgit v1.2.3 From 10e1b7b75f70c704cf78a7eb7197beebb4b82d4a Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sun, 24 Mar 2019 11:35:16 +0100 Subject: Make cs2cs support 4D coordinates. This is a bit of a hack, 4D coordinates *will* be written to STDOUT but the output format speficied with -f is not respected for the t component, rather it is forward verbatim from the input. Fixes #1354 --- src/apps/cs2cs.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index dafd06f8..c68572fa 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -113,6 +113,17 @@ static void process(FILE *fid) z = strtod(s, &s); + /* To avoid breaking existing tests, we read what is a possible t */ + /* component of the input and rewind the s-pointer so that the final */ + /* output has consistant behaviour, with or without t values. */ + /* This is a bit of a hack, in most cases 4D coordinates will be */ + /* written to STDOUT (except when using -E) but the output format */ + /* speficied with -f is not respected for the t component, rather it */ + /* is forward verbatim from the input. */ + char *before_time = s; + double t = strtod(s, &s); + s = before_time; + if (data.v == HUGE_VAL) data.u = HUGE_VAL; @@ -120,11 +131,11 @@ static void process(FILE *fid) --s; /* assumed we gobbled \n */ if (echoin) { - char t; - t = *s; + char temp; + temp = *s; *s = '\0'; (void)fputs(line, stdout); - *s = t; + *s = temp; putchar('\t'); } @@ -141,7 +152,7 @@ static void process(FILE *fid) coord.xyzt.x = data.u; coord.xyzt.y = data.v; coord.xyzt.z = z; - coord.xyzt.t = HUGE_VAL; + coord.xyzt.t = t; coord = proj_trans(transformation, PJ_FWD, coord); data.u = coord.xyz.x; data.v = coord.xyz.y; -- cgit v1.2.3 From 1eadd02ac0b28486e98aed9407f27c4956619bae Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Sun, 24 Mar 2019 11:56:35 +0000 Subject: Doc: consistently use +opt and brackets +opt represents one parameter. An ellipsis indicates additional instances of the previous parameter may be given. Spaces are used between parameters and before an ellipsis, not purely to format brackets. See man(1) SYNOPSIS conventions. --- src/apps/cs2cs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index dafd06f8..b6a0f2ac 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -68,8 +68,8 @@ static const char *oform = static char oform_buffer[16]; /* buffer for oform when using -d */ static const char *oterr = "*\t*"; /* output line for unprojectable input */ static const char *usage = - "%s\nusage: %s [ -dDeEfIlrstvwW [args] ] [ +opts[=arg] ]\n" - " [+to [+opts[=arg] [ files ]\n"; + "%s\nusage: %s [-dDeEfIlrstvwW [args]] [+opt[=arg] ...]\n" + " [+to +opt[=arg] ...] [file ...]\n"; static double (*informat)(const char *, char **); /* input data deformatter function */ -- cgit v1.2.3 From 473a8c133be66af64c227e7d24cb0031ebc6ebd7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 26 Mar 2019 14:24:48 +0100 Subject: cs2cs: remove dead code that would leak memory. Coverity CID 193534 --- src/apps/cs2cs.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index c68572fa..31f0ae8e 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -274,13 +274,6 @@ static std::string get_geog_crs_proj_string_from_proj_crs(PJ *src, double &toRadians, bool &isLatFirst) { auto srcType = proj_get_type(src); - if (srcType == PJ_TYPE_BOUND_CRS) { - auto base = proj_get_source_crs(nullptr, src); - assert(base); - proj_destroy(src); - src = base; - srcType = proj_get_type(src); - } if (srcType != PJ_TYPE_PROJECTED_CRS) { return std::string(); } -- cgit v1.2.3 From 8a31ed4036888ff2039919f8c998a90cb2143bc2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 19 Apr 2019 23:47:39 +0200 Subject: proj/cs2cs: validate value of -f parameter to avoid potential crashes (fixes #124) --- src/apps/cs2cs.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 877a68ff..40b0d584 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -45,6 +45,7 @@ #include "proj.h" #include "proj_internal.h" #include "emess.h" +#include "utils.h" // clang-format on #define MAX_LINE 1000 @@ -522,6 +523,13 @@ int main(int argc, char **argv) { if (eargc == 0) /* if no specific files force sysin */ eargv[eargc++] = const_cast("-"); + if( oform ) { + if( !validate_form_string_for_numbers(oform) ) { + emess(3, "invalid format string"); + exit(0); + } + } + /* * If the user has requested inverse, then just reverse the * coordinate systems. -- cgit v1.2.3 From c5346c7c25ca9fe281df39eaeefebc1aa4009266 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 3 May 2019 20:54:42 +0200 Subject: cs2cs: set time value to HUGE_VAL if not explicitly specified --- src/apps/cs2cs.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/apps/cs2cs.cpp') diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 40b0d584..20e5e73c 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -123,6 +123,8 @@ static void process(FILE *fid) /* is forward verbatim from the input. */ char *before_time = s; double t = strtod(s, &s); + if( s == before_time ) + t = HUGE_VAL; s = before_time; if (data.v == HUGE_VAL) -- cgit v1.2.3