本文整理汇总了C++中GDALGetDataTypeSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GDALGetDataTypeSize函数的具体用法?C++ GDALGetDataTypeSize怎么用?C++ GDALGetDataTypeSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GDALGetDataTypeSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:22,代码来源:coasp_dataset.cpp
示例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;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:22,代码来源:rawdataset.cpp
示例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;
}
}
开发者ID:0004c,项目名称:node-gdal,代码行数:38,代码来源:rawdataset.cpp
示例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;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:38,代码来源:grass57dataset.cpp
示例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 */
开发者ID:alexamici,项目名称:gdal-pixfun-plugin,代码行数:38,代码来源:pixelfunctions.c
示例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;
}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:23,代码来源:IntergraphBand.cpp
示例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 );
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:23,代码来源:vrtsourcedrasterband.cpp
示例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 */
开发者ID:alexamici,项目名称:gdal-pixfun-plugin,代码行数:24,代码来源:pixelfunctions.c
示例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;
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:36,代码来源:rasterband.cpp
示例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;
}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:24,代码来源:vrtwarped.cpp
示例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;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:91,代码来源:rawdataset.cpp
示例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,
//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,代码来源:vrtsourcedrasterband.cpp
示例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 );
}
//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,代码来源:memdataset.cpp
示例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;
}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,代码来源:memdataset.cpp
示例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+" );
//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,代码来源:ace2dataset.cpp
示例16: G_adjust_Cell_head
CPLErr GRASSRasterBand::IRasterIO ( GDALRWFlag eRWFlag,
int nXOff, int nYOff, int nXSize, int nYSize,
void * pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nPixelSpace, int nLineSpace )
{
/* GRASS library does that, we have only calculate and reset the region in map units
* and if the region has changed, reopen the raster */
/* Calculate the region */
struct Cell_head sWindow;
struct Cell_head *psDsWindow;
if ( ! this->valid ) return CE_Failure;
psDsWindow = &(((GRASSDataset *)poDS)->sCellInfo);
sWindow.north = psDsWindow->north - nYOff * psDsWindow->ns_res;
sWindow.south = sWindow.north - nYSize * psDsWindow->ns_res;
sWindow.west = psDsWindow->west + nXOff * psDsWindow->ew_res;
sWindow.east = sWindow.west + nXSize * psDsWindow->ew_res;
sWindow.proj = psDsWindow->proj;
sWindow.zone = psDsWindow->zone;
sWindow.cols = nBufXSize;
sWindow.rows = nBufYSize;
/* Reset resolution */
G_adjust_Cell_head ( &sWindow, 1, 1);
if ( ResetReading ( &sWindow ) != CE_None )
{
return CE_Failure;
}
/* Read Data */
CELL *cbuf = NULL;
FCELL *fbuf = NULL;
DCELL *dbuf = NULL;
bool direct = false;
/* Reset space if default (0) */
if ( nPixelSpace == 0 )
nPixelSpace = GDALGetDataTypeSize ( eBufType ) / 8;
if ( nLineSpace == 0 )
nLineSpace = nBufXSize * nPixelSpace;
if ( nGRSType == CELL_TYPE && ( !nativeNulls || eBufType != GDT_Int32 || sizeof(CELL) != 4 ||
nPixelSpace != sizeof(CELL) ) )
{
cbuf = G_allocate_c_raster_buf();
} else if( nGRSType == FCELL_TYPE && ( eBufType != GDT_Float32 || nPixelSpace != sizeof(FCELL) ) ) {
fbuf = G_allocate_f_raster_buf();
} else if( nGRSType == DCELL_TYPE && ( eBufType != GDT_Float64 || nPixelSpace != sizeof(DCELL) ) ) {
dbuf = G_allocate_d_raster_buf();
} else {
direct = true;
}
for ( int row = 0; row < nBufYSize; row++ ) {
char *pnt = (char *)pData + row * nLineSpace;
if ( nGRSType == CELL_TYPE ) {
if ( direct ) {
G_get_c_raster_row ( hCell, (CELL *) pnt, row );
} else {
G_get_c_raster_row ( hCell, cbuf, row );
/* Reset NULLs */
for ( int col = 0; col < nBufXSize; col++ ) {
if ( G_is_c_null_value(&(cbuf[col])) )
cbuf[col] = (CELL) dfNoData;
}
GDALCopyWords ( (void *) cbuf, GDT_Int32, sizeof(CELL),
(void *) pnt, eBufType, nPixelSpace,
nBufXSize );
}
} else if( nGRSType == FCELL_TYPE ) {
if ( direct ) {
G_get_f_raster_row ( hCell, (FCELL *) pnt, row );
} else {
G_get_f_raster_row ( hCell, fbuf, row );
GDALCopyWords ( (void *) fbuf, GDT_Float32, sizeof(FCELL),
(void *) pnt, eBufType, nPixelSpace,
nBufXSize );
}
} else if( nGRSType == DCELL_TYPE ) {
if ( direct ) {
G_get_d_raster_row ( hCell, (DCELL *) pnt, row );
} else {
G_get_d_raster_row ( hCell, dbuf, row );
GDALCopyWords ( (void *) dbuf, GDT_Float64, sizeof(DCELL),
(void *) pnt, eBufType, nPixelSpace,
nBufXSize );
}
}
//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,代码来源:grass57dataset.cpp
示例17: GDALGetDataTypeSize
GDALAsyncReader*
ECWDataset::BeginAsyncReader( int nXOff, int nYOff, int nXSize, int nYSize,
void *pBuf, int nBufXSize, int nBufYSize,
GDALDataType eBufType,
int nBandCount, int* panBandMap,
int nPixelSpace, int nLineSpace, int nBandSpace,
char **papszOptions)
{
int i;
/* -------------------------------------------------------------------- */
/* Provide default packing if needed. */
/* -------------------------------------------------------------------- */
if( nPixelSpace == 0 )
nPixelSpace = GDALGetDataTypeSize(eBufType) / 8;
if( nLineSpace == 0 )
nLineSpace = nPixelSpace * nBufXSize;
if( nBandSpace == 0 )
nBandSpace = nLineSpace * nBufYSize;
/* -------------------------------------------------------------------- */
/* Do a bit of validation. */
/* -------------------------------------------------------------------- */
if( nXSize < 1 || nYSize < 1 || nBufXSize < 1 || nBufYSize < 1 )
{
CPLDebug( "GDAL",
"BeginAsyncReader() skipped for odd window or buffer size.\n"
" Window = (%d,%d)x%dx%d\n"
" Buffer = %dx%d\n",
nXOff, nYOff, nXSize, nYSize,
nBufXSize, nBufYSize );
return NULL;
}
if( nXOff < 0 || nXOff > INT_MAX - nXSize || nXOff + nXSize > nRasterXSize
|| nYOff < 0 || nYOff > INT_MAX - nYSize || nYOff + nYSize > nRasterYSize )
{
ReportError( CE_Failure, CPLE_IllegalArg,
"Access window out of range in RasterIO(). Requested\n"
"(%d,%d) of size %dx%d on raster of %dx%d.",
nXOff, nYOff, nXSize, nYSize, nRasterXSize, nRasterYSize );
return NULL;
}
if( nBandCount <= 0 || nBandCount > nBands )
{
ReportError( CE_Failure, CPLE_IllegalArg, "Invalid band count" );
return NULL;
}
if( panBandMap != NULL )
{
for( i = 0; i < nBandCount; i++ )
{
if( panBandMap[i] < 1 || panBandMap[i] > nBands )
{
ReportError( CE_Failure, CPLE_IllegalArg,
"panBandMap[%d] = %d, this band does not exist on dataset.",
i, panBandMap[i] );
return NULL;
}
}
}
/* -------------------------------------------------------------------- */
/* Create the corresponding async reader. */
/* -------------------------------------------------------------------- */
ECWAsyncReader *poReader = new ECWAsyncReader();
poReader->poDS = this;
poReader->nXOff = nXOff;
poReader->nYOff = nYOff;
poReader->nXSize = nXSize;
poReader->nYSize = nYSize;
poReader->pBuf = pBuf;
poReader->nBufXSize = nBufXSize;
poReader->nBufYSize = nBufYSize;
poReader->eBufType = eBufType;
poReader->nBandCount = nBandCount;
poReader->panBandMap = (int *) CPLCalloc(sizeof(int),nBandCount);
if( panBandMap != NULL )
{
memcpy( poReader->panBandMap, panBandMap, sizeof(int) * nBandCount );
}
else
{
for( i = 0; i < nBandCount; i++ )
poReader->panBandMap[i] = i + 1;
}
poReader->nPixelSpace = nPixelSpace;
poReader->nLineSpace = nLineSpace;
poReader->nBandSpace = nBandSpace;
/* -------------------------------------------------------------------- */
/* Create a new view for this request. */
/* -------------------------------------------------------------------- */
//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,代码来源:ecwasyncreader.cpp
示例18: VSIFOpenL
//.........这里部分代码省略.........
poDS = new EIRDataset();
/* -------------------------------------------------------------------- */
/* Capture some information from the file that is of interest. */
/* -------------------------------------------------------------------- */
poDS->nRasterXSize = nCols;
poDS->nRasterYSize = nRows;
poDS->papszHDR = papszHDR;
/* -------------------------------------------------------------------- */
/* Open target binary file. */
/* -------------------------------------------------------------------- */
poDS->fpImage = VSIFOpenL( osRasterFilename.c_str(), "rb" );
if( poDS->fpImage == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to open %s.\n%s",
osRasterFilename.c_str(), VSIStrerror( errno ) );
delete poDS;
return NULL;
}
poDS->papszExtraFiles =
CSLAddString( poDS->papszExtraFiles,
osRasterFilename );
poDS->eAccess = poOpenInfo->eAccess;
/* -------------------------------------------------------------------- */
/* Compute the line offset. */
/* -------------------------------------------------------------------- */
int nItemSize = GDALGetDataTypeSize(eDataType)/8;
int nPixelOffset, nLineOffset;
vsi_l_offset nBandOffset;
if( EQUAL(szLayout,"BIP") )
{
nPixelOffset = nItemSize * nBands;
nLineOffset = nPixelOffset * nCols;
nBandOffset = (vsi_l_offset)nItemSize;
}
else if( EQUAL(szLayout,"BSQ") )
{
nPixelOffset = nItemSize;
nLineOffset = nPixelOffset * nCols;
nBandOffset = (vsi_l_offset)nLineOffset * nRows;
}
else /* assume BIL */
{
nPixelOffset = nItemSize;
nLineOffset = nItemSize * nBands * nCols;
nBandOffset = (vsi_l_offset)nItemSize * nCols;
}
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->PamInitialize();
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->nBands = nBands;
for( i = 0; i < poDS->nBands; i++ )
{
RawRasterBand *poBand;
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:67,代码来源:eirdataset.cpp
示例19: GDALGetDataTypeSize
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18297|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9687|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8185|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8554|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8463|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9400|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8435|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7869|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8420|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7398|2022-11-06
|
请发表评论