本文整理汇总了C++中GDALGetDataTypeSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GDALGetDataTypeSize函数的具体用法?C++ GDALGetDataTypeSize怎么用?C++ GDALGetDataTypeSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GDALGetDataTypeSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLError
CPLErr COASPRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,
int nBlockYOff,
void *pImage )
{
if (this->fp == NULL) {
CPLError(CE_Fatal, CPLE_AppDefined, "file pointer freed unexpectedly\n");
return CE_Fatal;
}
/* 8 bytes per pixel: 4 bytes I, 4 bytes Q */
unsigned long nByteNum = poDS->GetRasterXSize() * 8 * nBlockYOff;
VSIFSeekL(this->fp, nByteNum, SEEK_SET);
int nReadSize = (GDALGetDataTypeSize(eDataType)/8) * poDS->GetRasterXSize();
VSIFReadL((char *)pImage, 1, nReadSize,
this->fp);
#ifdef CPL_LSB
GDALSwapWords( pImage, 4, nBlockXSize * 2, 4 );
#endif
return CE_None;
}
示例2: CPLAssert
CPLErr RawRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,
int nBlockYOff,
void * pImage )
{
CPLErr eErr;
CPLAssert( nBlockXOff == 0 );
if (pLineBuffer == NULL)
return CE_Failure;
eErr = AccessLine( nBlockYOff );
/* -------------------------------------------------------------------- */
/* Copy data from disk buffer to user block buffer. */
/* -------------------------------------------------------------------- */
GDALCopyWords( pLineStart, eDataType, nPixelOffset,
pImage, eDataType, GDALGetDataTypeSize(eDataType)/8,
nBlockXSize );
return eErr;
}
示例3: CPLAssert
CPLVirtualMem *RawRasterBand::GetVirtualMemAuto( GDALRWFlag eRWFlag,
int *pnPixelSpace,
GIntBig *pnLineSpace,
char **papszOptions )
{
CPLAssert(pnPixelSpace);
CPLAssert(pnLineSpace);
vsi_l_offset nSize = (vsi_l_offset)(nRasterYSize - 1) * nLineOffset +
(nRasterXSize - 1) * nPixelOffset + GDALGetDataTypeSize(eDataType) / 8;
if( !bIsVSIL || VSIFGetNativeFileDescriptorL(fpRawL) == NULL ||
!CPLIsVirtualMemFileMapAvailable() || (eDataType != GDT_Byte && !bNativeOrder) ||
(size_t)nSize != nSize || nPixelOffset < 0 || nLineOffset < 0 ||
CSLTestBoolean(CSLFetchNameValueDef(papszOptions, "USE_DEFAULT_IMPLEMENTATION", "NO")) )
{
return GDALRasterBand::GetVirtualMemAuto(eRWFlag, pnPixelSpace,
pnLineSpace, papszOptions);
}
FlushCache();
CPLVirtualMem* pVMem = CPLVirtualMemFileMapNew(
fpRawL, nImgOffset, nSize,
(eRWFlag == GF_Write) ? VIRTUALMEM_READWRITE : VIRTUALMEM_READONLY,
NULL, NULL);
if( pVMem == NULL )
{
return GDALRasterBand::GetVirtualMemAuto(eRWFlag, pnPixelSpace,
pnLineSpace, papszOptions);
}
else
{
*pnPixelSpace = nPixelOffset;
*pnLineSpace = nLineOffset;
return pVMem;
}
}
示例4: G_allocate_c_raster_buf
CPLErr GRASSRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * pImage )
{
if ( ! this->valid ) return CE_Failure;
// Reset window because IRasterIO could be previosly called
if ( ResetReading ( &(((GRASSDataset *)poDS)->sCellInfo) ) != CE_None ) {
return CE_Failure;
}
if ( eDataType == GDT_Byte || eDataType == GDT_UInt16 ) {
CELL *cbuf;
cbuf = G_allocate_c_raster_buf();
G_get_c_raster_row ( hCell, cbuf, nBlockYOff );
/* Reset NULLs */
for ( int col = 0; col < nBlockXSize; col++ ) {
if ( G_is_c_null_value(&(cbuf[col])) )
cbuf[col] = (CELL) dfNoData;
}
GDALCopyWords ( (void *) cbuf, GDT_Int32, sizeof(CELL),
pImage, eDataType, GDALGetDataTypeSize(eDataType)/8,
nBlockXSize );
G_free ( cbuf );
} else if ( eDataType == GDT_Int32 ) {
G_get_c_raster_row ( hCell, (CELL *) pImage, nBlockYOff );
} else if ( eDataType == GDT_Float32 ) {
G_get_f_raster_row ( hCell, (FCELL *) pImage, nBlockYOff );
} else if ( eDataType == GDT_Float64 ) {
G_get_d_raster_row ( hCell, (DCELL *) pImage, nBlockYOff );
}
return CE_None;
}
示例5: ConjPixelFunc
CPLErr ConjPixelFunc(void **papoSources, int nSources, void *pData,
int nXSize, int nYSize,
GDALDataType eSrcType, GDALDataType eBufType,
int nPixelSpace, int nLineSpace)
{
/* ---- Init ---- */
if (nSources != 1) return CE_Failure;
if (GDALDataTypeIsComplex( eSrcType ) && GDALDataTypeIsComplex( eBufType ))
{
int iLine, iCol, ii;
double adfPixVal[2];
int nOffset = GDALGetDataTypeSize( eSrcType ) / 8 / 2;
void *pReal = papoSources[0];
void *pImag = ((GByte *)papoSources[0]) + nOffset;
/* ---- Set pixels ---- */
for( iLine = 0, ii= 0; iLine < nYSize; ++iLine ) {
for( iCol = 0; iCol < nXSize; ++iCol, ++ii ) {
/* Source raster pixels may be obtained with SRCVAL macro */
adfPixVal[0] = +SRCVAL(pReal, eSrcType, ii); /* re */
adfPixVal[1] = -SRCVAL(pImag, eSrcType, ii); /* im */
GDALCopyWords(adfPixVal, GDT_CFloat64, 0,
((GByte *)pData) + nLineSpace * iLine +
iCol * nPixelSpace, eBufType, nPixelSpace, 1);
}
}
} else {
/* no complex data type */
return RealPixelFunc(papoSources, nSources, pData, nXSize, nYSize,
eSrcType, eBufType, nPixelSpace, nLineSpace);
}
/* ---- Return success ---- */
return CE_None;
} /* ConjPixelFunc */
示例6: switch
int IntergraphRasterBand::HandleUninstantiatedTile(int nBlockXOff,
int nBlockYOff,
void* pImage)
{
if( bTiled && pahTiles[nBlockXOff + nBlockYOff * nBlocksPerRow].Start == 0 )
{
// ------------------------------------------------------------
// Uninstantieted tile, unique value
// ------------------------------------------------------------
int nColor = pahTiles[nBlockXOff + nBlockYOff * nBlocksPerRow].Used;
switch( GetColorInterpretation() )
{
case GCI_RedBand:
nColor >>= 16; break;
case GCI_GreenBand:
nColor >>= 8; break;
default:
break;
}
memset( pImage, nColor, nBlockXSize * nBlockYSize *
GDALGetDataTypeSize( eDataType ) / 8 );
return TRUE;
}
示例7: GDALGetDataTypeSize
CPLErr VRTSourcedRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
void * pImage )
{
int nPixelSize = GDALGetDataTypeSize(eDataType)/8;
int nReadXSize, nReadYSize;
if( (nBlockXOff+1) * nBlockXSize > GetXSize() )
nReadXSize = GetXSize() - nBlockXOff * nBlockXSize;
else
nReadXSize = nBlockXSize;
if( (nBlockYOff+1) * nBlockYSize > GetYSize() )
nReadYSize = GetYSize() - nBlockYOff * nBlockYSize;
else
nReadYSize = nBlockYSize;
return IRasterIO( GF_Read,
nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize,
nReadXSize, nReadYSize,
pImage, nReadXSize, nReadYSize, eDataType,
nPixelSize, nPixelSize * nBlockXSize );
}
示例8: RealPixelFunc
CPLErr RealPixelFunc(void **papoSources, int nSources, void *pData,
int nXSize, int nYSize,
GDALDataType eSrcType, GDALDataType eBufType,
int nPixelSpace, int nLineSpace)
{
int iLine, nPixelSpaceSrc, nLineSpaceSrc;
/* ---- Init ---- */
if (nSources != 1) return CE_Failure;
nPixelSpaceSrc = GDALGetDataTypeSize( eSrcType ) / 8;
nLineSpaceSrc = nPixelSpaceSrc * nXSize;
/* ---- Set pixels ---- */
for( iLine = 0; iLine < nYSize; ++iLine ) {
GDALCopyWords(((GByte *)papoSources[0]) + nLineSpaceSrc * iLine,
eSrcType, nPixelSpaceSrc,
((GByte *)pData) + nLineSpace * iLine,
eBufType, nPixelSpace, nXSize);
}
/* ---- Return success ---- */
return CE_None;
} /* RealPixelFunc */
示例9: CPLError
CPLErr GDALWMSRasterBand::ZeroBlock(int x, int y, int to_buffer_band, void *buffer) {
CPLErr ret = CE_None;
for (int ib = 1; ib <= m_parent_dataset->nBands; ++ib) {
if (ret == CE_None) {
void *p = NULL;
GDALRasterBlock *b = NULL;
if ((buffer != NULL) && (ib == to_buffer_band)) {
p = buffer;
} else {
GDALWMSRasterBand *band = static_cast<GDALWMSRasterBand *>(m_parent_dataset->GetRasterBand(ib));
if (m_overview >= 0) band = static_cast<GDALWMSRasterBand *>(band->GetOverview(m_overview));
if (!band->IsBlockInCache(x, y)) {
b = band->GetLockedBlockRef(x, y, true);
if (b != NULL) {
p = b->GetDataRef();
if (p == NULL) {
CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: GetDataRef returned NULL.");
ret = CE_Failure;
}
}
}
}
if (p != NULL) {
unsigned char *b = reinterpret_cast<unsigned char *>(p);
int block_size = nBlockXSize * nBlockYSize * (GDALGetDataTypeSize(eDataType) / 8);
for (int i = 0; i < block_size; ++i) b[i] = 0;
}
if (b != NULL) {
b->DropLock();
}
}
}
return ret;
}
示例10: GetLockedBlockRef
CPLErr VRTWarpedRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
void * pImage )
{
CPLErr eErr;
VRTWarpedDataset *poWDS = (VRTWarpedDataset *) poDS;
GDALRasterBlock *poBlock;
poBlock = GetLockedBlockRef( nBlockXOff, nBlockYOff, TRUE );
eErr = poWDS->ProcessBlock( nBlockXOff, nBlockYOff );
if( eErr == CE_None && pImage != poBlock->GetDataRef() )
{
int nDataBytes;
nDataBytes = (GDALGetDataTypeSize(poBlock->GetDataType()) / 8)
* poBlock->GetXSize() * poBlock->GetYSize();
memcpy( pImage, poBlock->GetDataRef(), nDataBytes );
}
poBlock->DropLock();
return eErr;
}
示例11: ABS
CPLErr RawRasterBand::AccessLine( int iLine )
{
if (pLineBuffer == NULL)
return CE_Failure;
if( nLoadedScanline == iLine )
return CE_None;
/* -------------------------------------------------------------------- */
/* Figure out where to start reading. */
/* -------------------------------------------------------------------- */
vsi_l_offset nReadStart;
if( nPixelOffset >= 0 )
nReadStart = nImgOffset + (vsi_l_offset)iLine * nLineOffset;
else
{
nReadStart = nImgOffset + (vsi_l_offset)iLine * nLineOffset
- ABS(nPixelOffset) * (nBlockXSize-1);
}
/* -------------------------------------------------------------------- */
/* Seek to the right line. */
/* -------------------------------------------------------------------- */
if( Seek(nReadStart, SEEK_SET) == -1 )
{
if (poDS != NULL && poDS->GetAccess() == GA_ReadOnly)
{
CPLError( CE_Failure, CPLE_FileIO,
"Failed to seek to scanline %d @ %d.\n",
iLine, (int) (nImgOffset + (vsi_l_offset)iLine * nLineOffset) );
return CE_Failure;
}
else
{
memset( pLineBuffer, 0, nPixelOffset * nBlockXSize );
nLoadedScanline = iLine;
return CE_None;
}
}
/* -------------------------------------------------------------------- */
/* Read the line. Take care not to request any more bytes than */
/* are needed, and not to lose a partially successful scanline */
/* read. */
/* -------------------------------------------------------------------- */
int nBytesToRead, nBytesActuallyRead;
nBytesToRead = ABS(nPixelOffset) * (nBlockXSize - 1)
+ GDALGetDataTypeSize(GetRasterDataType()) / 8;
nBytesActuallyRead = Read( pLineBuffer, 1, nBytesToRead );
if( nBytesActuallyRead < nBlockXSize )
{
if (poDS != NULL && poDS->GetAccess() == GA_ReadOnly)
{
CPLError( CE_Failure, CPLE_FileIO,
"Failed to read scanline %d.\n",
iLine);
return CE_Failure;
}
else
{
memset( ((GByte *) pLineBuffer) + nBytesActuallyRead,
0, nBytesToRead - nBytesActuallyRead );
}
}
/* -------------------------------------------------------------------- */
/* Byte swap the interesting data, if required. */
/* -------------------------------------------------------------------- */
if( !bNativeOrder && eDataType != GDT_Byte )
{
if( GDALDataTypeIsComplex( eDataType ) )
{
int nWordSize;
nWordSize = GDALGetDataTypeSize(eDataType)/16;
GDALSwapWords( pLineBuffer, nWordSize, nBlockXSize, ABS(nPixelOffset) );
GDALSwapWords( ((GByte *) pLineBuffer)+nWordSize,
nWordSize, nBlockXSize, ABS(nPixelOffset) );
}
else
GDALSwapWords( pLineBuffer, GDALGetDataTypeSize(eDataType)/8,
nBlockXSize, ABS(nPixelOffset) );
}
nLoadedScanline = iLine;
return CE_None;
}
示例12: CPLError
CPLErr VRTSourcedRasterBand::IRasterIO( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nPixelSpace, int nLineSpace )
{
int iSource;
CPLErr eErr = CE_None;
if( eRWFlag == GF_Write )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Writing through VRTSourcedRasterBand is not supported." );
return CE_Failure;
}
/* When using GDALProxyPoolDataset for sources, the recusion will not be */
/* detected at VRT opening but when doing RasterIO. As the proxy pool will */
/* return the already opened dataset, we can just test a member variable. */
if ( bAlreadyInIRasterIO )
{
CPLError( CE_Failure, CPLE_AppDefined,
"VRTSourcedRasterBand::IRasterIO() called recursively on the same band. "
"It looks like the VRT is referencing itself." );
return CE_Failure;
}
/* ==================================================================== */
/* Do we have overviews that would be appropriate to satisfy */
/* this request? */
/* ==================================================================== */
if( (nBufXSize < nXSize || nBufYSize < nYSize)
&& GetOverviewCount() > 0 )
{
if( OverviewRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
pData, nBufXSize, nBufYSize,
eBufType, nPixelSpace, nLineSpace ) == CE_None )
return CE_None;
}
/* -------------------------------------------------------------------- */
/* Initialize the buffer to some background value. Use the */
/* nodata value if available. */
/* -------------------------------------------------------------------- */
if ( nPixelSpace == GDALGetDataTypeSize(eBufType)/8 &&
(!bNoDataValueSet || (!CPLIsNan(dfNoDataValue) && dfNoDataValue == 0)) )
{
if (nLineSpace == nBufXSize * nPixelSpace)
{
memset( pData, 0, nBufYSize * nLineSpace );
}
else
{
int iLine;
for( iLine = 0; iLine < nBufYSize; iLine++ )
{
memset( ((GByte*)pData) + iLine * nLineSpace, 0, nBufXSize * nPixelSpace );
}
}
}
else if ( !bEqualAreas || bNoDataValueSet )
{
double dfWriteValue = 0.0;
int iLine;
if( bNoDataValueSet )
dfWriteValue = dfNoDataValue;
for( iLine = 0; iLine < nBufYSize; iLine++ )
{
GDALCopyWords( &dfWriteValue, GDT_Float64, 0,
((GByte *)pData) + nLineSpace * iLine,
eBufType, nPixelSpace, nBufXSize );
}
}
/* -------------------------------------------------------------------- */
/* Do we have overviews that would be appropriate to satisfy */
/* this request? */
/* -------------------------------------------------------------------- */
if( (nBufXSize < nXSize || nBufYSize < nYSize)
&& GetOverviewCount() > 0 )
{
if( OverviewRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
pData, nBufXSize, nBufYSize,
eBufType, nPixelSpace, nLineSpace ) == CE_None )
return CE_None;
}
bAlreadyInIRasterIO = TRUE;
/* -------------------------------------------------------------------- */
/* Overlay each source in turn over top this. */
/* -------------------------------------------------------------------- */
for( iSource = 0; eErr == CE_None && iSource < nSources; iSource++ )
{
eErr =
papoSources[iSource]->RasterIO( nXOff, nYOff, nXSize, nYSize,
//.........这里部分代码省略.........
示例13: CSLFetchNameValue
GDALDataset *MEMDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
GDALDataType eType,
char **papszOptions )
{
/* -------------------------------------------------------------------- */
/* Do we want a pixel interleaved buffer? I mostly care about */
/* this to test pixel interleaved io in other contexts, but it */
/* could be useful to create a directly accessable buffer for */
/* some apps. */
/* -------------------------------------------------------------------- */
int bPixelInterleaved = FALSE;
const char *pszOption = CSLFetchNameValue( papszOptions, "INTERLEAVE" );
if( pszOption && EQUAL(pszOption,"PIXEL") )
bPixelInterleaved = TRUE;
/* -------------------------------------------------------------------- */
/* First allocate band data, verifying that we can get enough */
/* memory. */
/* -------------------------------------------------------------------- */
std::vector<GByte*> apbyBandData;
int iBand;
int nWordSize = GDALGetDataTypeSize(eType) / 8;
int bAllocOK = TRUE;
if( bPixelInterleaved )
{
apbyBandData.push_back(
(GByte *) VSIMalloc3( nWordSize * nBands, nXSize, nYSize ) );
if( apbyBandData[0] == NULL )
bAllocOK = FALSE;
else
{
memset(apbyBandData[0], 0, ((size_t)nWordSize) * nBands * nXSize * nYSize);
for( iBand = 1; iBand < nBands; iBand++ )
apbyBandData.push_back( apbyBandData[0] + iBand * nWordSize );
}
}
else
{
for( iBand = 0; iBand < nBands; iBand++ )
{
apbyBandData.push_back(
(GByte *) VSIMalloc3( nWordSize, nXSize, nYSize ) );
if( apbyBandData[iBand] == NULL )
{
bAllocOK = FALSE;
break;
}
memset(apbyBandData[iBand], 0, ((size_t)nWordSize) * nXSize * nYSize);
}
}
if( !bAllocOK )
{
for( iBand = 0; iBand < (int) apbyBandData.size(); iBand++ )
{
if( apbyBandData[iBand] )
VSIFree( apbyBandData[iBand] );
}
CPLError( CE_Failure, CPLE_OutOfMemory,
"Unable to create band arrays ... out of memory." );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the new GTiffDataset object. */
/* -------------------------------------------------------------------- */
MEMDataset *poDS;
poDS = new MEMDataset();
poDS->nRasterXSize = nXSize;
poDS->nRasterYSize = nYSize;
poDS->eAccess = GA_Update;
if( bPixelInterleaved )
poDS->SetMetadataItem( "INTERLEAVE", "PIXEL", "IMAGE_STRUCTURE" );
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( iBand = 0; iBand < nBands; iBand++ )
{
MEMRasterBand *poNewBand;
if( bPixelInterleaved )
poNewBand = new MEMRasterBand( poDS, iBand+1, apbyBandData[iBand],
eType, nWordSize * nBands, 0,
iBand == 0 );
else
poNewBand = new MEMRasterBand( poDS, iBand+1, apbyBandData[iBand],
eType, 0, 0, TRUE );
poDS->SetBand( iBand+1, poNewBand );
}
//.........这里部分代码省略.........
示例14: CSLTokenizeStringComplex
//.........这里部分代码省略.........
/* -------------------------------------------------------------------- */
/* Extract other information. */
/* -------------------------------------------------------------------- */
const char *pszOption;
GDALDataType eType;
int nBands, nPixelOffset, nLineOffset;
size_t nBandOffset;
const char *pszDataPointer;
GByte *pabyData;
pszOption = CSLFetchNameValue(papszOptions,"BANDS");
if( pszOption == NULL )
nBands = 1;
else
{
nBands = atoi(pszOption);
}
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) ||
!GDALCheckBandCount(nBands, TRUE))
{
CSLDestroy( papszOptions );
delete poDS;
return NULL;
}
pszOption = CSLFetchNameValue(papszOptions,"DATATYPE");
if( pszOption == NULL )
eType = GDT_Byte;
else
{
if( atoi(pszOption) > 0 && atoi(pszOption) < GDT_TypeCount )
eType = (GDALDataType) atoi(pszOption);
else
{
int iType;
eType = GDT_Unknown;
for( iType = 0; iType < GDT_TypeCount; iType++ )
{
if( EQUAL(GDALGetDataTypeName((GDALDataType) iType),
pszOption) )
{
eType = (GDALDataType) iType;
break;
}
}
if( eType == GDT_Unknown )
{
CPLError( CE_Failure, CPLE_AppDefined,
"DATATYPE=%s not recognised.",
pszOption );
CSLDestroy( papszOptions );
delete poDS;
return NULL;
}
}
}
pszOption = CSLFetchNameValue(papszOptions,"PIXELOFFSET");
if( pszOption == NULL )
nPixelOffset = GDALGetDataTypeSize(eType) / 8;
else
nPixelOffset = atoi(pszOption);
pszOption = CSLFetchNameValue(papszOptions,"LINEOFFSET");
if( pszOption == NULL )
nLineOffset = poDS->nRasterXSize * nPixelOffset;
else
nLineOffset = atoi(pszOption);
pszOption = CSLFetchNameValue(papszOptions,"BANDOFFSET");
if( pszOption == NULL )
nBandOffset = nLineOffset * (size_t) poDS->nRasterYSize;
else
nBandOffset = atoi(pszOption);
pszDataPointer = CSLFetchNameValue(papszOptions,"DATAPOINTER");
pabyData = (GByte *) CPLScanPointer( pszDataPointer,
strlen(pszDataPointer) );
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( int iBand = 0; iBand < nBands; iBand++ )
{
poDS->SetBand( iBand+1,
new MEMRasterBand( poDS, iBand+1,
pabyData + iBand * nBandOffset,
eType, nPixelOffset, nLineOffset,
FALSE ) );
}
/* -------------------------------------------------------------------- */
/* Try to return a regular handle on the file. */
/* -------------------------------------------------------------------- */
CSLDestroy( papszOptions );
return poDS;
}
示例15: CPLGetBasename
GDALDataset *ACE2Dataset::Open( GDALOpenInfo * poOpenInfo )
{
if (!Identify(poOpenInfo))
return NULL;
const char* pszBasename = CPLGetBasename(poOpenInfo->pszFilename);
int nXSize = 0, nYSize = 0;
if (strlen(pszBasename) < 7)
return NULL;
/* Determine southwest coordinates from filename */
/* e.g. 30S120W_5M.ACE2 */
char pszLatLonValueString[4] = { '\0' };
memset(pszLatLonValueString, 0, 4);
strncpy(pszLatLonValueString, &pszBasename[0], 2);
int southWestLat = atoi(pszLatLonValueString);
memset(pszLatLonValueString, 0, 4);
strncpy(pszLatLonValueString, &pszBasename[3], 3);
int southWestLon = atoi(pszLatLonValueString);
if(pszBasename[2] == 'N' || pszBasename[2] == 'n')
/*southWestLat = southWestLat*/;
else if(pszBasename[2] == 'S' || pszBasename[2] == 's')
southWestLat = southWestLat * -1;
else
return NULL;
if(pszBasename[6] == 'E' || pszBasename[6] == 'e')
/*southWestLon = southWestLon*/;
else if(pszBasename[6] == 'W' || pszBasename[6] == 'w')
southWestLon = southWestLon * -1;
else
return NULL;
GDALDataType eDT = GDT_Unknown;
if (strstr(pszBasename, "_CONF_") ||
strstr(pszBasename, "_QUALITY_") ||
strstr(pszBasename, "_SOURCE_"))
eDT = GDT_Int16;
else
eDT = GDT_Float32;
int nWordSize = GDALGetDataTypeSize(eDT) / 8;
VSIStatBufL sStat;
if (strstr(pszBasename, "_5M"))
sStat.st_size = 180 * 180 * nWordSize;
else if (strstr(pszBasename, "_30S"))
sStat.st_size = 1800 * 1800 * nWordSize;
else if (strstr(pszBasename, "_9S"))
sStat.st_size = 6000 * 6000 * nWordSize;
else if (strstr(pszBasename, "_3S"))
sStat.st_size = 18000 * 18000 * nWordSize;
/* Check file size otherwise */
else if(VSIStatL(poOpenInfo->pszFilename, &sStat) != 0)
{
return NULL;
}
double dfPixelSize = 0;
if (sStat.st_size == 180 * 180 * nWordSize)
{
/* 5 minute */
nXSize = nYSize = 180;
dfPixelSize = 5. / 60;
}
else if (sStat.st_size == 1800 * 1800 * nWordSize)
{
/* 30 s */
nXSize = nYSize = 1800;
dfPixelSize = 30. / 3600;
}
else if (sStat.st_size == 6000 * 6000 * nWordSize)
{
/* 9 s */
nXSize = nYSize = 6000;
dfPixelSize = 9. / 3600;
}
else if (sStat.st_size == 18000 * 18000 * nWordSize)
{
/* 3 s */
nXSize = nYSize = 18000;
dfPixelSize = 3. / 3600;
}
else
return NULL;
/* -------------------------------------------------------------------- */
/* Open file. */
/* -------------------------------------------------------------------- */
CPLString osFilename = poOpenInfo->pszFilename;
if ((strstr(poOpenInfo->pszFilename, ".ACE2.gz") ||
strstr(poOpenInfo->pszFilename, ".ace2.gz")) &&
!STARTS_WITH(poOpenInfo->pszFilename, "/vsigzip/"))
osFilename = "/vsigzip/" + osFilename;
VSILFILE* fpImage = VSIFOpenL( osFilename, "rb+" );
//.........这里部分代码省略.........