本文整理汇总了C++中GDALRasterBand::GetOverview方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::GetOverview方法的具体用法?C++ GDALRasterBand::GetOverview怎么用?C++ GDALRasterBand::GetOverview使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::GetOverview方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
GDALRasterBand *
GDALDefaultOverviews::GetOverview( int nBand, int iOverview )
{
GDALRasterBand * poBand;
if( poODS == NULL || nBand < 1 || nBand > poODS->GetRasterCount() )
return NULL;
poBand = poODS->GetRasterBand( nBand );
if( poBand == NULL )
return NULL;
if( bOvrIsAux )
return poBand->GetOverview( iOverview );
else // TIFF case, base is overview 0.
{
if( iOverview == 0 )
return poBand;
else if( iOverview-1 >= poBand->GetOverviewCount() )
return NULL;
else
return poBand->GetOverview( iOverview-1 );
}
}
示例2: FillBlock
CPLErr GDALMRFRasterBand::FillBlock(int xblk, int yblk, void *buffer) {
vector<GDALRasterBlock *> blocks;
for (int i = 0; i < poDS->nBands; i++) {
GDALRasterBand *b = poDS->GetRasterBand(i + 1);
if (b->GetOverviewCount() && 0 != m_l)
b = b->GetOverview(m_l - 1);
// Get the other band blocks, keep them around until later
if (b == this) {
FillBlock(buffer);
}
else {
GDALRasterBlock *poBlock = b->GetLockedBlockRef(xblk, yblk, 1);
if (poBlock == nullptr) // Didn't get this block
break;
FillBlock(poBlock->GetDataRef());
blocks.push_back(poBlock);
}
}
// Drop the locks for blocks we acquired
for (int i = 0; i < int(blocks.size()); i++)
blocks[i]->DropLock();
return CE_None;
}
示例3: RB
CPLErr GDALMRFRasterBand::RB(int xblk, int yblk, buf_mgr /*src*/, void *buffer) {
vector<GDALRasterBlock *> blocks;
for (int i = 0; i < poDS->nBands; i++) {
GDALRasterBand *b = poDS->GetRasterBand(i+1);
if (b->GetOverviewCount() && m_l)
b = b->GetOverview(m_l-1);
void *ob = buffer;
// Get the other band blocks, keep them around until later
if (b != this)
{
GDALRasterBlock *poBlock = b->GetLockedBlockRef(xblk, yblk, 1);
if( poBlock == NULL )
break;
ob = poBlock->GetDataRef();
blocks.push_back(poBlock);
}
// Just the right mix of templates and macros make deinterleaving tidy
#define CpySI(T) cpy_stride_in<T> (ob, (T *)poDS->GetPBuffer() + i,\
blockSizeBytes()/sizeof(T), img.pagesize.c)
// Page is already in poDS->pbuffer, not empty
// There are only four cases, since only the real data type matters
switch (GDALGetDataTypeSize(eDataType)/8)
{
case 1: CpySI(GByte); break;
case 2: CpySI(GInt16); break;
case 4: CpySI(GInt32); break;
case 8: CpySI(GIntBig); break;
}
}
#undef CpySI
// Drop the locks we acquired
for (int i=0; i < int(blocks.size()); i++)
blocks[i]->DropLock();
return CE_None;
}
示例4: GDALProxyPoolOverviewRasterBand
GDALRasterBand *GDALProxyPoolRasterBand::GetOverview(int nOverviewBand)
{
if (nOverviewBand >= 0 && nOverviewBand < nSizeProxyOverviewRasterBand)
{
if (papoProxyOverviewRasterBand[nOverviewBand])
return papoProxyOverviewRasterBand[nOverviewBand];
}
GDALRasterBand* poUnderlyingRasterBand = RefUnderlyingRasterBand();
if (poUnderlyingRasterBand == NULL)
return NULL;
GDALRasterBand* poOverviewRasterBand = poUnderlyingRasterBand->GetOverview(nOverviewBand);
if (poOverviewRasterBand == NULL)
{
UnrefUnderlyingRasterBand(poUnderlyingRasterBand);
return NULL;
}
if (nOverviewBand >= nSizeProxyOverviewRasterBand)
{
int i;
papoProxyOverviewRasterBand = (GDALProxyPoolOverviewRasterBand**)
CPLRealloc(papoProxyOverviewRasterBand,
sizeof(GDALProxyPoolOverviewRasterBand*) * (nOverviewBand + 1));
for(i=nSizeProxyOverviewRasterBand; i<nOverviewBand + 1;i++)
papoProxyOverviewRasterBand[i] = NULL;
nSizeProxyOverviewRasterBand = nOverviewBand + 1;
}
papoProxyOverviewRasterBand[nOverviewBand] =
new GDALProxyPoolOverviewRasterBand((GDALProxyPoolDataset*)poDS,
poOverviewRasterBand,
this, nOverviewBand);
UnrefUnderlyingRasterBand(poUnderlyingRasterBand);
return papoProxyOverviewRasterBand[nOverviewBand];
}
示例5: if
//.........这里部分代码省略.........
panRed = (unsigned short *)
CPLCalloc(nColorCount,sizeof(unsigned short));
panGreen = (unsigned short *)
CPLCalloc(nColorCount,sizeof(unsigned short));
panBlue = (unsigned short *)
CPLCalloc(nColorCount,sizeof(unsigned short));
for( int iColor = 0; iColor < nColorCount; iColor++ )
{
GDALColorEntry sRGB;
if( poCT->GetColorEntryAsRGB( iColor, &sRGB ) )
{
panRed[iColor] = (unsigned short) (257 * sRGB.c1);
panGreen[iColor] = (unsigned short) (257 * sRGB.c2);
panBlue[iColor] = (unsigned short) (257 * sRGB.c3);
}
}
}
/* -------------------------------------------------------------------- */
/* Do we need some metadata for the overviews? */
/* -------------------------------------------------------------------- */
CPLString osMetadata;
GDALDataset *poBaseDS = papoBandList[0]->GetDataset();
GTIFFBuildOverviewMetadata( pszResampling, poBaseDS, osMetadata );
/* -------------------------------------------------------------------- */
/* Loop, creating overviews. */
/* -------------------------------------------------------------------- */
int nOvrBlockXSize, nOvrBlockYSize;
GTIFFGetOverviewBlockSize(&nOvrBlockXSize, &nOvrBlockYSize);
for( iOverview = 0; iOverview < nOverviews; iOverview++ )
{
int nOXSize, nOYSize;
nOXSize = (nXSize + panOverviewList[iOverview] - 1)
/ panOverviewList[iOverview];
nOYSize = (nYSize + panOverviewList[iOverview] - 1)
/ panOverviewList[iOverview];
GTIFFWriteDirectory(hOTIFF, FILETYPE_REDUCEDIMAGE,
nOXSize, nOYSize, nBitsPerPixel,
nPlanarConfig, nBands,
nOvrBlockXSize, nOvrBlockYSize, TRUE, nCompression,
nPhotometric, nSampleFormat, nPredictor,
panRed, panGreen, panBlue,
0, NULL, /* FIXME? how can we fetch extrasamples */
osMetadata );
}
if (panRed)
{
CPLFree(panRed);
CPLFree(panGreen);
CPLFree(panBlue);
panRed = panGreen = panBlue = NULL;
}
XTIFFClose( hOTIFF );
VSIFCloseL(fpL);
fpL = NULL;
/* -------------------------------------------------------------------- */
示例6: IWriteBlock
CPLErr GDALMRFRasterBand::IWriteBlock(int xblk, int yblk, void *buffer)
{
GInt32 cstride = img.pagesize.c;
ILSize req(xblk, yblk, 0, m_band/cstride, m_l);
GUIntBig infooffset = IdxOffset(req, img);
CPLDebug("MRF_IB", "IWriteBlock %d,%d,0,%d, level %d, stride %d\n", xblk, yblk,
m_band, m_l, cstride);
if (1 == cstride) { // Separate bands, we can write it as is
// Empty page skip
int success;
double val = GetNoDataValue(&success);
if (!success) val = 0.0;
if (isAllVal(eDataType, buffer, img.pageSizeBytes, val))
return poDS->WriteTile(NULL, infooffset, 0);
// Use the pbuffer to hold the compressed page before writing it
poDS->tile = ILSize(); // Mark it corrupt
buf_mgr src;
src.buffer = (char *)buffer;
src.size = static_cast<size_t>(img.pageSizeBytes);
buf_mgr dst = {(char *)poDS->GetPBuffer(), poDS->GetPBufferSize()};
// Swab the source before encoding if we need to
if (is_Endianess_Dependent(img.dt, img.comp) && (img.nbo != NET_ORDER))
swab_buff(src, img);
// Compress functions need to return the compressed size in
// the bytes in buffer field
Compress(dst, src);
void *usebuff = dst.buffer;
if (deflatep) {
usebuff = DeflateBlock(dst, poDS->pbsize - dst.size, deflate_flags);
if (!usebuff) {
CPLError(CE_Failure,CPLE_AppDefined, "MRF: Deflate error");
return CE_Failure;
}
}
return poDS->WriteTile(usebuff, infooffset , dst.size);
}
// Multiple bands per page, use a temporary to assemble the page
// Temporary is large because we use it to hold both the uncompressed and the compressed
poDS->tile=req; poDS->bdirty=0;
// Keep track of what bands are empty
GUIntBig empties=0;
void *tbuffer = VSIMalloc(img.pageSizeBytes + poDS->pbsize);
if (!tbuffer) {
CPLError(CE_Failure,CPLE_AppDefined, "MRF: Can't allocate write buffer");
return CE_Failure;
}
// Get the other bands from the block cache
for (int iBand=0; iBand < poDS->nBands; iBand++ )
{
const char *pabyThisImage=NULL;
GDALRasterBlock *poBlock=NULL;
if (iBand == m_band)
{
pabyThisImage = (char *) buffer;
poDS->bdirty |= bandbit();
} else {
GDALRasterBand *band = poDS->GetRasterBand(iBand +1);
// Pick the right overview
if (m_l) band = band->GetOverview(m_l -1);
poBlock = ((GDALMRFRasterBand *)band)
->TryGetLockedBlockRef(xblk, yblk);
if (NULL==poBlock) continue;
// This is where the image data is for this band
pabyThisImage = (char*) poBlock->GetDataRef();
poDS->bdirty |= bandbit(iBand);
}
// Keep track of empty bands, but encode them anyhow, in case some are not empty
int success;
double val = GetNoDataValue(&success);
if (!success) val = 0.0;
if (isAllVal(eDataType, (char *)pabyThisImage, blockSizeBytes(), val))
empties |= bandbit(iBand);
// Copy the data into the dataset buffer here
// Just the right mix of templates and macros make this real tidy
#define CpySO(T) cpy_stride_out<T> (((T *)tbuffer)+iBand, pabyThisImage,\
blockSizeBytes()/sizeof(T), cstride)
// Build the page in tbuffer
switch (GDALGetDataTypeSize(eDataType)/8)
{
case 1: CpySO(GByte); break;
case 2: CpySO(GInt16); break;
//.........这里部分代码省略.........
示例7: if
//.........这里部分代码省略.........
/* Open the overview dataset so that we can get at the overview */
/* bands. */
/* -------------------------------------------------------------------- */
GDALDataset *hODS;
hODS = (GDALDataset *) GDALOpen( pszFilename, GA_Update );
if( hODS == NULL )
return CE_Failure;
/* -------------------------------------------------------------------- */
/* Loop writing overview data. */
/* -------------------------------------------------------------------- */
if (nCompression != COMPRESSION_NONE &&
nPlanarConfig == PLANARCONFIG_CONTIG &&
GDALDataTypeIsComplex(papoBandList[0]->GetRasterDataType()) == FALSE &&
papoBandList[0]->GetColorTable() == NULL &&
(EQUALN(pszResampling, "NEAR", 4) || EQUAL(pszResampling, "AVERAGE") || EQUAL(pszResampling, "GAUSS")))
{
/* In the case of pixel interleaved compressed overviews, we want to generate */
/* the overviews for all the bands block by block, and not band after band, */
/* in order to write the block once and not loose space in the TIFF file */
GDALRasterBand ***papapoOverviewBands;
papapoOverviewBands = (GDALRasterBand ***) CPLCalloc(sizeof(void*),nBands);
for( iBand = 0; iBand < nBands; iBand++ )
{
GDALRasterBand *hDstBand = hODS->GetRasterBand( iBand+1 );
papapoOverviewBands[iBand] = (GDALRasterBand **) CPLCalloc(sizeof(void*),nOverviews);
papapoOverviewBands[iBand][0] = hDstBand;
for( int i = 0; i < nOverviews-1; i++ )
{
papapoOverviewBands[iBand][i+1] = hDstBand->GetOverview(i);
}
}
GDALRegenerateOverviewsMultiBand(nBands, papoBandList,
nOverviews, papapoOverviewBands,
pszResampling, pfnProgress, pProgressData );
for( iBand = 0; iBand < nBands; iBand++ )
{
CPLFree(papapoOverviewBands[iBand]);
}
CPLFree(papapoOverviewBands);
}
else
{
GDALRasterBand **papoOverviews;
papoOverviews = (GDALRasterBand **) CPLCalloc(sizeof(void*),128);
for( iBand = 0; iBand < nBands; iBand++ )
{
GDALRasterBand *hSrcBand = papoBandList[iBand];
GDALRasterBand *hDstBand;
int nDstOverviews;
CPLErr eErr;
hDstBand = hODS->GetRasterBand( iBand+1 );
papoOverviews[0] = hDstBand;
nDstOverviews = hDstBand->GetOverviewCount() + 1;
CPLAssert( nDstOverviews < 128 );
nDstOverviews = MIN(128,nDstOverviews);
示例8: CleanOverviews
CPLErr
GDALDefaultOverviews::BuildOverviews(
const char * pszBasename,
const char * pszResampling,
int nOverviews, int * panOverviewList,
int nBands, int * panBandList,
GDALProgressFunc pfnProgress, void * pProgressData)
{
if( pfnProgress == NULL )
pfnProgress = GDALDummyProgress;
if( nOverviews == 0 )
return CleanOverviews();
/* -------------------------------------------------------------------- */
/* If we don't already have an overview file, we need to decide */
/* what format to use. */
/* -------------------------------------------------------------------- */
if( poODS == NULL )
{
bOvrIsAux = CPLTestBool(CPLGetConfigOption( "USE_RRD", "NO" ));
if( bOvrIsAux )
{
osOvrFilename = CPLResetExtension(poDS->GetDescription(),"aux");
VSIStatBufL sStatBuf;
if( VSIStatExL( osOvrFilename, &sStatBuf,
VSI_STAT_EXISTS_FLAG ) == 0 )
osOvrFilename.Printf( "%s.aux", poDS->GetDescription() );
}
}
/* -------------------------------------------------------------------- */
/* If we already have the overviews open, but they are */
/* read-only, then try and reopen them read-write. */
/* -------------------------------------------------------------------- */
else if( poODS->GetAccess() == GA_ReadOnly )
{
GDALClose( poODS );
poODS = static_cast<GDALDataset *>(
GDALOpen( osOvrFilename, GA_Update ));
if( poODS == NULL )
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Our TIFF overview support currently only works safely if all */
/* bands are handled at the same time. */
/* -------------------------------------------------------------------- */
if( !bOvrIsAux && nBands != poDS->GetRasterCount() )
{
CPLError( CE_Failure, CPLE_NotSupported,
"Generation of overviews in external TIFF currently only "
"supported when operating on all bands. "
"Operation failed." );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* If a basename is provided, use it to override the internal */
/* overview filename. */
/* -------------------------------------------------------------------- */
if( pszBasename == NULL && osOvrFilename.length() == 0 )
pszBasename = poDS->GetDescription();
if( pszBasename != NULL )
{
if( bOvrIsAux )
osOvrFilename.Printf( "%s.aux", pszBasename );
else
osOvrFilename.Printf( "%s.ovr", pszBasename );
}
/* -------------------------------------------------------------------- */
/* Establish which of the overview levels we already have, and */
/* which are new. We assume that band 1 of the file is */
/* representative. */
/* -------------------------------------------------------------------- */
GDALRasterBand *poBand = poDS->GetRasterBand( 1 );
int nNewOverviews = 0;
int *panNewOverviewList = static_cast<int *>(
CPLCalloc(sizeof(int), nOverviews) );
double dfAreaNewOverviews = 0;
double dfAreaRefreshedOverviews = 0;
for( int i = 0; i < nOverviews && poBand != NULL; i++ )
{
for( int j = 0; j < poBand->GetOverviewCount(); j++ )
{
GDALRasterBand * poOverview = poBand->GetOverview( j );
if( poOverview == NULL )
continue;
int nOvFactor =
GDALComputeOvFactor(poOverview->GetXSize(),
poBand->GetXSize(),
poOverview->GetYSize(),
poBand->GetYSize());
if( nOvFactor == panOverviewList[i]
//.........这里部分代码省略.........
示例9: HaveMaskFile
int GDALDefaultOverviews::HaveMaskFile( char ** papszSiblingFiles,
const char *pszBasename )
{
/* -------------------------------------------------------------------- */
/* Have we already checked for masks? */
/* -------------------------------------------------------------------- */
if( bCheckedForMask )
return poMaskDS != NULL;
if( papszSiblingFiles == NULL )
papszSiblingFiles = papszInitSiblingFiles;
/* -------------------------------------------------------------------- */
/* Are we an overview? If so we need to find the corresponding */
/* overview in the base files mask file (if there is one). */
/* -------------------------------------------------------------------- */
if( poBaseDS != NULL && poBaseDS->oOvManager.HaveMaskFile() )
{
GDALRasterBand * const poBaseBand = poBaseDS->GetRasterBand(1);
GDALRasterBand * poBaseMask = poBaseBand != NULL ?
poBaseBand->GetMaskBand() : NULL;
const int nOverviewCount = poBaseMask != NULL ?
poBaseMask->GetOverviewCount() : 0;
for( int iOver = 0; iOver < nOverviewCount; iOver++ )
{
GDALRasterBand * const poOverBand =
poBaseMask->GetOverview( iOver );
if( poOverBand == NULL )
continue;
if( poOverBand->GetXSize() == poDS->GetRasterXSize()
&& poOverBand->GetYSize() == poDS->GetRasterYSize() )
{
poMaskDS = poOverBand->GetDataset();
break;
}
}
bCheckedForMask = true;
bOwnMaskDS = false;
CPLAssert( poMaskDS != poDS );
return poMaskDS != NULL;
}
/* -------------------------------------------------------------------- */
/* Are we even initialized? If not, we apparently don't want */
/* to support overviews and masks. */
/* -------------------------------------------------------------------- */
if( poDS == NULL )
return FALSE;
/* -------------------------------------------------------------------- */
/* Check for .msk file. */
/* -------------------------------------------------------------------- */
bCheckedForMask = true;
if( pszBasename == NULL )
pszBasename = poDS->GetDescription();
// Don't bother checking for masks of masks.
if( EQUAL(CPLGetExtension(pszBasename),"msk") )
return FALSE;
if( !GDALCanFileAcceptSidecarFile(pszBasename) )
return FALSE;
CPLString osMskFilename;
osMskFilename.Printf( "%s.msk", pszBasename );
std::vector<char> achMskFilename;
achMskFilename.resize(osMskFilename.size() + 1);
memcpy(&(achMskFilename[0]),
osMskFilename.c_str(),
osMskFilename.size() + 1);
bool bExists = CPL_TO_BOOL(
CPLCheckForFile( &achMskFilename[0],
papszSiblingFiles ) );
osMskFilename = &achMskFilename[0];
#if !defined(WIN32)
if( !bExists && !papszSiblingFiles )
{
osMskFilename.Printf( "%s.MSK", pszBasename );
memcpy(&(achMskFilename[0]),
osMskFilename.c_str(),
osMskFilename.size() + 1);
bExists = CPL_TO_BOOL(
CPLCheckForFile( &achMskFilename[0],
papszSiblingFiles ) );
osMskFilename = &achMskFilename[0];
}
#endif
if( !bExists )
return FALSE;
//.........这里部分代码省略.........
示例10: if
//.........这里部分代码省略.........
panGreen = static_cast<unsigned short *>(
CPLCalloc(nColorCount, sizeof(unsigned short)) );
panBlue = static_cast<unsigned short *>(
CPLCalloc(nColorCount, sizeof(unsigned short)) );
for( int iColor = 0; iColor < nColorCount; iColor++ )
{
GDALColorEntry sRGB = { 0, 0, 0, 0 };
if( poCT->GetColorEntryAsRGB( iColor, &sRGB ) )
{
// TODO(schwehr): Check for underflow.
// Going from signed short to unsigned short.
panRed[iColor] = static_cast<unsigned short>(257 * sRGB.c1);
panGreen[iColor] = static_cast<unsigned short>(257 * sRGB.c2);
panBlue[iColor] = static_cast<unsigned short>(257 * sRGB.c3);
}
}
}
/* -------------------------------------------------------------------- */
/* Do we need some metadata for the overviews? */
/* -------------------------------------------------------------------- */
CPLString osMetadata;
GDALDataset *poBaseDS = papoBandList[0]->GetDataset();
GTIFFBuildOverviewMetadata( pszResampling, poBaseDS, osMetadata );
/* -------------------------------------------------------------------- */
/* Loop, creating overviews. */
/* -------------------------------------------------------------------- */
int nOvrBlockXSize = 0;
int nOvrBlockYSize = 0;
GTIFFGetOverviewBlockSize(&nOvrBlockXSize, &nOvrBlockYSize);
CPLString osNoData; // don't move this in inner scope
const char* pszNoData = nullptr;
int bNoDataSet = FALSE;
const double dfNoDataValue = papoBandList[0]->GetNoDataValue(&bNoDataSet);
if( bNoDataSet )
{
osNoData = GTiffFormatGDALNoDataTagValue(dfNoDataValue);
pszNoData = osNoData.c_str();
}
std::vector<uint16> anExtraSamples;
for( int i = GTIFFGetMaxColorChannels(nPhotometric)+1; i <= nBands; i++ )
{
if( papoBandList[i-1]->GetColorInterpretation() == GCI_AlphaBand )
{
anExtraSamples.push_back(
GTiffGetAlphaValue(CPLGetConfigOption("GTIFF_ALPHA", nullptr),
DEFAULT_ALPHA_TYPE));
}
else
{
anExtraSamples.push_back(EXTRASAMPLE_UNSPECIFIED);
}
}
for( iOverview = 0; iOverview < nOverviews; iOverview++ )
{
const int nOXSize = (nXSize + panOverviewList[iOverview] - 1)
/ panOverviewList[iOverview];
const int nOYSize = (nYSize + panOverviewList[iOverview] - 1)
/ panOverviewList[iOverview];
示例11: HaveMaskFile
int GDALDefaultOverviews::HaveMaskFile( char ** papszSiblingFiles,
const char *pszBasename )
{
/* -------------------------------------------------------------------- */
/* Have we already checked for masks? */
/* -------------------------------------------------------------------- */
if( bCheckedForMask )
return poMaskDS != NULL;
if( papszSiblingFiles == NULL )
papszSiblingFiles = papszInitSiblingFiles;
/* -------------------------------------------------------------------- */
/* Are we an overview? If so we need to find the corresponding */
/* overview in the base files mask file (if there is one). */
/* -------------------------------------------------------------------- */
if( poBaseDS != NULL && poBaseDS->oOvManager.HaveMaskFile() )
{
int iOver, nOverviewCount = 0;
GDALRasterBand *poBaseBand = poBaseDS->GetRasterBand(1);
GDALRasterBand *poBaseMask = NULL;
if( poBaseBand != NULL )
poBaseMask = poBaseBand->GetMaskBand();
if( poBaseMask )
nOverviewCount = poBaseMask->GetOverviewCount();
for( iOver = 0; iOver < nOverviewCount; iOver++ )
{
GDALRasterBand *poOverBand = poBaseMask->GetOverview( iOver );
if (poOverBand == NULL)
continue;
if( poOverBand->GetXSize() == poDS->GetRasterXSize()
&& poOverBand->GetYSize() == poDS->GetRasterYSize() )
{
poMaskDS = poOverBand->GetDataset();
break;
}
}
bCheckedForMask = TRUE;
bOwnMaskDS = FALSE;
CPLAssert( poMaskDS != poDS );
return poMaskDS != NULL;
}
/* -------------------------------------------------------------------- */
/* Are we even initialized? If not, we apparently don't want */
/* to support overviews and masks. */
/* -------------------------------------------------------------------- */
if( poDS == NULL )
return FALSE;
/* -------------------------------------------------------------------- */
/* Check for .msk file. */
/* -------------------------------------------------------------------- */
CPLString osMskFilename;
bCheckedForMask = TRUE;
if( pszBasename == NULL )
pszBasename = poDS->GetDescription();
// Don't bother checking for masks of masks.
if( EQUAL(CPLGetExtension(pszBasename),"msk") )
return FALSE;
osMskFilename.Printf( "%s.msk", pszBasename );
int bExists = CPLCheckForFile( (char *) osMskFilename.c_str(),
papszSiblingFiles );
#if !defined(WIN32)
if( !bExists && !papszSiblingFiles )
{
osMskFilename.Printf( "%s.MSK", pszBasename );
bExists = CPLCheckForFile( (char *) osMskFilename.c_str(),
papszSiblingFiles );
}
#endif
if( !bExists )
return FALSE;
/* -------------------------------------------------------------------- */
/* Open the file. */
/* -------------------------------------------------------------------- */
GDALOpenInfo oOpenInfo(osMskFilename, poDS->GetAccess(),
papszInitSiblingFiles);
poMaskDS = (GDALDataset *) GDALOpenInternal( oOpenInfo, NULL );
CPLAssert( poMaskDS != poDS );
if( poMaskDS == NULL )
return FALSE;
bOwnMaskDS = TRUE;
//.........这里部分代码省略.........
示例12: if
const char *GDALWMSRasterBand::GetMetadataItem( const char * pszName,
const char * pszDomain )
{
/* ==================================================================== */
/* LocationInfo handling. */
/* ==================================================================== */
if( pszDomain != NULL
&& EQUAL(pszDomain,"LocationInfo")
&& (STARTS_WITH_CI(pszName, "Pixel_") || STARTS_WITH_CI(pszName, "GeoPixel_")) )
{
int iPixel, iLine;
/* -------------------------------------------------------------------- */
/* What pixel are we aiming at? */
/* -------------------------------------------------------------------- */
if( STARTS_WITH_CI(pszName, "Pixel_") )
{
if( sscanf( pszName+6, "%d_%d", &iPixel, &iLine ) != 2 )
return NULL;
}
else if( STARTS_WITH_CI(pszName, "GeoPixel_") )
{
double adfGeoTransform[6];
double adfInvGeoTransform[6];
double dfGeoX, dfGeoY;
{
dfGeoX = CPLAtof(pszName + 9);
const char* pszUnderscore = strchr(pszName + 9, '_');
if( !pszUnderscore )
return NULL;
dfGeoY = CPLAtof(pszUnderscore+1);
}
if( m_parent_dataset->GetGeoTransform( adfGeoTransform ) != CE_None )
return NULL;
if( !GDALInvGeoTransform( adfGeoTransform, adfInvGeoTransform ) )
return NULL;
iPixel = (int) floor(
adfInvGeoTransform[0]
+ adfInvGeoTransform[1] * dfGeoX
+ adfInvGeoTransform[2] * dfGeoY );
iLine = (int) floor(
adfInvGeoTransform[3]
+ adfInvGeoTransform[4] * dfGeoX
+ adfInvGeoTransform[5] * dfGeoY );
/* The GetDataset() for the WMS driver is always the main overview level, so rescale */
/* the values if we are an overview */
if (m_overview >= 0)
{
iPixel = (int) (1.0 * iPixel * GetXSize() / m_parent_dataset->GetRasterBand(1)->GetXSize());
iLine = (int) (1.0 * iLine * GetYSize() / m_parent_dataset->GetRasterBand(1)->GetYSize());
}
}
else
return NULL;
if( iPixel < 0 || iLine < 0
|| iPixel >= GetXSize()
|| iLine >= GetYSize() )
return NULL;
if (nBand != 1)
{
GDALRasterBand* poFirstBand = m_parent_dataset->GetRasterBand(1);
if (m_overview >= 0)
poFirstBand = poFirstBand->GetOverview(m_overview);
if (poFirstBand)
return poFirstBand->GetMetadataItem(pszName, pszDomain);
}
GDALWMSImageRequestInfo iri;
GDALWMSTiledImageRequestInfo tiri;
int nBlockXOff = iPixel / nBlockXSize;
int nBlockYOff = iLine / nBlockYSize;
ComputeRequestInfo(iri, tiri, nBlockXOff, nBlockYOff);
CPLString url;
m_parent_dataset->m_mini_driver->GetTiledImageInfo(&url,
iri, tiri,
iPixel % nBlockXSize,
iLine % nBlockXSize);
char* pszRes = NULL;
if (url.size() != 0)
{
if (url == osMetadataItemURL)
{
return osMetadataItem.size() != 0 ? osMetadataItem.c_str() : NULL;
}
osMetadataItemURL = url;
char **http_request_opts = BuildHTTPRequestOpts();
CPLHTTPResult* psResult = CPLHTTPFetch( url.c_str(), http_request_opts);
//.........这里部分代码省略.........
示例13: CleanOverviews
CPLErr
GDALDefaultOverviews::BuildOverviews(
const char * pszBasename,
const char * pszResampling,
int nOverviews, int * panOverviewList,
int nBands, int * panBandList,
GDALProgressFunc pfnProgress, void * pProgressData)
{
GDALRasterBand **pahBands;
CPLErr eErr;
int i;
if( pfnProgress == NULL )
pfnProgress = GDALDummyProgress;
if( nOverviews == 0 )
return CleanOverviews();
/* -------------------------------------------------------------------- */
/* If we don't already have an overview file, we need to decide */
/* what format to use. */
/* -------------------------------------------------------------------- */
if( poODS == NULL )
{
bOvrIsAux = CSLTestBoolean(CPLGetConfigOption( "USE_RRD", "NO" ));
if( bOvrIsAux )
{
VSIStatBufL sStatBuf;
osOvrFilename = CPLResetExtension(poDS->GetDescription(),"aux");
if( VSIStatL( osOvrFilename, &sStatBuf ) == 0 )
osOvrFilename.Printf( "%s.aux", poDS->GetDescription() );
}
}
/* -------------------------------------------------------------------- */
/* If we already have the overviews open, but they are */
/* read-only, then try and reopen them read-write. */
/* -------------------------------------------------------------------- */
else if( poODS->GetAccess() == GA_ReadOnly )
{
GDALClose( poODS );
poODS = (GDALDataset *) GDALOpen( osOvrFilename, GA_Update );
if( poODS == NULL )
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Our TIFF overview support currently only works safely if all */
/* bands are handled at the same time. */
/* -------------------------------------------------------------------- */
if( !bOvrIsAux && nBands != poDS->GetRasterCount() )
{
CPLError( CE_Failure, CPLE_NotSupported,
"Generation of overviews in external TIFF currently only"
" supported when operating on all bands.\n"
"Operation failed.\n" );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* If a basename is provided, use it to override the internal */
/* overview filename. */
/* -------------------------------------------------------------------- */
if( pszBasename == NULL && osOvrFilename.length() == 0 )
pszBasename = poDS->GetDescription();
if( pszBasename != NULL )
{
if( bOvrIsAux )
osOvrFilename.Printf( "%s.aux", pszBasename );
else
osOvrFilename.Printf( "%s.ovr", pszBasename );
}
/* -------------------------------------------------------------------- */
/* Establish which of the overview levels we already have, and */
/* which are new. We assume that band 1 of the file is */
/* representative. */
/* -------------------------------------------------------------------- */
int nNewOverviews, *panNewOverviewList = NULL;
GDALRasterBand *poBand = poDS->GetRasterBand( 1 );
nNewOverviews = 0;
panNewOverviewList = (int *) CPLCalloc(sizeof(int),nOverviews);
for( i = 0; i < nOverviews && poBand != NULL; i++ )
{
int j;
for( j = 0; j < poBand->GetOverviewCount(); j++ )
{
int nOvFactor;
GDALRasterBand * poOverview = poBand->GetOverview( j );
nOvFactor = (int)
(0.5 + poBand->GetXSize() / (double) poOverview->GetXSize());
if( nOvFactor == panOverviewList[i]
|| nOvFactor == GDALOvLevelAdjust( panOverviewList[i],
//.........这里部分代码省略.........