1
/* Convert radian argument to DMS ascii format */
3
static const char SCCSID[]="@(#)rtodms.c 4.3 93/06/12 GIE REL";
9
** RES is fractional second figures
11
** CONV = 180 * 3600 * RES / PI (radians to RES seconds)
16
CONV = 206264806.24709635515796003417;
18
format[50] = "%dd%d'%.3f\"%c";
22
set_rtodms(int fract, int con_w) {
25
if (fract >= 0 && fract < 9 ) {
27
/* following not very elegant, but used infrequently */
28
for (i = 0; i < fract; ++i)
31
CONV = 180. * 3600. * RES / PI;
33
(void)sprintf(format,"%%dd%%d'%%.%df\"%%c", fract);
35
(void)sprintf(format,"%%dd%%02d'%%0%d.%df\"%%c",
36
fract+2+(fract?1:0), fract);
41
rtodms(char *s, double r, int pos, int neg) {
48
if (!pos) { *ss++ = '-'; sign = 0; }
52
r = floor(r * CONV + .5);
53
sec = fmod(r / RES, 60.);
58
(void)sprintf(ss,format,deg,min,sec,sign);
62
(void)sprintf(ss,format,deg,min,sec,sign);
63
for (q = p = ss + strlen(ss) - (sign ? 3 : 2); *p == '0'; --p) ;
69
(void)sprintf(ss,"%dd%d'%c",deg,min,sign);
71
(void)sprintf(ss,"%dd%c",deg, sign);