IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11774


Ignore:
Timestamp:
Feb 13, 2007, 12:11:56 PM (19 years ago)
Author:
jhoblitt
Message:

implement -scmap

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r11773 r11774  
    5252#endif
    5353
     54static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    5455static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state);
    5556static bool isValidMode(pxConfig *config, const char *mode);
     
    566567
    567568
    568 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    569 
    570569static bool addoverlapMode(pxConfig *config)
    571570{
     
    670669{
    671670    PS_ASSERT_PTR_NON_NULL(config, NULL);
     671
     672    bool status = false;
     673    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     674    if (!status) {
     675        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     676        return false;
     677    }
     678
     679    // find all rawImfiles matching the default query
     680    psString query = psStringCopy(
     681        "SELECT\n"
     682        "   p4SkyCellMap.*\n"
     683        " FROM p4Run\n"
     684        " JOIN p4SkyCellMap\n"
     685        "   USING(p4_id)\n"
     686        " WHERE\n"
     687        "   p4Run.state = 'run'\n"
     688    );
     689
     690    if (config->where) {
     691        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4SkyCellMap");
     692        psStringAppend(&query, " AND %s", whereClause);
     693        psFree(whereClause);
     694    }
     695
     696    // treat limit == 0 as "no limit"
     697    if (limit) {
     698        psString limitString = psDBGenerateLimitSQL(limit);
     699        psStringAppend(&query, " %s", limitString);
     700        psFree(limitString);
     701    }
     702
     703    if (!p_psDBRunQuery(config->dbh, query)) {
     704        psError(PS_ERR_UNKNOWN, false, "database error");
     705        psFree(query);
     706        return false;
     707    }
     708    psFree(query);
     709
     710    psArray *output = p_psDBFetchResult(config->dbh);
     711    if (!output) {
     712        psErrorCode err = psErrorCodeLast();
     713        switch (err) {
     714            case PS_ERR_DB_CLIENT:
     715                psError(PXTOOLS_ERR_SYS, false, "database error");
     716            case PS_ERR_DB_SERVER:
     717                psError(PXTOOLS_ERR_PROG, false, "database error");
     718            default:
     719                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     720        }
     721
     722        return false;
     723    }
     724    if (!psArrayLength(output)) {
     725        psError(PS_ERR_UNKNOWN, false, "no p4SkyCellMap rows found");
     726        psFree(output);
     727        return true;
     728    }
     729
     730    bool simple = false;
     731    {
     732        bool status = false;
     733        simple = psMetadataLookupBool(&status, config->args, "-simple");
     734        if (!status) {
     735            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     736            return false;
     737        }
     738    }
     739
     740    if (psArrayLength(output)) {
     741        // negative simple so the default is true
     742        if (!ippdbPrintMetadatas(stdout, output, "p4SkyCellMap", !simple)) {
     743            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     744            psFree(output);
     745            return false;
     746        }
     747    }
     748
     749    psFree(output);
     750
    672751    return true;
    673752}
  • trunk/ippTools/src/warptoolConfig.c

    r11769 r11774  
    356356    }
    357357}
     358    addWhereStr(skycell_id);
     359    addWhereStr(tess_id);
     360    addWhereStr(exp_tag);
    358361
    359362    if (config->where->list->n < 1) {
Note: See TracChangeset for help on using the changeset viewer.