GDALRasterBand *VRTRasterBand::GetOverview( int iOverview ) { // First: overviews declared in <Overview> element if( !m_apoOverviews.empty() ) { if( iOverview < 0 || iOverview >= static_cast<int>( m_apoOverviews.size() ) ) return NULL; if( m_apoOverviews[iOverview].poBand == NULL && !m_apoOverviews[iOverview].bTriedToOpen ) { m_apoOverviews[iOverview].bTriedToOpen = TRUE; GDALDataset *poSrcDS = reinterpret_cast<GDALDataset *>( GDALOpenShared( m_apoOverviews[iOverview].osFilename, GA_ReadOnly ) ); if( poSrcDS == NULL ) return NULL; m_apoOverviews[iOverview].poBand = poSrcDS->GetRasterBand( m_apoOverviews[iOverview].nBand ); if (m_apoOverviews[iOverview].poBand == NULL) { GDALClose( (GDALDatasetH)poSrcDS ); } } return m_apoOverviews[iOverview].poBand; } // If not found, external .ovr overviews GDALRasterBand* poRet = GDALRasterBand::GetOverview( iOverview ); if( poRet ) return poRet; // If not found, implicit virtual overviews VRTDataset* poVRTDS = reinterpret_cast<VRTDataset *>( poDS ); poVRTDS->BuildVirtualOverviews(); if( !poVRTDS->m_apoOverviews.empty() && poVRTDS->m_apoOverviews[0] ) { if( iOverview < 0 || iOverview >= static_cast<int>( poVRTDS->m_apoOverviews.size() ) ) return NULL; return poVRTDS->m_apoOverviews[iOverview]->GetRasterBand(nBand); } return NULL; }
GDALRasterBand *VRTRasterBand::GetOverview( int iOverview ) { // First: overviews declared in <Overview> element if( apoOverviews.size() > 0 ) { if( iOverview < 0 || iOverview >= (int) apoOverviews.size() ) return NULL; if( apoOverviews[iOverview].poBand == NULL && !apoOverviews[iOverview].bTriedToOpen ) { apoOverviews[iOverview].bTriedToOpen = TRUE; GDALDataset *poSrcDS = (GDALDataset *) GDALOpenShared( apoOverviews[iOverview].osFilename, GA_ReadOnly ); if( poSrcDS == NULL ) return NULL; apoOverviews[iOverview].poBand = poSrcDS->GetRasterBand( apoOverviews[iOverview].nBand ); if (apoOverviews[iOverview].poBand == NULL) { GDALClose( (GDALDatasetH)poSrcDS ); } } return apoOverviews[iOverview].poBand; } // If not found, external .ovr overviews GDALRasterBand* poRet = GDALRasterBand::GetOverview( iOverview ); if( poRet ) return poRet; // If not found, implicit virtual overviews VRTDataset* poVRTDS = ((VRTDataset *)poDS); poVRTDS->BuildVirtualOverviews(); if( poVRTDS->apoOverviews.size() && poVRTDS->apoOverviews[0] ) { if( iOverview < 0 || iOverview >= (int) poVRTDS->apoOverviews.size() ) return NULL; return poVRTDS->apoOverviews[iOverview]->GetRasterBand(nBand); } return NULL; }
int VRTRasterBand::GetOverviewCount() { // First: overviews declared in <Overview> element if( !m_apoOverviews.empty() ) return static_cast<int>(m_apoOverviews.size()); // If not found, external .ovr overviews const int nOverviewCount = GDALRasterBand::GetOverviewCount(); if( nOverviewCount ) return nOverviewCount; // If not found, implicit virtual overviews VRTDataset* poVRTDS = reinterpret_cast<VRTDataset *>( poDS ); poVRTDS->BuildVirtualOverviews(); if( !poVRTDS->m_apoOverviews.empty() && poVRTDS->m_apoOverviews[0] ) return static_cast<int>( poVRTDS->m_apoOverviews.size() ); return 0; }
int VRTRasterBand::GetOverviewCount() { // First: overviews declared in <Overview> element if( apoOverviews.size() > 0 ) return apoOverviews.size(); // If not found, external .ovr overviews int nOverviewCount = GDALRasterBand::GetOverviewCount(); if( nOverviewCount ) return nOverviewCount; // If not found, implicit virtual overviews VRTDataset* poVRTDS = ((VRTDataset *)poDS); poVRTDS->BuildVirtualOverviews(); if( poVRTDS->apoOverviews.size() && poVRTDS->apoOverviews[0] ) return (int)poVRTDS->apoOverviews.size(); return 0; }