static double StrDegreesToDouble( char * str, int mode ); static char * DoubleToStrDegrees( double arc, Boolean hours ); static void StrRADecToStrAZAlt( char * ra, char * dec ); static void StrAZAltToStrRADec( char * az, char * alt ); //avoids a string in the form 000:00:00 which //contains degrees:arcminutes:arcseconds, or hours:minutes:seconds //mode == 0:converts it to the complete number of arcseconds, //mode == 1:converts it to a number of hours //mode == 2:converts it to a number of degrees //which are returned as double //if an error it returns value -1 static double StrDegreesToDouble( char * str, int mode ) { double d,m,s,v; char *p1,*p2,*p3; int ct; StrCopy(&tmptext[0],(const char *)str); ct = 0; p1 = &tmptext[0]; while( (p1[0] == 0x20) && (ct < 4)){ p1++;ct++; } p2 = NULL; p3 = NULL; p2 = StrChr(p1,':'); if(p2 != NULL){ p2[0] = 0; p2++; ct = 0; while((p2[0] == 0x20) && (ct < 2 )){ p2++;ct++; } if( (p2[0] >= '0') && (p2[0] <= '9') ){ p3 = StrChr(p2,':'); if(p3 != NULL){ p3[0] = 0; p3++; ct = 0; while((p3[0] == 0x20) && (ct < 2 )){ p3++;ct++; } if( (p3[0] < '0') || (p3[0] > '9') ){ p3 = NULL; } } } else { p2 = NULL; } } d = 0; m=0; s=0; v = 0; if(strToDouble((const char*) p1, &d) == false){ return(-1); } if(p2 != NULL){ if(strToDouble((const char*) p2, &m) == false){ return(-1); } } if(p3 != NULL){ if(strToDouble((const char*) p3, &s) == false){ return(-1); } } if(mode == 0){ if(d != 0){ d = d * 3600; } if(m != 0){ m = m * 60; } v = d + m + s; return(v); } if(mode == 1){ if(m != 0){ m = m / 60; } if(s != 0){ s = s / 3600; } v = d + m + s; return(v); } if(mode == 2){ if(m != 0){ m = m / 60; } if(s != 0){ s = s / 3600; } v = d + m + s; return(v); } return(v); } //avoids a double which //contains a number of arcseconds. //converts it to a string of the form 000:00:00 //which are returned as pointer //if an error it returns NULL //if flag hours is set to true, it will not be convertert //to a string representating degrees, instead hours:minutes:seconds static char * DoubleToStrDegrees( double arc, Boolean hours ) { double d,t,m,s,v; char *pa,*pb,*pc,*p; Int16 la,lb,lc; v = arc; if( hours ) { v = arc / 15.0; } d = v / 3600; d = makeAbsoluteDouble(d); t = d * 3600; v = v - t; m = v / 60; m = makeAbsoluteDouble( m ); t = m * 60; s = v - t; s = makeAbsoluteDouble(s); if(d < 0 ){ if( m < 0 ){ m = m * -1; } if( s < 0 ){ s = s * -1; } } printDouble(d,&tmptext[0]); printDouble(m,&tmptext[10]); printDouble(s,&tmptext[20]); pa = &tmptext[0]; pb = &tmptext[10]; pc = &tmptext[20]; la = StrLen(pa); lb = StrLen(pb); lc = StrLen(pc); if(la > 4){ pa = &tmptext[ 0 + la ] - 4; la = 4; } if(lb > 2){ pb = &tmptext[ 10 + lb ] - 2; lb = 2; } if(lc > 2){ pc = &tmptext[ 20 + lc ] - 2; lc = 2; } StrCopy(&unitext[0],(const Char *)"0000:00:00\0"); if(la > 0){ p = &unitext[4] - la; StrCopy(p,(const Char *)pa); } if(lb > 0){ p = &unitext[7] - lb; StrCopy(p,(const Char *)pb); } if(lc > 0){ p = &unitext[10] - lc; StrCopy(p,(const Char *)pc); } unitext[4] = ':'; unitext[7] = ':'; p = &unitext[0]; la = 0; while( (p[0] == '0') && ( la < 3 ) ){ p++; la++; } return( p ); } //avoids a string like 00:00:00 containing ra-koodinates, and also for declination //converts it to azimuth/altitude,koordinates wich are stored to the variables //azimuth, and altitude. ( this can be convertet later with DoubleToStrDegrees. //ra must be given as hours //dec must be given as degrees static void StrRADecToStrAZAlt( char * ra, char * dec ) { double rah,decd; //convert ra to rah ( hours ) //convert dec to decd ( degrees ) rah = StrDegreesToDouble( ra , 1 ); decd = StrDegreesToDouble( dec, 2 ); cCurrentStarTime( scope.utcadjust, scope.longitude, 0 ); cAzAlt( scope.latitude, rah, decd ); } //avoids a string like 000:00:00 containing az-koodinates, and also for altitude //converts it to rectaszension/declination ,koordinates wich are stored to the variables //rectaszension, and declination. ( this can be convertet later with DoubleToStrDegrees //az must be given as degrees //alt must be given as degrees static void StrAZAltToStrRADec( char * az, char * alt ) { double azd,altd; azd = StrDegreesToDouble( az , 2 ); altd = StrDegreesToDouble( alt, 2 ); cCurrentStarTime( scope.utcadjust, scope.longitude, 0 ); cRaDec( scope.latitude, azd, altd ); }