IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5149


Ignore:
Timestamp:
Sep 27, 2005, 9:55:32 AM (21 years ago)
Author:
desonia
Message:

Fixed psFitsUpdateTable to properly handle string and bool values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFits.c

    r5141 r5149  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-27 02:27:28 $
     9 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-27 19:55:32 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7777}
    7878
    79 static bool convertPsTypeToFits(psElemType type, int* bitPix, double* bZero, int* dataType)
     79static bool convertPsTypeToFits(int type, int* bitPix, double* bZero, int* dataType)
    8080{
    8181
     
    9191        break;
    9292
    93     case PS_TYPE_BOOL:
    9493    case PS_TYPE_S8:
    9594        bitpix = BYTE_IMG;
     
    128127        bitpix = DOUBLE_IMG;
    129128        datatype = TDOUBLE;
     129        break;
     130
     131    case PS_DATA_STRING:
     132        bitpix = BYTE_IMG;
     133        datatype = TSTRING;
     134        break;
     135
     136    case PS_DATA_BOOL:
     137        bitpix = BYTE_IMG;
     138        datatype = TLOGICAL;
    130139        break;
    131140
     
    15391548        if (fitsType[strlen(fitsType)-1] == 'A') {
    15401549            // string type -- append length to the type.
    1541             psStringPrepend(&fitsType,"%d",strlen(((psMetadataItem*)columns->data[n])->data.V)+1);
     1550            psStringPrepend(&fitsType,"%d",strlen(((psMetadataItem*)columns->data[n])->data.V));
    15421551        }
    15431552        columnTypes->data[n] = fitsType;
     
    17151724
    17161725    while ( (item=psMetadataGetAndIncrement(iter)) != NULL) {
    1717         if (PS_DATA_IS_PRIMITIVE(item->type) || item->type == PS_DATA_STRING) {
     1726        if (PS_DATA_IS_PRIMITIVE(item->type) ||
     1727                item->type == PS_DATA_BOOL ||
     1728                item->type == PS_DATA_STRING) {
    17181729            // operating on primitive data type or string, i.e., not a complex object
    17191730            int colnum = 0;
     
    17211732            if ( fits_get_colnum(fits->fd, CASESEN, item->name, &colnum, &status) == 0) {
    17221733                // cooresponding column found in table
    1723                 int dataType = TSTRING; // assume string unless it is a primative type
    1724                 if (PS_DATA_IS_PRIMITIVE(item->type)) {
    1725                     convertPsTypeToFits(item->type, NULL, NULL, &dataType);
    1726                 }
     1734                int dataType;
     1735                convertPsTypeToFits(item->type, NULL, NULL, &dataType);
    17271736
    17281737                if (fits_write_col(fits->fd, dataType, colnum, row+1, 1, 1, &item->data,&status) != 0) {
Note: See TracChangeset for help on using the changeset viewer.