IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11769


Ignore:
Timestamp:
Feb 12, 2007, 6:58:30 PM (19 years ago)
Author:
jhoblitt
Message:

first pass at p4tool -addoverlap

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r11766 r11769  
    565565}
    566566
     567
     568static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
     569
    567570static bool addoverlapMode(pxConfig *config)
    568571{
    569572    PS_ASSERT_PTR_NON_NULL(config, NULL);
     573
     574    bool status = false;
     575    psString mapfile = psMetadataLookupStr(&status, config->args, "-mapfile");
     576    if (!status) {
     577        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mapfile");
     578        return false;
     579    }
     580    if (!mapfile) {
     581        psError(PS_ERR_UNKNOWN, true, "-mapfile is required");
     582        return false;
     583    }
     584
     585    if (!parseAndInsertSkyCellMap(config, mapfile)) {
     586    }
     587
     588    return true;
     589}
     590
     591
     592static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile)
     593{
     594    unsigned int nFail = 0;
     595    psMetadata *skycells = psMetadataConfigRead(NULL, &nFail, mapfile, false);
     596    if (!skycells) {
     597        psError(PS_ERR_UNKNOWN, false, "failed to parse mapfile: %s", mapfile);
     598        return false;
     599    }       
     600    if (nFail) {
     601        psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing mapfile: %s", nFail, mapfile);
     602        psFree(skycells);
     603        return false;
     604    }
     605
     606    psMetadataItem *item = NULL;
     607    psMetadataIterator *iter = psMetadataIteratorAlloc(skycells, 0, NULL);
     608    if ((item = psMetadataGetAndIncrement(iter))) {
     609        if (item->type != PS_DATA_METADATA) {
     610            psError(PS_ERR_UNKNOWN, false, "mapfile: %s is in the wrong format", mapfile);
     611            psFree(iter);
     612            psFree(skycells);
     613            return false;
     614        }
     615
     616        psMetadata *sc = item->data.md;
     617        // this conversion isn't strictly nessicary but it's an easy way of
     618        // validating the format
     619        p4SkyCellMapRow *row = p4SkyCellMapObjectFromMetadata(sc);
     620        if (!row) {
     621            psError(PS_ERR_UNKNOWN, false, "failed to convert mapfile: %s metdata entry into a p4SkyCellMap object", mapfile);
     622            psFree(iter);
     623            psFree(skycells);
     624            return false;
     625        }
     626
     627        if (!p4SkyCellMapInsertObject(config->dbh, row)) {
     628            psError(PS_ERR_UNKNOWN, false, "failed to convert mapfile: %s metdata entry into a p4SkyCellMap object", mapfile);
     629            psFree(row);
     630            psFree(iter);
     631            psFree(skycells);
     632            return false;
     633        }
     634
     635        psFree(row);
     636    }
     637    psFree(iter);
     638    psFree(skycells);
     639
    570640    return true;
    571641}
  • trunk/ippTools/src/warptoolConfig.c

    r11765 r11769  
    118118    // -addoverlap
    119119    psMetadata *addoverlapArgs = psMetadataAlloc();
    120     psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-p4_id", 0,
    121             "search by p4 ID", NULL);
    122120    psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-mapfile", 0,
    123121            "skycell <-> imfile mapping description", NULL);
Note: See TracChangeset for help on using the changeset viewer.