本文整理汇总了C++中GDALRasterBand::GetMaskBand方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::GetMaskBand方法的具体用法?C++ GDALRasterBand::GetMaskBand怎么用?C++ GDALRasterBand::GetMaskBand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::GetMaskBand方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GDALProxyPoolMaskBand
GDALRasterBand *GDALProxyPoolRasterBand::GetMaskBand()
{
if (poProxyMaskBand)
return poProxyMaskBand;
GDALRasterBand* poUnderlyingRasterBand = RefUnderlyingRasterBand();
if (poUnderlyingRasterBand == NULL)
return NULL;
GDALRasterBand* poMaskBand = poUnderlyingRasterBand->GetMaskBand();
poProxyMaskBand =
new GDALProxyPoolMaskBand((GDALProxyPoolDataset*)poDS,
poMaskBand,
this);
UnrefUnderlyingRasterBand(poUnderlyingRasterBand);
return poProxyMaskBand;
}
示例2: CPLAssert
//.........这里部分代码省略.........
{
poVRTDS->SetGeoTransform( adfGeoTransform );
}
/* -------------------------------------------------------------------- */
/* Copy projection */
/* -------------------------------------------------------------------- */
poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );
/* -------------------------------------------------------------------- */
/* Emit dataset level metadata. */
/* -------------------------------------------------------------------- */
poVRTDS->SetMetadata( poSrcDS->GetMetadata() );
/* -------------------------------------------------------------------- */
/* Copy any special domains that should be transportable. */
/* -------------------------------------------------------------------- */
char **papszMD = poSrcDS->GetMetadata( "RPC" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "RPC" );
papszMD = poSrcDS->GetMetadata( "IMD" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "IMD" );
papszMD = poSrcDS->GetMetadata( "GEOLOCATION" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "GEOLOCATION" );
/* -------------------------------------------------------------------- */
/* GCPs */
/* -------------------------------------------------------------------- */
if( poSrcDS->GetGCPCount() > 0 )
{
poVRTDS->SetGCPs( poSrcDS->GetGCPCount(),
poSrcDS->GetGCPs(),
poSrcDS->GetGCPProjection() );
}
/* -------------------------------------------------------------------- */
/* Loop over all the bands. */
/* -------------------------------------------------------------------- */
for( int iBand = 0; iBand < poSrcDS->GetRasterCount(); iBand++ )
{
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 );
/* -------------------------------------------------------------------- */
/* Create the band with the appropriate band type. */
/* -------------------------------------------------------------------- */
poVRTDS->AddBand( poSrcBand->GetRasterDataType(), NULL );
VRTSourcedRasterBand *poVRTBand
= reinterpret_cast<VRTSourcedRasterBand *>(
poVRTDS->GetRasterBand( iBand+1 ) );
/* -------------------------------------------------------------------- */
/* Setup source mapping. */
/* -------------------------------------------------------------------- */
poVRTBand->AddSimpleSource( poSrcBand );
/* -------------------------------------------------------------------- */
/* Emit various band level metadata. */
/* -------------------------------------------------------------------- */
poVRTBand->CopyCommonInfoFrom( poSrcBand );
/* -------------------------------------------------------------------- */
/* Add specific mask band. */
/* -------------------------------------------------------------------- */
if( (poSrcBand->GetMaskFlags()
& (GMF_PER_DATASET | GMF_ALL_VALID | GMF_NODATA)) == 0)
{
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(
poVRTDS, 0,
poSrcBand->GetMaskBand()->GetRasterDataType(),
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize());
poVRTMaskBand->AddMaskBandSource( poSrcBand );
poVRTBand->SetMaskBand( poVRTMaskBand );
}
}
/* -------------------------------------------------------------------- */
/* Add dataset mask band */
/* -------------------------------------------------------------------- */
if( poSrcDS->GetRasterCount() != 0 &&
poSrcDS->GetRasterBand(1) != NULL &&
poSrcDS->GetRasterBand(1)->GetMaskFlags() == GMF_PER_DATASET )
{
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand(1);
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(
poVRTDS, 0,
poSrcBand->GetMaskBand()->GetRasterDataType(),
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize() );
poVRTMaskBand->AddMaskBandSource( poSrcBand );
poVRTDS->SetMaskBand( poVRTMaskBand );
}
poVRTDS->FlushCache();
return poVRTDS;
}
示例3: 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;
//.........这里部分代码省略.........
示例4: ProxyMain
//.........这里部分代码省略.........
/* -------------------------------------------------------------------- */
poVDS->SetMetadata(((GDALDataset*)hDataset)->GetMetadata());
AttachMetadata((GDALDatasetH) poVDS, papszMetadataOptions);
const char *pszInterleave = GDALGetMetadataItem(hDataset, "INTERLEAVE", "IMAGE_STRUCTURE");
if (pszInterleave)
poVDS->SetMetadataItem("INTERLEAVE", pszInterleave, "IMAGE_STRUCTURE");
/* -------------------------------------------------------------------- */
/* Transfer metadata that remains valid if the spatial */
/* arrangement of the data is unaltered. */
/* -------------------------------------------------------------------- */
if (bSpatialArrangementPreserved)
{
char **papszMD;
papszMD = ((GDALDataset*)hDataset)->GetMetadata("RPC");
if (papszMD != NULL)
poVDS->SetMetadata(papszMD, "RPC");
papszMD = ((GDALDataset*)hDataset)->GetMetadata("GEOLOCATION");
if (papszMD != NULL)
poVDS->SetMetadata(papszMD, "GEOLOCATION");
}
int nSrcBandCount = nBandCount;
if (nRGBExpand != 0)
{
GDALRasterBand *poSrcBand;
poSrcBand = ((GDALDataset*)
hDataset)->GetRasterBand(ABS(panBandList[0]));
if (panBandList[0] < 0)
poSrcBand = poSrcBand->GetMaskBand();
GDALColorTable *poColorTable = poSrcBand->GetColorTable();
if (poColorTable == NULL)
{
fprintf(stderr, "Error : band %d has no color table\n", ABS(panBandList[0]));
GDALClose(hDataset);
CPLFree(panBandList);
GDALDestroyDriverManager();
CSLDestroy(argv);
CSLDestroy(papszCreateOptions);
exit(1);
}
/* Check that the color table only contains gray levels */
/* when using -expand gray */
if (nRGBExpand == 1)
{
int nColorCount = poColorTable->GetColorEntryCount();
int nColor;
for (nColor = 0; nColor < nColorCount; nColor++)
{
const GDALColorEntry *poEntry = poColorTable->GetColorEntry(nColor);
if (poEntry->c1 != poEntry->c2 || poEntry->c1 != poEntry->c2)
{
fprintf(stderr, "Warning : color table contains non gray levels colors\n");
break;
}
}
}
if (nBandCount == 1)