IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2007, 3:46:12 PM (18 years ago)
Author:
jhoblitt
Message:

impliemnt -flatcorrimfile

File:
1 edited

Legend:

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

    r15695 r15755  
    3535static bool newrunMode(pxConfig *config);
    3636static bool pendingMode(pxConfig *config);
     37static bool flatcorrimfileMode(pxConfig *config);
    3738static bool updateMode(pxConfig *config);
    3839
     
    5960        MODECASE(FLATCORR_MODE_NEWRUN,      newrunMode);
    6061        MODECASE(FLATCORR_MODE_PENDING,     pendingMode);
     62        MODECASE(FLATCORR_MODE_FLATCORRIMFILE, flatcorrimfileMode);
    6163        MODECASE(FLATCORR_MODE_UPDATE,      updateMode);
    6264        default:
     
    429431}
    430432
     433
     434static bool flatcorrimfileMode(pxConfig *config)
     435{
     436    PS_ASSERT_PTR_NON_NULL(config, false);
     437
     438
     439    bool status = false;
     440    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     441    if (!status) {
     442        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     443        return false;
     444    }
     445
     446    // find all rawImfiles matching the default query
     447    psString query = pxDataGet("flatcorr_find_processedimfiles.sql");
     448    if (!query) {
     449        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     450        return false;
     451    }
     452
     453    if (config->where) {
     454        psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     455        psStringAppend(&query, " AND %s", whereClause);
     456        psFree(whereClause);
     457    }
     458
     459    // treat limit == 0 as "no limit"
     460    if (limit) {
     461        psString limitString = psDBGenerateLimitSQL(limit);
     462        psStringAppend(&query, " %s", limitString);
     463        psFree(limitString);
     464    }
     465
     466    if (!p_psDBRunQuery(config->dbh, query)) {
     467        psError(PS_ERR_UNKNOWN, false, "database error");
     468        psFree(query);
     469        return false;
     470    }
     471    psFree(query);
     472   
     473    psArray *output = p_psDBFetchResult(config->dbh);
     474    if (!output) {
     475        psErrorCode err = psErrorCodeLast();
     476        switch (err) {
     477            case PS_ERR_DB_CLIENT:
     478                psError(PXTOOLS_ERR_SYS, false, "database error");
     479            case PS_ERR_DB_SERVER:
     480                psError(PXTOOLS_ERR_PROG, false, "database error");
     481            default:
     482                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     483        }
     484   
     485        return false;
     486    }
     487    if (!psArrayLength(output)) {
     488        psTrace("warptool", PS_LOG_INFO, "no rows found");
     489        psFree(output);
     490        return true;
     491    }
     492
     493    bool simple = false;
     494    {
     495        bool status = false;
     496        simple = psMetadataLookupBool(&status, config->args, "-simple");
     497        if (!status) {            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     498            return false;
     499        }
     500    }
     501
     502    if (psArrayLength(output)) {
     503        if (!convertIdToStr(output)) {
     504            psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     505            psFree(output);
     506            return false;
     507        }
     508
     509        // negative simple so the default is true
     510        if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
     511            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     512            psFree(output);
     513            return false;
     514        }
     515    }
     516
     517    psFree(output);
     518
     519    return true;
     520}
     521
     522
    431523static bool updateMode(pxConfig *config)
    432524{
Note: See TracChangeset for help on using the changeset viewer.