本文整理汇总了C++中GDALRasterBand::SetOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::SetOffset方法的具体用法?C++ GDALRasterBand::SetOffset怎么用?C++ GDALRasterBand::SetOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::SetOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
/* UTM projection. However, using UTM projection is dangerous */
/* because there is no North/South field, or use of latitude */
/* bands! */
/* ------------------------------------------------------------ */
OGRSpatialReference oSRS;
if ( strcmp( CSLFetchNameValue( papszRsc, "PROJECTION" ),
"LL" ) == 0 )
{
if ( CSLFetchNameValue( papszRsc, "DATUM" ) != NULL )
{
oSRS.SetWellKnownGeogCS( CSLFetchNameValue( papszRsc,
"DATUM" ) );
}
else {
oSRS.SetWellKnownGeogCS( "WGS84" );
}
}
else if( STARTS_WITH(CSLFetchNameValue( papszRsc, "PROJECTION" ), "UTM") )
{
const char *pszZone = CSLFetchNameValue( papszRsc,
"PROJECTION" ) + 3;
oSRS.SetUTM( atoi( pszZone ), TRUE ); /* FIXME: north/south? */
if ( CSLFetchNameValue( papszRsc, "DATUM" ) != NULL )
{
oSRS.SetWellKnownGeogCS( CSLFetchNameValue( papszRsc,
"DATUM" ) );
}
else {
oSRS.SetWellKnownGeogCS( "NAD27" );
}
}
oSRS.exportToWkt( &poDS->pszProjection );
}
if ( CSLFetchNameValue( papszRsc, "Z_OFFSET" ) != NULL )
{
const double dfOffset
= strtod( CSLFetchNameValue( papszRsc, "Z_OFFSET" ), NULL);
for (int b = 1; b <= nBands; b++)
{
GDALRasterBand *poBand = poDS->GetRasterBand(b);
poBand->SetOffset( dfOffset );
}
}
if ( CSLFetchNameValue( papszRsc, "Z_SCALE" ) != NULL )
{
const double dfScale
= strtod( CSLFetchNameValue( papszRsc, "Z_SCALE" ), NULL);
for (int b = 1; b <= nBands; b++)
{
GDALRasterBand *poBand = poDS->GetRasterBand(b);
poBand->SetScale( dfScale );
}
}
/* -------------------------------------------------------------------- */
/* Set all the other header metadata into the ROI_PAC domain */
/* -------------------------------------------------------------------- */
for (int i = 0; i < CSLCount( papszRsc ); i++)
{
char **papszTokens = CSLTokenizeString2( papszRsc[i],
"=",
CSLT_STRIPLEADSPACES
| CSLT_STRIPENDSPACES);
if ( strcmp( papszTokens[0], "WIDTH" ) == 0
|| strcmp( papszTokens[0], "FILE_LENGTH" ) == 0
|| strcmp( papszTokens[0], "X_FIRST" ) == 0
|| strcmp( papszTokens[0], "X_STEP" ) == 0
|| strcmp( papszTokens[0], "Y_FIRST" ) == 0
|| strcmp( papszTokens[0], "Y_STEP" ) == 0
|| strcmp( papszTokens[0], "PROJECTION" ) == 0
|| strcmp( papszTokens[0], "DATUM" ) == 0
|| strcmp( papszTokens[0], "Z_OFFSET" ) == 0
|| strcmp( papszTokens[0], "Z_SCALE" ) == 0 )
{
CSLDestroy( papszTokens );
continue;
}
poDS->SetMetadataItem(papszTokens[0], papszTokens[1], "ROI_PAC");
CSLDestroy( papszTokens );
}
/* -------------------------------------------------------------------- */
/* Free papszRsc */
/* -------------------------------------------------------------------- */
CSLDestroy( papszRsc );
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
/* -------------------------------------------------------------------- */
/* Check for overviews. */
/* -------------------------------------------------------------------- */
poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename );
return( poDS );
}
示例2: if
//.........这里部分代码省略.........
for( i = 0; i < nBands; i++ )
{
GDALRasterBand *poBand;
if( EQUAL(szLayout,"Tiled") )
{
poBand = new ISISTiledBand( poDS, poDS->fpImage, i+1, eDataType,
tileSizeX, tileSizeY,
nSkipBytes, 0, 0,
bNativeOrder );
}
else
{
poBand =
new RawRasterBand( poDS, i+1, poDS->fpImage,
nSkipBytes + nBandOffset * i,
nPixelOffset, nLineOffset, eDataType,
#ifdef CPL_LSB
chByteOrder == 'I' || chByteOrder == 'L',
#else
chByteOrder == 'M',
#endif
TRUE );
}
poDS->SetBand( i+1, poBand );
if( bNoDataSet )
((GDALPamRasterBand *) poBand)->SetNoDataValue( dfNoData );
// Set offset/scale values at the PAM level.
poBand->SetOffset(
CPLAtofM(poDS->GetKeyword("IsisCube.Core.Pixels.Base","0.0")));
poBand->SetScale(
CPLAtofM(poDS->GetKeyword("IsisCube.Core.Pixels.Multiplier","1.0")));
}
/* -------------------------------------------------------------------- */
/* Check for a .prj file. For ISIS3 I would like to keep this in */
/* -------------------------------------------------------------------- */
CPLString osPath, osName;
osPath = CPLGetPath( poOpenInfo->pszFilename );
osName = CPLGetBasename(poOpenInfo->pszFilename);
const char *pszPrjFile = CPLFormCIFilename( osPath, osName, "prj" );
fp = VSIFOpenL( pszPrjFile, "r" );
if( fp != NULL )
{
char **papszLines;
OGRSpatialReference oSRS;
VSIFCloseL( fp );
papszLines = CSLLoad( pszPrjFile );
if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE )
{
char *pszResult = NULL;
oSRS.exportToWkt( &pszResult );
poDS->osProjection = pszResult;
CPLFree( pszResult );
}
示例3: if
//.........这里部分代码省略.........
poDS->eAccess = poOpenInfo->eAccess;
/* -------------------------------------------------------------------- */
/* Compute the line offsets. */
/* -------------------------------------------------------------------- */
const long int nItemSize = GDALGetDataTypeSize(eDataType)/8;
const long int nPixelOffset = nItemSize;
const long int nLineOffset = nPixelOffset * nCols + atoi(poDS->GetKeyword("NBB")) ;
const long int nBandOffset = nLineOffset * nRows;
nSkipBytes = atoi(poDS->GetKeyword("LBLSIZE"));
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( int i = 0; i < nBands; i++ )
{
GDALRasterBand *poBand
= new RawRasterBand( poDS, i+1, poDS->fpImage, nSkipBytes + nBandOffset * i,
nPixelOffset, nLineOffset, eDataType,
#ifdef CPL_LSB
chByteOrder == 'I' || chByteOrder == 'L',
#else
chByteOrder == 'M',
#endif
TRUE );
poDS->SetBand( i+1, poBand );
poBand->SetNoDataValue( dfNoData );
if (bIsDTM) {
poBand->SetScale( (double) CPLAtof(poDS->GetKeyword( "DTM.DTM_SCALING_FACTOR") ) );
poBand->SetOffset( (double) CPLAtof(poDS->GetKeyword( "DTM.DTM_OFFSET") ) );
const char* pszMin = poDS->GetKeyword( "DTM.DTM_MINIMUM_DN", NULL );
const char* pszMax = poDS->GetKeyword( "DTM.DTM_MAXIMUM_DN", NULL );
if (pszMin != NULL && pszMax != NULL )
poBand->SetStatistics(CPLAtofM(pszMin),CPLAtofM(pszMax),0,0);
const char* pszNoData = poDS->GetKeyword( "DTM.DTM_MISSING_DN", NULL );
if (pszNoData != NULL )
poBand->SetNoDataValue( CPLAtofM(pszNoData) );
} else if (EQUAL( poDS->GetKeyword( "BLTYPE"), "M94_HRSC" )) {
float scale=CPLAtof(poDS->GetKeyword("DLRTO8.REFLECTANCE_SCALING_FACTOR","-1."));
if (scale < 0.) {
scale = CPLAtof(poDS->GetKeyword( "HRCAL.REFLECTANCE_SCALING_FACTOR","1."));
}
poBand->SetScale( scale );
float offset=CPLAtof(poDS->GetKeyword("DLRTO8.REFLECTANCE_OFFSET","-1."));
if (offset < 0.) {
offset = CPLAtof(poDS->GetKeyword( "HRCAL.REFLECTANCE_OFFSET","0."));
}
poBand->SetOffset( offset );
}
const char* pszMin = poDS->GetKeyword( "STATISTICS.MINIMUM", NULL );
const char* pszMax = poDS->GetKeyword( "STATISTICS.MAXIMUM", NULL );
const char* pszMean = poDS->GetKeyword( "STATISTICS.MEAN", NULL );
const char* pszStdDev = poDS->GetKeyword( "STATISTICS.STANDARD_DEVIATION", NULL );
if (pszMin != NULL && pszMax != NULL && pszMean != NULL && pszStdDev != NULL )
poBand->SetStatistics(CPLAtofM(pszMin),CPLAtofM(pszMax),CPLAtofM(pszMean),CPLAtofM(pszStdDev));
}
/* -------------------------------------------------------------------- */
/* Instrument-specific keywords as metadata. */
/* -------------------------------------------------------------------- */
示例4: 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;
}