本文整理汇总了C++中GDALRasterBand::SetDescription方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::SetDescription方法的具体用法?C++ GDALRasterBand::SetDescription怎么用?C++ GDALRasterBand::SetDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::SetDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLError
//.........这里部分代码省略.........
/* -------------------------------------------------------------------- */
int iPixelSize;
iPixelSize = nBands * 2;
int bNativeOrder;
if (nWidth > INT_MAX / iPixelSize)
{
CPLError( CE_Failure, CPLE_AppDefined, "Int overflow occured");
delete poDS;
return NULL;
}
#ifdef CPL_LSB
bNativeOrder = TRUE;
#else
bNativeOrder = FALSE;
#endif
pszList = (char*)CPLMalloc(2048);
for( int iBand = 1; iBand <= nBands; iBand++ )
{
GDALRasterBand *poBand = NULL;
poBand = new RawRasterBand(
poDS, iBand, poDS->fpImage, LCP_HEADER_SIZE + ((iBand-1)*2),
iPixelSize, iPixelSize * nWidth, GDT_Int16, bNativeOrder, TRUE );
poDS->SetBand(iBand, poBand);
switch ( iBand ) {
case 1:
poBand->SetDescription("Elevation");
nTemp = CPL_LSBINT16PTR (poDS->pachHeader + 4224);
sprintf(szTemp, "%d", nTemp);
poBand->SetMetadataItem( "ELEVATION_UNIT", szTemp );
if ( nTemp == 0 )
poBand->SetMetadataItem( "ELEVATION_UNIT_NAME", "Meters" );
if ( nTemp == 1 )
poBand->SetMetadataItem( "ELEVATION_UNIT_NAME", "Feet" );
nTemp = CPL_LSBINT32PTR (poDS->pachHeader + 44);
sprintf(szTemp, "%d", nTemp);
poBand->SetMetadataItem( "ELEVATION_MIN", szTemp );
nTemp = CPL_LSBINT32PTR (poDS->pachHeader + 48);
sprintf(szTemp, "%d", nTemp);
poBand->SetMetadataItem( "ELEVATION_MAX", szTemp );
nTemp = CPL_LSBINT32PTR (poDS->pachHeader + 52);
sprintf(szTemp, "%d", nTemp);
poBand->SetMetadataItem( "ELEVATION_NUM_CLASSES", szTemp );
*(poDS->pachHeader + 4244 + 255) = '\0';
poBand->SetMetadataItem( "ELEVATION_FILE", poDS->pachHeader + 4244 );
break;
case 2:
poBand->SetDescription("Slope");
nTemp = CPL_LSBINT16PTR (poDS->pachHeader + 4226);
sprintf(szTemp, "%d", nTemp);
示例2: if
//.........这里部分代码省略.........
NULL, pProgressData ) )
{
VSIFCloseL( fp );
VSIFree( pfData );
CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" );
return NULL;
}
}
VSIFree( pfData );
/* write out the min and max values */
eErr = WriteHeader( fp, nXSize, nYSize,
dfMinX, dfMaxX, dfMinY, dfMaxY, dfMinZ, dfMaxZ );
if( eErr != CE_None )
{
VSIFCloseL( fp );
return NULL;
}
VSIFCloseL( fp );
GDALPamDataset *poDstDS = (GDALPamDataset *)GDALOpen( pszFilename,
GA_Update );
if( poDstDS == NULL )
{
VSIUnlink( pszFilename );
CPLError( CE_Failure, CPLE_FileIO,
"Unable to open copy of dataset.\n" );
return NULL;
}
else if( dynamic_cast<GSBGDataset *>(poDstDS) == NULL )
{
VSIUnlink( pszFilename );
delete poDstDS;
CPLError( CE_Failure, CPLE_FileIO,
"Copy dataset not opened as Golden Surfer Binary Grid!?\n" );
return NULL;
}
GDALRasterBand *poDstBand = poSrcDS->GetRasterBand(1);
if( poDstBand == NULL )
{
VSIUnlink( pszFilename );
delete poDstDS;
CPLError( CE_Failure, CPLE_FileIO,
"Unable to open copy of raster band?\n" );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Attempt to copy metadata. */
/* -------------------------------------------------------------------- */
if( !bStrict )
CPLPushErrorHandler( CPLQuietErrorHandler );
/* non-zero transform 2 or 4 or negative 1 or 5 not supported natively */
/*if( adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0
|| adfGeoTransform[1] < 0.0 || adfGeoTransform[5] < 0.0 )
poDstDS->GDALPamDataset::SetGeoTransform( adfGeoTransform );*/
const char *szProjectionRef = poSrcDS->GetProjectionRef();
if( *szProjectionRef != '\0' )
poDstDS->SetProjection( szProjectionRef );
char **pszMetadata = poSrcDS->GetMetadata();
if( pszMetadata != NULL )
poDstDS->SetMetadata( pszMetadata );
/* FIXME: Should the dataset description be copied as well, or is it
* always the file name? */
poDstBand->SetDescription( poSrcBand->GetDescription() );
int bSuccess;
double dfOffset = poSrcBand->GetOffset( &bSuccess );
if( bSuccess && dfOffset != 0.0 )
poDstBand->SetOffset( dfOffset );
double dfScale = poSrcBand->GetScale( &bSuccess );
if( bSuccess && dfScale != 1.0 )
poDstBand->SetScale( dfScale );
GDALColorInterp oColorInterp = poSrcBand->GetColorInterpretation();
if( oColorInterp != GCI_Undefined )
poDstBand->SetColorInterpretation( oColorInterp );
char **pszCatNames = poSrcBand->GetCategoryNames();
if( pszCatNames != NULL)
poDstBand->SetCategoryNames( pszCatNames );
GDALColorTable *poColorTable = poSrcBand->GetColorTable();
if( poColorTable != NULL )
poDstBand->SetColorTable( poColorTable );
if( !bStrict )
CPLPopErrorHandler();
return poDstDS;
}