We saw above () how to display the
internal values of an Object, but what about accessing these values
from a program? Not all internal Object values are accessible in this
way, but many are. Those that are, are called attributes. A
description of all the attributes used by the AST library can be found
in
.
Attributes come in several data types (character string, integer, boolean and floating point) and there is a standard way of obtaining their values. As an example, consider obtaining the value of the Nin attribute for the ZoomMap created earlier. This could be done as follows:
int nin; ... nin = astGetI( zoommap, "Nin" );
Here, the function astGetI is used to extract the attribute value by giving it the ZoomMap pointer and the attribute name (attribute names are not case sensitive, but we have used consistent capitalisation in this document in order to identify them). Remember to use the ``ast.h'' header file to include the function prototype.
If we had wanted the value of the Zoom attribute, we would probably have used astGetD instead, this being a double version of the same function, for example:
double zoom; ... zoom = astGetD( zoommap, "Zoom" );
However, we could equally well have read the Nin value as double, or the Zoom value as an integer, or whatever we wanted.
The data type you want returned is specified simply by replacing the
final character of the astGetX function name with C (character
string), D (double), F (float), I (int) or L (long). If possible, the
value is converted to the type you want. If not, an error message will
result. Note that all floating point values are stored internally as
double, and all integer values as int. Boolean values are also stored
as integers, but only take the values 1 and 0 (for true/false).
AST A Library for Handling World Coordinate Systems in Astronomy