IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16105


Ignore:
Timestamp:
Jan 16, 2008, 5:28:06 PM (18 years ago)
Author:
jhoblitt
Message:

convert to PXOPT_* macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/end_stage/ippTools/src/detselect.c

    r15857 r16105  
    7171}
    7272
     73#define ADDRENAMEPARAMF(from, to, type, oldname, newname, comment) \
     74{ \
     75    bool status = false; \
     76    ps##type var = psMetadataLookup##type(&status, from, oldname); \
     77    if (!status) { \
     78        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for " oldname); \
     79        return false; \
     80    } \
     81    if (!isnan(var)) { \
     82        if (!psMetadataAdd##type(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
     83            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
     84            psFree(to); \
     85            return false; \
     86        } \
     87    } \
     88}
     89
     90#define ADDPARAMF(from, to, type, name) \
     91  ADDRENAMEPARAMF(from, to, type, name, name, "==")
     92
     93
    7394static bool searchMode(pxConfig *config)
    7495{
    7596    PS_ASSERT_PTR_NON_NULL(config, false);
    7697
     98    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     99    PXOPT_LOOKUP_BOOL(unlimit, config->args, "-unlimit", false);
     100
    77101    psMetadata *where = psMetadataAlloc();
    78102
    79103    // airmass_min  < airmass  < airmass_max
    80     {
    81         bool status = false;
    82         psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass");
    83         if (!status) {
    84             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass");
    85             psFree(where);
    86             return false;
    87         }
    88 
    89         if (!isnan(airmass)) {
    90             psMetadataAddF32(where, PS_LIST_TAIL, "airmass_min", 0, "<=", airmass);
    91             psMetadataAddF32(where, PS_LIST_TAIL, "airmass_max", 0, ">=", airmass);
    92         }
    93     }
     104    ADDRENAMEPARAMF(config->args, where, F32, "-airmass", "airmass_min", "<=");
     105    ADDRENAMEPARAMF(config->args, where, F32, "-airmass", "airmass_max", ">=");
    94106
    95107    // exp_time_min < exp_time < exp_time_max
    96     {
    97         bool status = false;
    98         psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time");
    99         if (!status) {
    100             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time");
    101             psFree(where);
    102             return false;
    103         }
    104 
    105         if (!isnan(exp_time)) {
    106             psMetadataAddF32(where, PS_LIST_TAIL, "exp_time_min", 0, "<=", exp_time);
    107             psMetadataAddF32(where, PS_LIST_TAIL, "exp_time_max", 0, ">=", exp_time);
    108         }
    109     }
     108    ADDRENAMEPARAMF(config->args, where, F32, "-exp_time", "exp_time_min", "<=");
     109    ADDRENAMEPARAMF(config->args, where, F32, "-exp_time", "exp_time_max", ">=");
    110110
    111111    // ccd_temp_min < ccd_temp < ccd_temp_max
    112     {
    113         bool status = false;
    114         psF32 ccd_temp = psMetadataLookupF32(&status, config->args, "-ccd_temp");
    115         if (!status) {
    116             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp");
    117             psFree(where);
    118             return false;
    119         }
    120 
    121         if (!isnan(ccd_temp)) {
    122             psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp_min", 0, "<=", ccd_temp);
    123             psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp_max", 0, ">=", ccd_temp);
    124         }
    125     }
    126 
    127     {
    128         bool status = false;
    129         psF64 posang = psMetadataLookupF64(&status, config->args, "-posang");
    130         if (!status) {
    131             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang");
    132             psFree(where);
    133             return false;
    134         }
    135 
    136         if (!isnan(posang)) {
    137             psMetadataAddF32(where, PS_LIST_TAIL, "posang_min", 0, "<=", posang);
    138             psMetadataAddF32(where, PS_LIST_TAIL, "posang_max", 0, ">=", posang);
    139         }
    140     }
     112    ADDRENAMEPARAMF(config->args, where, F32, "-ccd_temp", "ccd_temp_min", "<=");
     113    ADDRENAMEPARAMF(config->args, where, F32, "-ccd_temp", "ccd_temp_max", ">=");
     114
     115    ADDRENAMEPARAMF(config->args, where, F64, "-posang", "posang_min", "<=");
     116    ADDRENAMEPARAMF(config->args, where, F64, "-posang", "posang_max", ">=");
    141117
    142118    // time_begin    < time     < time_end
     
    189165    }
    190166
    191     // we choose the single detrend image which matches all criteria and has the latest
    192     // insertion date
     167    // we choose the single detrend image which matches all criteria and has
     168    // the latest insertion date
    193169
    194170    // unless explicitly specified by the user, list all possible matches
    195     if (!psMetadataLookupBool(NULL, config->args, "-unlimit")) {
    196         psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
     171    if (!unlimit) {
     172        psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
    197173    }
    198174
     
    216192    }
    217193
    218     bool simple = false;
    219     {
    220         bool status = false;
    221         simple = psMetadataLookupBool(&status, config->args, "-simple");
    222         if (!status) {
    223             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    224             return false;
    225         }
    226     }
    227 
    228194    // negate simple so the default is true
    229195    if (!ippdbPrintMetadatas(stdout, output, "detExp", !simple)) {
     
    241207{
    242208    PS_ASSERT_PTR_NON_NULL(config, false);
     209
     210    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    243211
    244212    psString query = pxDataGet("detselect_select.sql");
     
    274242    }
    275243
    276     bool simple = false;
    277     {
    278         bool status = false;
    279         simple = psMetadataLookupBool(&status, config->args, "-simple");
    280         if (!status) {
    281             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    282             return false;
    283         }
    284     }
    285 
    286244    // negative simple so the default is true
    287245    if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) {
Note: See TracChangeset for help on using the changeset viewer.