IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15153


Ignore:
Timestamp:
Oct 1, 2007, 11:42:12 AM (19 years ago)
Author:
jhoblitt
Message:

change pztool -pendingimfile to "zip" together the imfiles from different cameras instead of merely appending the result sets from different cameras together

File:
1 edited

Legend:

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

    r15149 r15153  
    3838static bool copydoneCompleteExp(pxConfig *config);
    3939static psArray *pzGetKnownCameras(pxConfig *config);
    40 static psArray *pzArrayAddArray(psArray *array, psArray *input);
     40static psArray *pzArrayZip(psArray *arraySet);
    4141
    4242# define MODECASE(caseName, func) \
     
    227227
    228228    // array to hold the aggregate results
    229     psArray *output = psArrayAlloc(0);
     229    psArray *cameraImfiles = psArrayAlloc(0);
    230230
    231231    for (long i = 0; i < psArrayLength(cameras); i++) {
     
    233233        if (!query) {
    234234            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    235             psFree(output);
     235            psFree(cameraImfiles);
    236236            return false;
    237237        }
     
    273273            psError(PS_ERR_UNKNOWN, false, "database error");
    274274            psFree(query);
    275             psFree(output);
     275            psFree(cameraImfiles);
    276276            return false;
    277277        }
     
    281281        if (!result) {
    282282            psError(PS_ERR_UNKNOWN, false, "database error");
    283             psFree(output);
     283            psFree(cameraImfiles);
    284284            return false;
    285285        }
     
    287287            psTrace("pztool", PS_LOG_INFO, "no rows found");
    288288            psFree(result);
    289             psFree(output);
     289            psFree(cameraImfiles);
    290290            return true;
    291291        }
    292292
    293         // merge this query into the result set
    294         pzArrayAddArray(output, result);
     293        // add this query into the array of result set
     294        psArrayAdd(cameraImfiles, 0, result);
    295295        psFree(result);
    296296    }
     297
     298    // stitch the arrays of imfiles together
     299    psArray *output = pzArrayZip(cameraImfiles);
     300    psFree(cameraImfiles);
    297301
    298302    bool simple = false;
     
    620624}
    621625
     626static psArray *pzArrayZip(psArray *arraySet)
     627{
     628    long setSize = 0;
     629
     630    // figure out the size of the combined arrays
     631    for (long i = 0; i < psArrayLength(arraySet); i++) {
     632        setSize += psArrayLength(arraySet->data[i]);
     633    }
     634
     635    psArray *output = psArrayAllocEmpty(setSize);
     636    // loop over each array in the set forever
     637    long index = 0; // the depth into each array
     638    long counter; // counter - the total number of elements zipped so far
     639    long i; // i - which array in the set
     640    for (counter = 0, i = 0;
     641            (counter < setSize) && (i < psArrayLength(arraySet));
     642            counter++, ++i, i = i % psArrayLength(arraySet)) {
     643
     644        psArray *array = arraySet->data[i];
     645        // make sure that this array has not run out of elements
     646        if (index > (psArrayLength(arraySet) - 1)) {
     647            continue;
     648        }
     649
     650        psArrayAdd(output, 0, array->data[index]);
     651    }
     652
     653    return output;
     654}
     655
     656#if 0
    622657static psArray *pzArrayAddArray(psArray *array, psArray *input)
    623658{
     
    628663    return array;
    629664}
     665#endif
Note: See TracChangeset for help on using the changeset viewer.