IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 5, 2007, 2:03:35 PM (19 years ago)
Author:
Paul Price
Message:

Protecting against NULL BIASSEC.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r15219 r15229  
    837837    // Return a metadata item containing a list of metadata items of region strings
    838838    psList *biassecs = concept->data.V; // The biassecs region list
    839     psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator
    840     psRegion *region = NULL;            // Region from iteration
    841839    psList *new = psListAlloc(NULL);    // New list containing metadatas
    842     while ((region = psListGetAndIncrement(biassecsIter))) {
    843 
    844         // Correct bias section for binning if it's specified explicitly (i.e., immutably) in the CELLS.
    845         if (source == PM_CONCEPT_SOURCE_CELLS) {
    846             bool xStatus, yStatus;          // Status of MD lookups
    847             int xBin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
    848             int yBin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
    849             if (!xStatus || !yStatus || xBin == 0 || yBin == 0) {
    850                 psWarning("Unable to find CELL.XBIN and CELL.YBIN to correct CELL.BIASSEC.\n");
     840    if (biassecs) {
     841        psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator
     842        psRegion *region = NULL;            // Region from iteration
     843        while ((region = psListGetAndIncrement(biassecsIter))) {
     844            // Correct bias section for binning if it's specified explicitly (i.e., immutably) in the CELLS.
     845            if (source == PM_CONCEPT_SOURCE_CELLS) {
     846                bool xStatus, yStatus;          // Status of MD lookups
     847                int xBin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
     848                int yBin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
     849                if (!xStatus || !yStatus || xBin == 0 || yBin == 0) {
     850                    psWarning("Unable to find CELL.XBIN and CELL.YBIN to correct CELL.BIASSEC.\n");
     851                } else {
     852                    psRegion *newTrimsec = psRegionAlloc(region->x0 * xBin, region->x1 * xBin,
     853                                                         region->y0 * yBin, region->y1 * yBin);
     854                    region = newTrimsec;
     855                }
    851856            } else {
    852                 psRegion *newTrimsec = psRegionAlloc(region->x0 * xBin, region->x1 * xBin,
    853                                                      region->y0 * yBin, region->y1 * yBin);
    854                 region = newTrimsec;
     857                psMemIncrRefCounter(region);
    855858            }
    856         } else {
    857             psMemIncrRefCounter(region);
    858         }
    859 
    860         psString regionString = psRegionToString(*region); // The string region "[x0:x1,y0:y1]"
    861         psFree(region);
    862         psMetadataItem *item = psMetadataItemAllocStr(concept->name, concept->comment, regionString);
    863         psFree(regionString);           // Drop reference
    864         psListAdd(new, PS_LIST_TAIL, item);
    865         psFree(item);                   // Drop reference
    866     }
    867     psFree(biassecsIter);
     859
     860            psString regionString = psRegionToString(*region); // The string region "[x0:x1,y0:y1]"
     861            psFree(region);
     862            psMetadataItem *item = psMetadataItemAllocStr(concept->name, concept->comment, regionString);
     863            psFree(regionString);           // Drop reference
     864            psListAdd(new, PS_LIST_TAIL, item);
     865            psFree(item);                   // Drop reference
     866        }
     867        psFree(biassecsIter);
     868    }
     869
    868870    psMetadataItem *formatted = psMetadataItemAllocPtr(concept->name, PS_DATA_LIST, concept->comment, new);
    869871    psFree(new);                        // Drop reference
Note: See TracChangeset for help on using the changeset viewer.