#include "wcserr.h"
Go to the source code of this file.
Data Structures | |
struct | tabprm |
Tabular transformation parameters. More... | |
Defines | |
#define | TABLEN (sizeof(struct tabprm)/sizeof(int)) |
Size of the tabprm struct in int units. | |
#define | tabini_errmsg tab_errmsg |
Deprecated. | |
#define | tabcpy_errmsg tab_errmsg |
Deprecated. | |
#define | tabfree_errmsg tab_errmsg |
Deprecated. | |
#define | tabprt_errmsg tab_errmsg |
Deprecated. | |
#define | tabset_errmsg tab_errmsg |
Deprecated. | |
#define | tabx2s_errmsg tab_errmsg |
Deprecated. | |
#define | tabs2x_errmsg tab_errmsg |
Deprecated. | |
Enumerations | |
enum | tab_errmsg_enum { TABERR_SUCCESS = 0, TABERR_NULL_POINTER = 1, TABERR_MEMORY = 2, TABERR_BAD_PARAMS = 3, TABERR_BAD_X = 4, TABERR_BAD_WORLD = 5 } |
Functions | |
int | tabini (int alloc, int M, const int K[], struct tabprm *tab) |
Default constructor for the tabprm struct. | |
int | tabmem (struct tabprm *tab) |
Acquire tabular memory. | |
int | tabcpy (int alloc, const struct tabprm *tabsrc, struct tabprm *tabdst) |
Copy routine for the tabprm struct. | |
int | tabfree (struct tabprm *tab) |
Destructor for the tabprm struct. | |
int | tabprt (const struct tabprm *tab) |
Print routine for the tabprm struct. | |
int | tabset (struct tabprm *tab) |
Setup routine for the tabprm struct. | |
int | tabx2s (struct tabprm *tab, int ncoord, int nelem, const double x[], double world[], int stat[]) |
Pixel-to-world transformation. | |
int | tabs2x (struct tabprm *tab, int ncoord, int nelem, const double world[], double x[], int stat[]) |
World-to-pixel transformation. | |
Variables | |
const char * | tab_errmsg [] |
Status return messages. |
tabini(), tabmem(), tabcpy(), and tabfree() are provided to manage the tabprm struct, and another, tabprt(), to print its contents.
A setup routine, tabset(), computes intermediate values in the tabprm struct from parameters in it that were supplied by the user. The struct always needs to be set up by tabset() but it need not be called explicitly - refer to the explanation of tabprm::flag.
tabx2s() and tabs2x() implement the WCS tabular coordinate transformations.
Accuracy:
No warranty is given for the accuracy of these routines (refer to the copyright notice); intending users must satisfy for themselves their adequacy for the intended purpose. However, closure effectively to within double precision rounding error was demonstrated by test routine ttab.c which accompanies this software.
#define TABLEN (sizeof(struct tabprm)/sizeof(int)) |
Size of the tabprm struct in int units, used by the Fortran wrappers.
#define tabini_errmsg tab_errmsg |
#define tabcpy_errmsg tab_errmsg |
#define tabfree_errmsg tab_errmsg |
#define tabprt_errmsg tab_errmsg |
#define tabset_errmsg tab_errmsg |
#define tabx2s_errmsg tab_errmsg |
#define tabs2x_errmsg tab_errmsg |
enum tab_errmsg_enum |
int tabini | ( | int | alloc, | |
int | M, | |||
const int | K[], | |||
struct tabprm * | tab | |||
) |
tabini() allocates memory for arrays in a tabprm struct and sets all members of the struct to default values.
PLEASE NOTE: every tabprm struct should be initialized by tabini(), possibly repeatedly. On the first invokation, and only the first invokation, the flag member of the tabprm struct must be set to -1 to initialize memory management, regardless of whether tabini() will actually be used to allocate memory.
[in] | alloc | If true, allocate memory unconditionally for arrays in the tabprm struct. If false, it is assumed that pointers to these arrays have been set by the user except if they are null pointers in which case memory will be allocated for them regardless. (In other words, setting alloc true saves having to initalize these pointers to zero.) |
[in] | M | The number of tabular coordinate axes. |
[in] | K | Vector of length M whose elements record the lengths of the axes of the coordinate array and of each indexing vector. M and K[] are used to determine the length of the various tabprm arrays and therefore the amount of memory to allocate for them. Their values are copied into the tabprm struct. It is permissible to set K (i.e. the address of the array) to zero which has the same effect as setting each element of K[] to zero. In this case no memory will be allocated for the index vectors or coordinate array in the tabprm struct. These together with the K vector must be set separately before calling tabset(). |
[in,out] | tab | Tabular transformation parameters. Note that, in order to initialize memory management tabprm::flag should be set to -1 when tab is initialized for the first time (memory leaks may result if it had already been initialized). |
int tabmem | ( | struct tabprm * | tab | ) |
tabmem() takes control of memory allocated by the user for arrays in the tabprm struct.
[in,out] | tab | Tabular transformation parameters. |
tabcpy() does a deep copy of one tabprm struct to another, using tabini() to allocate memory for its arrays if required. Only the "information to be provided" part of the struct is copied; a call to tabset() is required to set up the remainder.
[in] | alloc | If true, allocate memory unconditionally for arrays in the tabprm struct. If false, it is assumed that pointers to these arrays have been set by the user except if they are null pointers in which case memory will be allocated for them regardless. (In other words, setting alloc true saves having to initalize these pointers to zero.) |
[in] | tabsrc | Struct to copy from. |
[in,out] | tabdst | Struct to copy to. tabprm::flag should be set to -1 if tabdst was not previously initialized (memory leaks may result if it was previously initialized). |
int tabfree | ( | struct tabprm * | tab | ) |
tabfree() frees memory allocated for the tabprm arrays by tabini(). tabini() records the memory it allocates and tabfree() will only attempt to free this.
PLEASE NOTE: tabfree() must not be invoked on a tabprm struct that was not initialized by tabini().
[out] | tab | Coordinate transformation parameters. |
int tabprt | ( | const struct tabprm * | tab | ) |
tabprt() prints the contents of a tabprm struct using wcsprintf(). Mainly intended for diagnostic purposes.
[in] | tab | Tabular transformation parameters. |
int tabset | ( | struct tabprm * | tab | ) |
tabset() allocates memory for work arrays in the tabprm struct and sets up the struct according to information supplied within it.
Note that this routine need not be called directly; it will be invoked by tabx2s() and tabs2x() if tabprm::flag is anything other than a predefined magic value.
[in,out] | tab | Tabular transformation parameters. |
int tabx2s | ( | struct tabprm * | tab, | |
int | ncoord, | |||
int | nelem, | |||
const double | x[], | |||
double | world[], | |||
int | stat[] | |||
) |
tabx2s() transforms intermediate world coordinates to world coordinates using coordinate lookup.
[in,out] | tab | Tabular transformation parameters. |
[in] | ncoord,nelem | The number of coordinates, each of vector length nelem. |
[in] | x | Array of intermediate world coordinates, SI units. |
[out] | world | Array of world coordinates, in SI units. |
[out] | stat | Status return value status for each coordinate:
|
int tabs2x | ( | struct tabprm * | tab, | |
int | ncoord, | |||
int | nelem, | |||
const double | world[], | |||
double | x[], | |||
int | stat[] | |||
) |
tabs2x() transforms world coordinates to intermediate world coordinates.
[in,out] | tab | Tabular transformation parameters. |
[in] | ncoord,nelem | The number of coordinates, each of vector length nelem. |
[in] | world | Array of world coordinates, in SI units. |
[out] | x | Array of intermediate world coordinates, SI units. |
[out] | stat | Status return value status for each vector element:
|
const char * tab_errmsg[] |
Error messages to match the status value returned from each function.