From 6e9ec0dd65d4613e2b4f803e8e9bb6fc537886fc Mon Sep 17 00:00:00 2001 From: zvezdochiot Date: Sat, 25 Jun 2022 23:40:51 +0300 Subject: [PATCH] 1.0.6: Proj string output --- src/helmeltrans.c | 10 +++++----- src/helmert3d.h | 5 ++++- src/helmparms3d.c | 9 ++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/helmeltrans.c b/src/helmeltrans.c index 7ed6aa6..ff6af0f 100644 --- a/src/helmeltrans.c +++ b/src/helmeltrans.c @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } command = argv[1]; - if (!strcmp(command,"xyz")) + if (!strcmp(command,"xyz")) { fprintf(stdout,"B-L-H -> X-Y-Z...\n"); } @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) } else ofile = stdout; - + if(ofile == NULL) { fprintf(stderr,"Error writing %s\n",ofilename); @@ -142,9 +142,9 @@ int main(int argc, char* argv[]) fprintf(stdout,"Ellipsoid %s, a = %lf, b = %lf\n", name, a, b); a2 = a * a; b2 = b * b; - ro = M_PI / 180.0; - roi = 180.0 / M_PI; - if (!strcmp(command,"xyz")) + ro = DEG2RAD; + roi = RAD2DEG; + if (!strcmp(command,"xyz")) { while(fgets( ibuf, 256, ifile)!=NULL) { diff --git a/src/helmert3d.h b/src/helmert3d.h index 0cb3886..6b74d02 100644 --- a/src/helmert3d.h +++ b/src/helmert3d.h @@ -22,9 +22,12 @@ #include #include #include -#define VERS "1.0.5" +#define VERS "1.0.6" #define C_AUTHOR "U. Niethammer" #define C_YEAR "2021" #define DEBUG 0 +#define DEG2RAD (M_PI / 180.0) +#define RAD2DEG (180 / M_PI) +#define RAD2SEC (RAD2DEG * 3600) #endif // HELMERT3D_H diff --git a/src/helmparms3d.c b/src/helmparms3d.c index 7c5e7e2..5ee1e06 100644 --- a/src/helmparms3d.c +++ b/src/helmparms3d.c @@ -288,6 +288,7 @@ int main(int argc, char* argv[]) double **R_mat=NULL; double trace1=0.0, trace2=0.0; double scal=0.0, ppm=0.0; + double rx=0.0, ry=0.0, rz=0.0; FILE *outfile; fprintf(stdout,"\n*******************************\n"); @@ -514,7 +515,7 @@ int main(int argc, char* argv[]) fprintf(stderr,"Error writing %s\n",out_param_name); exit(EXIT_FAILURE); } - + matrix_init(n, m, src_mat_T); matrix_transpose(n, n, R_mat, src_mat_T); fprintf(stdout,"R =\n"); @@ -529,6 +530,12 @@ int main(int argc, char* argv[]) fprintf(stdout,"s = %10.10lf (= %10.10lf ppm)\n\n",scal, ppm); + rx = 0.5 * (src_mat_T[2][1] - src_mat_T[1][2]) * RAD2SEC; + ry = 0.5 * (src_mat_T[0][2] - src_mat_T[2][0]) * RAD2SEC; + rz = 0.5 * (src_mat_T[1][0] - src_mat_T[0][1]) * RAD2SEC; + fprintf(stdout,"Proj string:\n"); + fprintf(stdout,"+towgs84=%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f\n\n", T_vec[0], T_vec[1], T_vec[2], rx, ry, rz, ppm); + if(argc < 4) { fprintf(stdout,"Results matrix:\n");