Skip to content

Commit

Permalink
1.0.6: Proj string output
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jun 26, 2022
1 parent d394723 commit 6e9ec0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/helmeltrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -124,7 +124,7 @@ int main(int argc, char* argv[])
}
else
ofile = stdout;

if(ofile == NULL)
{
fprintf(stderr,"Error writing %s\n",ofilename);
Expand All @@ -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)
{
Expand Down
5 changes: 4 additions & 1 deletion src/helmert3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#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
9 changes: 8 additions & 1 deletion src/helmparms3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down

1 comment on commit 6e9ec0d

@zvezdochiot
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dr-ni .

Source: #5 (comment)

$ ./helmparms3d LGS21-XYZ.txt GRS80-XYZ.txt LGS21-GRS80.txt 

*******************************
*      helmparms3d v1.0.6     *
*   (c) U. Niethammer 2021    *
*******************************
LGS21-XYZ.txt:
3304034.3490459998 1283287.9191079999 5283949.4887509998 
3276692.9020600002 1309439.4641430001 5294477.9373279996 
3239550.2130729998 1370905.5592650000 5301722.4823249998 
3235514.1377170002 1410203.9334880000 5293926.4333119998 
3216604.6092050001 1453413.5190610001 5293764.2016519997 
3185805.5211020000 1495931.7423080001 5300495.0485579995 
3203758.3981829998 1530897.0280950000 5279789.2733049998 
3205584.8743250002 1579067.5206750000 5264573.8426959999 
3220595.9118769998 1614015.5588100001 5244909.0321549997 
3182272.7297210000 1424090.0228889999 5322215.1343620000 
3182272.1184680001 1424090.5639820001 5322215.3535890002 

GRS80-XYZ.txt:
3304502.1147460002 1283492.3329030001 5284443.3995580003 
3277159.6720739999 1309642.5787430000 5294972.9819120001 
3240015.7178949998 1371108.1066350001 5302218.5273949997 
3235978.2911339998 1410406.2354860001 5294423.1104520001 
3217068.8608690002 1453615.7774700001 5294260.8565339996 
3186268.6674410002 1496134.1354350001 5300992.6273670001 
3204220.0920139998 1531098.5640900000 5280287.4481279999 
3206044.0709199999 1579268.6103780000 5265073.4168819999 
3221055.7549939998 1614217.6244659999 5245407.5472219996 
3182737.9470930002 1424292.5250919999 5322712.0058840001 
3182737.3587659998 1424293.0765640000 5322712.2087420002 

R =
0.9999999996 -0.0000220952 0.0000160236 
0.0000220953 0.9999999997 -0.0000091965 
-0.0000160234 0.0000091969 0.9999999998 

T =
419.6398186970 183.7356435974 549.3785472015 

s = 0.9999973306 (= -2.6694413159 ppm)

Proj string:
+towgs84=419.640,183.736,549.379,1.897,3.305,4.557,-2.669

Results written to LGS21-GRS80.txt
...done

See +towgs84=419.640,183.736,549.379,1.897,3.305,4.557,-2.669

Please sign in to comment.