IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/warptool.c

    r18336 r18561  
    109109{
    110110    PS_ASSERT_PTR_NON_NULL(config, false);
    111 
    112     // required options
    113     PXOPT_LOOKUP_S64(fake_id, config->args, "-fake_id", true, false);
    114     PXOPT_LOOKUP_STR(mode, config->args, "-mode", true, false);
    115     // check mode
    116     if (mode && !isValidMode(config, mode)) {
    117         psError(PS_ERR_UNKNOWN, false, "invalud mode");
    118         return false;
    119     }
    120     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
    121 
    122     // optional
     111   
     112    PXOPT_LOOKUP_S64(fake_id, config->args, "-fake_id", true, false); // required
     113    PXOPT_LOOKUP_STR(mode, config->args, "-mode", true, false); // required
     114    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required
    123115    PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
    124116    PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false);
    125117    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false);
    126118    PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false);
    127 
    128     // default
    129119    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    130120    PXOPT_LOOKUP_BOOL(magiced, config->args, "-magiced", false);
    131121    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     122
     123    // check mode
     124    if (mode && !isValidMode(config, mode)) {
     125        psError(PS_ERR_UNKNOWN, false, "invalid mode");
     126        return false;
     127    }
    132128
    133129    warpRunRow *warpRun = warpRunRowAlloc(
     
    190186    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
    191187    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
    192 
    193     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
    194     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     188    PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">=");
     189    PXOPT_COPY_F32(config->args, where, "-airmass_max", "airmass", "<");
    195190    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
    196191    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     
    211206    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
    212207    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
    213     PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
    214     PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
     208    PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
     209    PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
    215210    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
    216211    PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     
    262257    PS_ASSERT_PTR_NON_NULL(config, false);
    263258
     259    psMetadata *where = psMetadataAlloc();
     260    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     261    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     262
    264263    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    265264    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    272271    }
    273272
    274     if (config->where) {
    275         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpRun");
     273    if (psListLength(where->list)) {
     274        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpRun");
    276275        psStringAppend(&query, " AND %s", whereClause);
    277276        psFree(whereClause);
    278277    }
     278    psFree(where);
    279279
    280280    // treat limit == 0 as "no limit"
     
    331331    PS_ASSERT_PTR_NON_NULL(config, false);
    332332
     333    psMetadata *where = psMetadataAlloc();
     334    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     335    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     336
    333337    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    334338    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    341345    }
    342346
    343     if (config->where) {
    344         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpRun");
     347    if (psListLength(where->list)) {
     348        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpRun");
    345349        psStringAppend(&query, " AND %s", whereClause);
    346350        psFree(whereClause);
    347351    }
     352    psFree(where);
    348353
    349354    // treat limit == 0 as "no limit"
     
    400405    PS_ASSERT_PTR_NON_NULL(config, false);
    401406
     407    psMetadata *where = psMetadataAlloc();
     408    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     409
    402410    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    403411    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    410418    }
    411419
    412     if (config->where) {
    413         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpRun");
     420    if (psListLength(where->list)) {
     421        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpRun");
    414422        psStringAppend(&query, " AND %s", whereClause);
    415423        psFree(whereClause);
    416424    }
     425    psFree(where);
    417426
    418427    // treat limit == 0 as "no limit"
     
    571580    PS_ASSERT_PTR_NON_NULL(config, false);
    572581
     582    psMetadata *where = psMetadataAlloc();
     583    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     584    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     585    PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
     586
    573587    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    574588    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    581595    }
    582596
    583     if (config->where) {
    584         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyCellMap");
     597    if (psListLength(where->list)) {
     598        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpSkyCellMap");
    585599        psStringAppend(&query, " AND %s", whereClause);
    586600        psFree(whereClause);
    587601    }
     602    psFree(where);
    588603
    589604    // treat limit == 0 as "no limit"
     
    635650}
    636651
    637 
    638652static bool towarpedMode(pxConfig *config)
    639653{
    640654    PS_ASSERT_PTR_NON_NULL(config, false);
     655
     656    psMetadata *where = psMetadataAlloc();
     657    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
    641658
    642659    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    650667    }
    651668
    652     if (config->where) {
    653         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyCellMap");
     669    if (psListLength(where->list)) {
     670        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpSkyCellMap");
    654671        psStringAppend(&query, " AND %s", whereClause);
    655672        psFree(whereClause);
    656673    }
     674    psFree(where);
    657675
    658676    // treat limit == 0 as "no limit"
     
    891909    PS_ASSERT_PTR_NON_NULL(config, false);
    892910
     911    psMetadata *where = psMetadataAlloc();
     912    PXOPT_COPY_S64(config->args, where, "-warp_id",    "warp_id", "==");
     913    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     914    PXOPT_COPY_STR(config->args, where, "-tess_id",    "tess_id", "==");
     915    PXOPT_COPY_S64(config->args, where, "-exp_id",     "exp_id", "==");
     916    PXOPT_COPY_S64(config->args, where, "-fake_id",    "fake_id", "==");
     917
    893918    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    894919    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    901926    }
    902927
    903     if (config->where) {
    904         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyfile");
     928    if (psListLength(where->list)) {
     929        psString whereClause = psDBGenerateWhereConditionSQL(where, "warpSkyfile");
    905930        psStringAppend(&query, " AND %s", whereClause);
    906931        psFree(whereClause);
    907932    }
     933    psFree(where);
    908934
    909935    // treat limit == 0 as "no limit"
     
    962988    psMetadata *where = psMetadataAlloc();
    963989    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     990    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     991    PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
    964992    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
    965993    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    966994    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    967     PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
    968     PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
    969995
    970996    // XXX These may need to be updated with the table name?
     
    9801006    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
    9811007
    982     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
    983     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     1008    PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">=");
     1009    PXOPT_COPY_F32(config->args, where, "-airmass_max", "airmass", "<");
    9841010    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
    9851011    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     
    10001026    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
    10011027    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
    1002     PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
    1003     PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
     1028    PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
     1029    PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
    10041030    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
    10051031    PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     
    10071033    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
    10081034    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
    1009 //    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
     1035    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
    10101036
    10111037    if (!psListLength(where->list)
Note: See TracChangeset for help on using the changeset viewer.