Changeset 10884


Ignore:
Timestamp:
Mar 7, 2007 9:10:29 AM (10 years ago)
Author:
hobu
Message:

be less dumb with overview support :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gdal/frmts/sde/sderasterband.cpp

    r10883 r10884  
    101101    this->poDS = poDS;
    102102    this->nBand = nBand;
    103          this->nOverview = nOverview;
     103        this->nOverview = nOverview;
    104104    poBand = band;
    105 //if (nOverview == -1) this->nOverview = 0; else
    106105   
    107106    // Initialize our SDE opaque object pointers to NULL.
     
    111110        hConstraint = NULL;
    112111    hQuery = NULL;
    113     nOverviews = GetOverviewCount();
    114 
    115     if (nOverviews != -1)
    116         papoOverviews = (GDALRasterBand**)  CPLMalloc( nOverviews * sizeof(GDALRasterBand*) );
     112   
     113    if (this->nOverview == -1 || this->nOverview == 0)
     114        this->nOverviews = GetOverviewCount();
    117115    else
    118         papoOverviews = NULL;
    119     eDataType = GetRasterDataType();
     116        this->nOverviews = 0;
     117
     118    if (nOverview == -1) {
     119        this->papoOverviews = (GDALRasterBand**)  CPLMalloc( nOverviews * sizeof(GDALRasterBand*) );
     120    }
     121    else {
     122        this->papoOverviews = NULL;
     123    }
     124    this->eDataType = GetRasterDataType();
    120125   
    121126    // nSDERasterType is set by GetRasterDataType
    122     dfDepth = MorphESRIRasterDepth(nSDERasterType);
     127    this->dfDepth = MorphESRIRasterDepth(nSDERasterType);
    123128    InitializeBand(this->nOverview);
    124     CPLDebug("SDERASTER","Initializing rasterband with overview=%d", this->nOverview);
     129
    125130   
    126131}
     
    132137
    133138{
    134     // clean up our SDE related stuff
    135     CPLDebug ("SDERASTER", "Calling ~SDERasterBand()...");
    136 
    137139    // grab our Dataset to limit the casting we have to do.
    138140    SDEDataset *poGDS = (SDEDataset *) poDS;
    139141
     142    // clean up our SDE related stuff
    140143    SE_stream_close(poGDS->hStream, 1);
    141         if (hQuery)
    142             SE_queryinfo_free(hQuery);
    143 
    144            
    145         if (hConstraint)
    146             SE_rasconstraint_free(hConstraint);
    147 
     144
     145    if (hQuery)
     146        SE_queryinfo_free(hQuery);
     147
     148    if (hConstraint)
     149        SE_rasconstraint_free(hConstraint);
     150
     151    if (papoOverviews)
     152        for (int i=0; i < nOverviews; i++)
     153            CPLFree(papoOverviews[i]);
     154        CPLFree(papoOverviews);
    148155}
    149156
     
    181188/*                           GetOverview()                              */
    182189/************************************************************************/
    183 GDALRasterBand* SDERasterBand::GetOverview( int nOverview )
    184 {
    185     CPLDebug("SDERASTER","Calling get overview for band %d, noverview %d, numoverviews: %d", nBand, nOverview, nOverviews);
     190GDALRasterBand* SDERasterBand::GetOverview( int nOverviewValue )
     191{
     192
    186193    if (papoOverviews) {
    187         if (!papoOverviews[nOverview]) {
    188             CPLDebug("SDERASTER", "hey idiot, we were null!!!");
    189         }
    190         return papoOverviews[nOverview];
     194        return papoOverviews[nOverviewValue];
    191195    }
    192196    else
    193197        return NULL;
    194     // cast our Dataset and request a new band for the given overview.
    195 //      SDEDataset *poGDS = (SDEDataset *) poDS;
    196 //    return new SDERasterBand(poGDS, nBand, nOverview, poBand);
     198
    197199   
    198200}
     
    208210    BOOL bSkipLevel;
    209211   
    210 //    if (nOverviews)
    211 //        return nOverviews;
     212    // return nothing if we were an overview band
     213    if (nOverview != -1)
     214        return 0;
     215
    212216    nSDEErr = SE_rasbandinfo_get_max_level(*poBand,
    213217                                           (long*)&nOverviews,
     
    216220    {
    217221        IssueSDEError( nSDEErr, "SE_rasbandinfo_get_band_size" );
    218 
    219222    }
    220223   
     
    687690    nBlockSize = nBlockXSize * nBlockYSize;
    688691
    689     CPLDebug("SDERASTER", "preparing to cache overviews nOverview: %d", nOverview);
     692    // We're the base level
    690693    if (nOverview == -1) {
    691694        for (int i = 0; i<this->nOverviews; i++) {
    692             CPLDebug("SDERASTER", "initializing badn... nOverviews:%d nBand: %d, i:%d", this->nOverviews,nBand,i);
    693695            papoOverviews[i]= new SDERasterBand(poGDS, nBand, i, poBand);
    694             CPLDebug("SDERASTER", " sizex:%d sizey:%d" , papoOverviews[i]->GetXSize(), papoOverviews[i]->GetYSize());
     696
    695697        }
    696698    }
Note: See TracChangeset for help on using the changeset viewer.