From c560b7957664c32e2465e8425abaccc5a6b2607d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 17 Nov 2020 12:39:48 +0100 Subject: cs2cs, cct, proj and geod: fflush(stdout) after each line to emit each result as soon as it is produced This is needed when working with pipes, when stdout is not an interactive terminal, and thus the behaviour is to have it buffered as a regular file, whereas with an interactive terminal, each newline character causes an implicit flush. --- src/apps/proj.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/apps/proj.cpp') diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index 0bf98b3a..c9bd8950 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -171,6 +171,7 @@ static void process(FILE *fid) { (void)fputs("\t<* * * * * *>", stdout); } (void)fputs(bin_in ? "\n" : s, stdout); + fflush(stdout); } } @@ -286,6 +287,8 @@ static void vprocess(FILE *fid) { (void)fputs(proj_rtodms(pline, facs.meridian_convergence, 0, 0), stdout); (void)printf(" [ %.8f ]\n", facs.meridian_convergence * RAD_TO_DEG); (void)printf("Max-min (Tissot axis a-b) scale error: %.5f %.5f\n\n", facs.tissot_semimajor, facs.tissot_semiminor); + + fflush(stdout); } } -- cgit v1.2.3 From 43efca4ab87fb37a0931edcb6be11c0bd3784098 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 18 Nov 2020 09:57:42 +0100 Subject: Remove pj_free() and move it's functional parts to proj_destroy() --- src/apps/proj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/apps/proj.cpp') diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index c9bd8950..8bfd99a3 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -562,7 +562,7 @@ int main(int argc, char **argv) { } if( Proj ) - pj_free(Proj); + proj_destroy(Proj); exit(0); /* normal completion */ } -- cgit v1.2.3 From 56f0ad70054eea15e9671cd67aafd14bf7c11c74 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 18 Nov 2020 10:43:16 +0100 Subject: Remove pj_errno and related functions --- src/apps/proj.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/apps/proj.cpp') diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index 8bfd99a3..a5c917f6 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -250,10 +250,8 @@ static void vprocess(FILE *fid) { if (postscale) { dat_xy.x *= fscale; dat_xy.y *= fscale; } } - /* For some reason pj_errno does not work as expected in some */ - /* versions of Visual Studio, so using pj_get_errno_ref instead */ - if (*pj_get_errno_ref()) { - emess(-1, pj_strerrno(*pj_get_errno_ref())); + if (proj_context_errno(nullptr)) { + emess(-1, proj_errno_string(proj_context_errno(nullptr))); continue; } @@ -477,7 +475,7 @@ int main(int argc, char **argv) { } if (!(Proj = pj_init(pargc, pargv))) emess(3,"projection initialization failure\ncause: %s", - pj_strerrno(pj_errno)); + proj_errno_string(proj_context_errno(nullptr))); if (!proj_angular_input(Proj, PJ_FWD)) { emess(3, "can't initialize operations that take non-angular input coordinates"); -- cgit v1.2.3 From f4dc79075c19706dda6e3253c2f224e9df468291 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 30 Nov 2020 01:35:59 +0100 Subject: API cleanup: unexport number of internal symbols, and remove/replace a few unused ones --- src/apps/proj.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/apps/proj.cpp') diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index a5c917f6..0108cb74 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -9,6 +9,8 @@ #include "emess.h" #include "utils.h" +#include + #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__WIN32__) # include # include @@ -292,10 +294,10 @@ static void vprocess(FILE *fid) { int main(int argc, char **argv) { char *arg; - char *pargv[MAX_PARGS] = {}; + std::vector argvVector; char **eargv = argv; FILE *fid; - int pargc = 0, eargc = 0, mon = 0; + int eargc = 0, mon = 0; if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != nullptr) ++emess_dat.Prog_name; @@ -450,10 +452,7 @@ int main(int argc, char **argv) { } break; } else if (**argv == '+') { /* + argument */ - if (pargc < MAX_PARGS) - pargv[pargc++] = *argv + 1; - else - emess(1,"overflowed + argument table"); + argvVector.push_back(*argv + 1); } else /* assumed to be input file name(s) */ eargv[eargc++] = *argv; } @@ -473,7 +472,12 @@ int main(int argc, char **argv) { postscale = 0; fscale = 1./fscale; } - if (!(Proj = pj_init(pargc, pargv))) + proj_context_use_proj4_init_rules(nullptr, true); + + // proj historically ignores any datum shift specifier, like nadgrids, towgs84, etc + argvVector.push_back(const_cast("break_cs2cs_recursion")); + + if (!(Proj = proj_create_argv(nullptr, static_cast(argvVector.size()), argvVector.data()))) emess(3,"projection initialization failure\ncause: %s", proj_errno_string(proj_context_errno(nullptr))); -- cgit v1.2.3