TwiceAsNice  2019-02-18
Functions
Formatting Functions: Functions to perform handy formatting and conversion routines.

Functions

int fs_sexa (char *out, double a, int w, int fracbase)
 Converts a sexagesimal number to a string. More...
 
int f_scansexa (const char *str0, double *dp)
 convert sexagesimal string str AxBxC to double. More...
 
int extractISOTime (const char *timestr, struct ln_date *iso_date)
 Extract ISO 8601 time and store it in a tm struct. More...
 
void getSexComponents (double value, int *d, int *m, int *s)
 
void getSexComponentsIID (double value, int *d, int *m, double *s)
 
int numberFormat (char *buf, const char *format, double value)
 Fill buffer with properly formatted INumber string. More...
 
const char * timestamp ()
 Create an ISO 8601 formatted time stamp. More...
 
double rangeHA (double r)
 rangeHA Limits the hour angle value to be between -12 —> 12 More...
 
double range24 (double r)
 range24 Limits a number to be between 0-24 range. More...
 
double range360 (double r)
 range360 Limits an angle to be between 0-360 degrees. More...
 
double rangeDec (double r)
 rangeDec Limits declination value to be in -90 to 90 range. More...
 
double get_local_sidereal_time (double longitude)
 get_local_sidereal_time Returns local sideral time given longitude and system clock. More...
 
double get_local_hour_angle (double local_sideral_time, double ra)
 get_local_hour_angle Returns local hour angle of an object More...
 

Detailed Description

Function Documentation

◆ extractISOTime()

int extractISOTime ( const char *  timestr,
struct ln_date *  iso_date 
)

Extract ISO 8601 time and store it in a tm struct.

Parameters
timestra string containing date and time in ISO 8601 format.
iso_datea pointer to a ln_date structure to store the extracted time and date (libnova).
Returns
0 on success, -1 on failure.

◆ f_scansexa()

int f_scansexa ( const char *  str0,
double *  dp 
)

convert sexagesimal string str AxBxC to double.

x can be anything non-numeric. Any missing A, B or C will be assumed 0. Optional - and + can be anywhere.

Parameters
str0string containing sexagesimal number.
dppointer to a double to store the sexagesimal number.
Returns
return 0 if ok, -1 if can't find a thing.

◆ fs_sexa()

int fs_sexa ( char *  out,
double  a,
int  w,
int  fracbase 
)

Converts a sexagesimal number to a string.

sprint the variable a in sexagesimal format into out[].

Parameters
outa pointer to store the sexagesimal number.
athe sexagesimal number to convert.
wthe number of spaces in the whole part.
fracbaseis the number of pieces a whole is to broken into; valid options:
  • 360000: <w>:mm:ss.ss
  • 36000: <w>:mm:ss.s
  • 3600: <w>:mm:ss
  • 600: <w>:mm.m
  • 60: <w>:mm
Returns
number of characters written to out, not counting final null terminator.

◆ get_local_hour_angle()

double get_local_hour_angle ( double  local_sideral_time,
double  ra 
)

get_local_hour_angle Returns local hour angle of an object

Parameters
local_sideral_timeLocal Sideral Time
raRA of object
Returns
Hour angle in hours (-12 to 12)

◆ get_local_sidereal_time()

double get_local_sidereal_time ( double  longitude)

get_local_sidereal_time Returns local sideral time given longitude and system clock.

Parameters
longitudeLongitude in INDI format (0 to 360) increasing eastward.
Returns
Local Sidereal Time.

◆ getSexComponents()

void getSexComponents ( double  value,
int *  d,
int *  m,
int *  s 
)

◆ getSexComponentsIID()

void getSexComponentsIID ( double  value,
int *  d,
int *  m,
double *  s 
)

◆ numberFormat()

int numberFormat ( char *  buf,
const char *  format,
double  value 
)

Fill buffer with properly formatted INumber string.

Parameters
bufto store the formatted string.
formatformat in sprintf style.
valuethe number to format.
Returns
length of string.
Note
buf must be of length MAXINDIFORMAT at minimum

◆ range24()

double range24 ( double  r)

range24 Limits a number to be between 0-24 range.

Parameters
rnumber to be limited
Returns
Limited number

◆ range360()

double range360 ( double  r)

range360 Limits an angle to be between 0-360 degrees.

Parameters
rangle
Returns
Limited angle

◆ rangeDec()

double rangeDec ( double  r)

rangeDec Limits declination value to be in -90 to 90 range.

Parameters
rdeclination angle
Returns
limited declination

◆ rangeHA()

double rangeHA ( double  r)

rangeHA Limits the hour angle value to be between -12 —> 12

Parameters
rcurrent hour angle value
Returns
Limited value (-12,12)

◆ timestamp()

const char * timestamp ( )

Create an ISO 8601 formatted time stamp.

The format is YYYY-MM-DDTHH:MM:SS

Returns
The formatted time stamp.