11/*
22Name: geositer500.c
3- Version: 2.4
4- Date: 2020-09-28
3+ Version: 2.5
4+ Date: 2021-10-10
55Author: zvezdochiot (https://github.com/zvezdochiot)
66Author: Zoltan Siki (https://github.com/zsiki)
77*
@@ -54,7 +54,7 @@ OKD-12 3.8890 288.39138889 133.60805556
5454#include <string.h>
5555
5656#define PNAME "GeoSIter500"
57- #define PVERSION "2.4 "
57+ #define PVERSION "2.5 "
5858
5959#define defUnits "DEG"
6060
@@ -68,6 +68,7 @@ void geositer500usage()
6868 fprintf (stderr , "usage: geositer500 [option] input-file report-file\n" );
6969 fprintf (stderr , "options:\n" );
7070 fprintf (stderr , " -d N decimal after comma, default=4\n" );
71+ fprintf (stderr , " -r N.N radius Earth, default=6370009.0\n" );
7172 fprintf (stderr , " -u str units angles {RAD,DEG,GON,DMS}, default=DEG\n" );
7273 fprintf (stderr , " -h this help\n" );
7374 fprintf (stderr , "\n" );
@@ -149,12 +150,13 @@ int main(int argc, char *argv[])
149150 int np ;
150151 FILE * fp0 , * fp1 ;
151152
153+ double RE = 6370009.0 ;
154+
152155 int opt ;
153- double PI2 = M_PI / 2.0 ; /* PI/2 */
154156 int decimals = 4 ; /* number of decimals in the calculated coordinates */
155157 int fhelp = 0 ;
156158 units = defUnits ;
157- while ((opt = getopt (argc , argv , "d:u:h" )) != -1 )
159+ while ((opt = getopt (argc , argv , "d:r: u:h" )) != -1 )
158160 {
159161 switch (opt )
160162 {
@@ -164,6 +166,9 @@ int main(int argc, char *argv[])
164166 case 'd' :
165167 decimals = atoi (optarg );
166168 break ;
169+ case 'r' :
170+ RE = atof (optarg );
171+ break ;
167172 case 'u' :
168173 units = optarg ;
169174 break ;
@@ -242,10 +247,10 @@ int main(int argc, char *argv[])
242247 j ++ ;
243248 }
244249 x [1 ] = ANGLEtoRAD (x [1 ], units );
245- x [1 ] = PI2 - x [ 1 ]; ;
250+ x [1 ] -= ( RE > 0.0 ) ? ( x [ 0 ] * sin ( x [ 1 ]) * 0.5 / RE ) : 0.0 ;
246251 x [2 ] = ANGLEtoRAD (x [2 ], units );
247- y [2 ] = x [0 ] * sin (x [1 ]);
248- x [0 ] *= cos (x [1 ]);
252+ y [2 ] = x [0 ] * cos (x [1 ]);
253+ x [0 ] *= sin (x [1 ]);
249254 y [0 ] = x [0 ] * sin (x [2 ]);
250255 y [1 ] = x [0 ] * cos (x [2 ]);
251256 for (i = 0 ; i < 3 ; i ++ )
@@ -279,10 +284,10 @@ int main(int argc, char *argv[])
279284 j ++ ;
280285 }
281286 x [1 ] = ANGLEtoRAD (x [1 ], units );
282- x [1 ] = PI2 - x [ 1 ]; ;
287+ x [1 ] -= ( RE > 0.0 ) ? ( x [ 0 ] * sin ( x [ 1 ]) * 0.5 / RE ) : 0.0 ;
283288 x [2 ] = ANGLEtoRAD (x [2 ], units );
284- y [2 ] = x [0 ] * sin (x [1 ]);
285- x [0 ] *= cos (x [1 ]);
289+ y [2 ] = x [0 ] * cos (x [1 ]);
290+ x [0 ] *= sin (x [1 ]);
286291 y [0 ] = x [0 ] * sin (x [2 ]);
287292 y [1 ] = x [0 ] * cos (x [2 ]);
288293 for (i = 0 ; i < 3 ; i ++ )
0 commit comments