本文整理汇总了C++中GDALRasterBand::SetMetadataItem方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::SetMetadataItem方法的具体用法?C++ GDALRasterBand::SetMetadataItem怎么用?C++ GDALRasterBand::SetMetadataItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::SetMetadataItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateLL
// static function- pointer set in driver
GDALDataset *KEADataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
GDALDataType eType,
char ** papszParmList )
{
H5::H5File *keaImgH5File = CreateLL( pszFilename, nXSize, nYSize, nBands,
eType, papszParmList );
if( keaImgH5File == NULL )
return NULL;
bool bThematic =
CPLTestBool(CSLFetchNameValueDef( papszParmList, "THEMATIC", "FALSE" ));
try
{
// create our dataset object
KEADataset *pDataset = new KEADataset( keaImgH5File, GA_Update );
pDataset->SetDescription( pszFilename );
// set all to thematic if asked
if( bThematic )
{
for( int nCount = 0; nCount < nBands; nCount++ )
{
GDALRasterBand *pBand = pDataset->GetRasterBand(nCount+1);
pBand->SetMetadataItem("LAYER_TYPE", "thematic");
}
}
return pDataset;
}
catch (kealib::KEAIOException &e)
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Attempt to create file `%s' failed. Error: %s\n",
pszFilename, e.what() );
return NULL;
}
}
示例2: CreateLL
GDALDataset *KEADataset::CreateCopy( const char * pszFilename, GDALDataset *pSrcDs,
CPL_UNUSED int bStrict, char ** papszParmList,
GDALProgressFunc pfnProgress, void *pProgressData )
{
// get the data out of the input dataset
int nXSize = pSrcDs->GetRasterXSize();
int nYSize = pSrcDs->GetRasterYSize();
int nBands = pSrcDs->GetRasterCount();
GDALDataType eType = (nBands == 0) ? GDT_Unknown : pSrcDs->GetRasterBand(1)->GetRasterDataType();
H5::H5File *keaImgH5File = CreateLL( pszFilename, nXSize, nYSize, nBands,
eType, papszParmList );
if( keaImgH5File == NULL )
return NULL;
bool bThematic = CSLTestBoolean(CSLFetchNameValueDef( papszParmList, "THEMATIC", "FALSE" ));
try
{
// create the imageio
kealib::KEAImageIO *pImageIO = new kealib::KEAImageIO();
// open the file
pImageIO->openKEAImageHeader( keaImgH5File );
// copy file
if( !KEACopyFile( pSrcDs, pImageIO, pfnProgress, pProgressData) )
{
delete pImageIO;
return NULL;
}
// close it
try
{
pImageIO->close();
}
catch (kealib::KEAIOException &e)
{
}
delete pImageIO;
// now open it again - because the constructor loads all the info
// in we need to copy the data first....
keaImgH5File = kealib::KEAImageIO::openKeaH5RW( pszFilename );
// and wrap it in a dataset
KEADataset *pDataset = new KEADataset( keaImgH5File, GA_Update );
pDataset->SetDescription( pszFilename );
// set all to thematic if asked - overrides whatever set by CopyFile
if( bThematic )
{
for( int nCount = 0; nCount < nBands; nCount++ )
{
GDALRasterBand *pBand = pDataset->GetRasterBand(nCount+1);
pBand->SetMetadataItem("LAYER_TYPE", "thematic");
}
}
for( int nCount = 0; nCount < nBands; nCount++ )
{
pDataset->GetRasterBand(nCount+1)->SetColorInterpretation(
pSrcDs->GetRasterBand(nCount+1)->GetColorInterpretation());
}
// KEA has no concept of per-dataset mask band for now.
for( int nCount = 0; nCount < nBands; nCount++ )
{
if( pSrcDs->GetRasterBand(nCount+1)->GetMaskFlags() == 0 ) // Per-band mask
{
pDataset->GetRasterBand(nCount+1)->CreateMaskBand(0);
GDALRasterBandCopyWholeRaster(
(GDALRasterBandH)pSrcDs->GetRasterBand(nCount+1)->GetMaskBand(),
(GDALRasterBandH)pDataset->GetRasterBand(nCount+1)->GetMaskBand(),
NULL, NULL, NULL);
}
}
return pDataset;
}
catch (kealib::KEAException &e)
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Attempt to create file `%s' failed. Error: %s\n",
pszFilename, e.what() );
return NULL;
}
}
示例3: CPLError
GDALDataset *LCPDataset::Open( GDALOpenInfo * poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* Verify that this is a FARSITE LCP file */
/* -------------------------------------------------------------------- */
if( !Identify( poOpenInfo ) )
return NULL;
/* -------------------------------------------------------------------- */
/* Confirm the requested access is supported. */
/* -------------------------------------------------------------------- */
if( poOpenInfo->eAccess == GA_Update )
{
CPLError( CE_Failure, CPLE_NotSupported,
"The LCP driver does not support update access to existing"
" datasets.\n" );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
LCPDataset *poDS;
VSILFILE *fpImage;
fpImage = VSIFOpenL(poOpenInfo->pszFilename, "rb");
if (fpImage == NULL)
return NULL;
poDS = new LCPDataset();
poDS->fpImage = fpImage;
/* -------------------------------------------------------------------- */
/* Read the header and extract some information. */
/* -------------------------------------------------------------------- */
int bHaveCrownFuels, bHaveGroundFuels;
int nBands, i;
long nWidth = -1, nHeight = -1;
int nTemp, nTemp2;
char szTemp[32];
char* pszList;
VSIFSeekL( poDS->fpImage, 0, SEEK_SET );
if (VSIFReadL( poDS->pachHeader, 1, LCP_HEADER_SIZE, poDS->fpImage ) != LCP_HEADER_SIZE)
{
CPLError(CE_Failure, CPLE_FileIO, "File too short");
delete poDS;
return NULL;
}
nWidth = CPL_LSBINT32PTR (poDS->pachHeader + 4164);
nHeight = CPL_LSBINT32PTR (poDS->pachHeader + 4168);
poDS->nRasterXSize = nWidth;
poDS->nRasterYSize = nHeight;
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
{
delete poDS;
return NULL;
}
// crown fuels = canopy height, canopy base height, canopy bulk density
// 21 = have them, 20 = don't have them
bHaveCrownFuels = ( CPL_LSBINT32PTR (poDS->pachHeader + 0) - 20 );
// ground fuels = duff loading, coarse woody
bHaveGroundFuels = ( CPL_LSBINT32PTR (poDS->pachHeader + 4) - 20 );
if( bHaveCrownFuels )
{
if( bHaveGroundFuels )
nBands = 10;
else
nBands = 8;
}
else
{
if( bHaveGroundFuels )
nBands = 7;
else
nBands = 5;
}
// add dataset-level metadata
nTemp = CPL_LSBINT32PTR (poDS->pachHeader + 8);
sprintf(szTemp, "%d", nTemp);
poDS->SetMetadataItem( "LATITUDE", szTemp );
nTemp = CPL_LSBINT32PTR (poDS->pachHeader + 4204);
if ( nTemp == 0 )
poDS->SetMetadataItem( "LINEAR_UNIT", "Meters" );
if ( nTemp == 1 )
poDS->SetMetadataItem( "LINEAR_UNIT", "Feet" );
poDS->pachHeader[LCP_HEADER_SIZE-1] = '\0';
poDS->SetMetadataItem( "DESCRIPTION", poDS->pachHeader + 6804 );
//.........这里部分代码省略.........