本文整理汇总了C++中GDALCheckDatasetDimensions函数的典型用法代码示例。如果您正苦于以下问题:C++ GDALCheckDatasetDimensions函数的具体用法?C++ GDALCheckDatasetDimensions怎么用?C++ GDALCheckDatasetDimensions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GDALCheckDatasetDimensions函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NWT_GRDDataset
GDALDataset *NWT_GRDDataset::Open( GDALOpenInfo * poOpenInfo )
{
if( !Identify(poOpenInfo) )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NWT_GRDDataset *poDS;
poDS = new NWT_GRDDataset();
poDS->fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");
if (poDS->fp == NULL)
{
delete poDS;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
VSIFSeekL( poDS->fp, 0, SEEK_SET );
VSIFReadL( poDS->abyHeader, 1, 1024, poDS->fp );
poDS->pGrd = (NWT_GRID *) malloc(sizeof(NWT_GRID));
if (!nwt_ParseHeader( poDS->pGrd, (char *) poDS->abyHeader ) ||
!GDALCheckDatasetDimensions(poDS->pGrd->nXSide, poDS->pGrd->nYSide) )
{
delete poDS;
return NULL;
}
poDS->nRasterXSize = poDS->pGrd->nXSide;
poDS->nRasterYSize = poDS->pGrd->nYSide;
// create a colorTable
// if( poDS->pGrd->iNumColorInflections > 0 )
// poDS->CreateColorTable();
nwt_LoadColors( poDS->ColorMap, 4096, poDS->pGrd );
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->SetBand( 1, new NWT_GRDRasterBand( poDS, 1 ) ); //r
poDS->SetBand( 2, new NWT_GRDRasterBand( poDS, 2 ) ); //g
poDS->SetBand( 3, new NWT_GRDRasterBand( poDS, 3 ) ); //b
poDS->SetBand( 4, new NWT_GRDRasterBand( poDS, 4 ) ); //z
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
/* -------------------------------------------------------------------- */
/* Check for external overviews. */
/* -------------------------------------------------------------------- */
poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename, poOpenInfo->papszSiblingFiles );
return (poDS);
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:60,代码来源:grddataset.cpp
示例2: NWT_GRDDataset
GDALDataset *NWT_GRDDataset::Open( GDALOpenInfo * poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* Look for the header */
/* -------------------------------------------------------------------- */
if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 50 )
return NULL;
if( poOpenInfo->pabyHeader[0] != 'H' ||
poOpenInfo->pabyHeader[1] != 'G' ||
poOpenInfo->pabyHeader[2] != 'P' ||
poOpenInfo->pabyHeader[3] != 'C' || poOpenInfo->pabyHeader[4] != '1' )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NWT_GRDDataset *poDS;
poDS = new NWT_GRDDataset();
poDS->fp = poOpenInfo->fp;
poOpenInfo->fp = NULL;
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
VSIFSeek( poDS->fp, 0, SEEK_SET );
VSIFRead( poDS->abyHeader, 1, 1024, poDS->fp );
poDS->pGrd = (NWT_GRID *) malloc(sizeof(NWT_GRID));
if (!nwt_ParseHeader( poDS->pGrd, (char *) poDS->abyHeader ) ||
!GDALCheckDatasetDimensions(poDS->pGrd->nXSide, poDS->pGrd->nYSide) )
{
delete poDS;
return NULL;
}
poDS->nRasterXSize = poDS->pGrd->nXSide;
poDS->nRasterYSize = poDS->pGrd->nYSide;
// create a colorTable
// if( poDS->pGrd->iNumColorInflections > 0 )
// poDS->CreateColorTable();
nwt_LoadColors( poDS->ColorMap, 4096, poDS->pGrd );
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->SetBand( 1, new NWT_GRDRasterBand( poDS, 1 ) ); //r
poDS->SetBand( 2, new NWT_GRDRasterBand( poDS, 2 ) ); //g
poDS->SetBand( 3, new NWT_GRDRasterBand( poDS, 3 ) ); //b
poDS->SetBand( 4, new NWT_GRDRasterBand( poDS, 4 ) ); //z
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
return (poDS);
}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:60,代码来源:grddataset.cpp
示例3: NWT_GRCDataset
GDALDataset *NWT_GRCDataset::Open( GDALOpenInfo * poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* Look for the header */
/* -------------------------------------------------------------------- */
if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 50 )
return NULL;
if( poOpenInfo->pabyHeader[0] != 'H' ||
poOpenInfo->pabyHeader[1] != 'G' ||
poOpenInfo->pabyHeader[2] != 'P' ||
poOpenInfo->pabyHeader[3] != 'C' ||
poOpenInfo->pabyHeader[4] != '8' )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NWT_GRCDataset *poDS;
poDS = new NWT_GRCDataset();
poDS->fp = poOpenInfo->fp;
poOpenInfo->fp = NULL;
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
VSIFSeek( poDS->fp, 0, SEEK_SET );
VSIFRead( poDS->abyHeader, 1, 1024, poDS->fp );
poDS->pGrd = (NWT_GRID *) malloc( sizeof (NWT_GRID) );
poDS->pGrd->fp = poDS->fp;
if (!nwt_ParseHeader( poDS->pGrd, (char *) poDS->abyHeader ) ||
!GDALCheckDatasetDimensions(poDS->pGrd->nXSide, poDS->pGrd->nYSide) ||
poDS->pGrd->stClassDict == NULL)
{
delete poDS;
return NULL;
}
poDS->nRasterXSize = poDS->pGrd->nXSide;
poDS->nRasterYSize = poDS->pGrd->nYSide;
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->SetBand( 1, new NWT_GRCRasterBand( poDS, 1) ); //Class Indexes
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
return (poDS);
}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:58,代码来源:grcdataset.cpp
示例4: NWT_GRCDataset
GDALDataset *NWT_GRCDataset::Open( GDALOpenInfo * poOpenInfo )
{
if( !Identify(poOpenInfo) )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NWT_GRCDataset *poDS;
poDS = new NWT_GRCDataset();
poDS->fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");
if (poDS->fp == NULL)
{
delete poDS;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
VSIFSeekL( poDS->fp, 0, SEEK_SET );
VSIFReadL( poDS->abyHeader, 1, 1024, poDS->fp );
poDS->pGrd = (NWT_GRID *) malloc( sizeof (NWT_GRID) );
poDS->pGrd->fp = poDS->fp;
if (!nwt_ParseHeader( poDS->pGrd, (char *) poDS->abyHeader ) ||
!GDALCheckDatasetDimensions(poDS->pGrd->nXSide, poDS->pGrd->nYSide) ||
poDS->pGrd->stClassDict == NULL)
{
delete poDS;
return NULL;
}
poDS->nRasterXSize = poDS->pGrd->nXSide;
poDS->nRasterYSize = poDS->pGrd->nYSide;
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->SetBand( 1, new NWT_GRCRasterBand( poDS, 1) ); //Class Indexes
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
/* -------------------------------------------------------------------- */
/* Check for external overviews. */
/* -------------------------------------------------------------------- */
poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename, poOpenInfo->GetSiblingFiles() );
return (poDS);
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:57,代码来源:grcdataset.cpp
示例5: CPLError
GDALDataset* EpsilonDataset::Open(GDALOpenInfo* poOpenInfo)
{
if (!Identify(poOpenInfo))
return NULL;
if( poOpenInfo->eAccess == GA_Update )
{
CPLError( CE_Failure, CPLE_NotSupported,
"The EPSILON driver does not support update access to existing"
" files.\n" );
return NULL;
}
VSILFILE* fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");
if (fp == NULL)
return NULL;
EpsilonDataset* poDS = new EpsilonDataset();
poDS->fp = fp;
poDS->nRasterXSize = 0;
poDS->nRasterYSize = 0;
int nBandsToAdd = 0;
if (!poDS->ScanBlocks(&nBandsToAdd))
{
delete poDS;
return NULL;
}
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) ||
!GDALCheckBandCount(nBandsToAdd, FALSE))
{
delete poDS;
return NULL;
}
if (!poDS->bRegularTiling)
{
CPLError( CE_Failure, CPLE_NotSupported,
"The EPSILON driver does not support reading "
"not regularly blocked files.\n" );
delete poDS;
return NULL;
}
int i;
for(i=1;i<=nBandsToAdd;i++)
poDS->SetBand(i, new EpsilonRasterBand(poDS, i));
if (nBandsToAdd > 1)
poDS->SetMetadataItem("INTERLEAVE", "PIXEL", "IMAGE_STRUCTURE");
return poDS;
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:54,代码来源:epsilondataset.cpp
示例6: CPLDebug
RawRasterBand::RawRasterBand( void * fpRaw, vsi_l_offset nImgOffset,
int nPixelOffset, int nLineOffset,
GDALDataType eDataType, int bNativeOrder,
int nXSize, int nYSize, int bIsVSIL, int bOwnsFP )
{
this->poDS = NULL;
this->nBand = 1;
this->eDataType = eDataType;
this->bIsVSIL = bIsVSIL;
this->bOwnsFP =bOwnsFP;
if (bIsVSIL)
{
this->fpRaw = NULL;
this->fpRawL = (VSILFILE*) fpRaw;
}
else
{
this->fpRaw = (FILE*) fpRaw;
this->fpRawL = NULL;
}
this->nImgOffset = nImgOffset;
this->nPixelOffset = nPixelOffset;
this->nLineOffset = nLineOffset;
this->bNativeOrder = bNativeOrder;
CPLDebug( "GDALRaw",
"RawRasterBand(floating,Off=%d,PixOff=%d,LineOff=%d,%s,%d)\n",
(unsigned int) nImgOffset, nPixelOffset, nLineOffset,
GDALGetDataTypeName(eDataType), bNativeOrder );
/* -------------------------------------------------------------------- */
/* Treat one scanline as the block size. */
/* -------------------------------------------------------------------- */
nBlockXSize = nXSize;
nBlockYSize = 1;
nRasterXSize = nXSize;
nRasterYSize = nYSize;
if (!GDALCheckDatasetDimensions(nXSize, nYSize))
{
pLineBuffer = NULL;
return;
}
/* -------------------------------------------------------------------- */
/* Initialize other fields, and setup the line buffer. */
/* -------------------------------------------------------------------- */
Initialize();
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:51,代码来源:rawdataset.cpp
示例7: CPLGetPath
GDALDataset *SAGADataset::Open( GDALOpenInfo * poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* We assume the user is pointing to the binary (ie. .sdat) file. */
/* -------------------------------------------------------------------- */
if( !EQUAL(CPLGetExtension( poOpenInfo->pszFilename ), "sdat"))
{
return NULL;
}
CPLString osPath = CPLGetPath( poOpenInfo->pszFilename );
CPLString osName = CPLGetBasename( poOpenInfo->pszFilename );
CPLString osHDRFilename;
osHDRFilename = CPLFormCIFilename( osPath, osName, ".sgrd" );
VSILFILE *fp;
fp = VSIFOpenL( osHDRFilename, "r" );
if( fp == NULL )
{
return NULL;
}
/* -------------------------------------------------------------------- */
/* Is this file a SAGA header file? Read a few lines of text */
/* searching for something starting with nrows or ncols. */
/* -------------------------------------------------------------------- */
const char *pszLine;
int nRows = -1, nCols = -1;
double dXmin = 0.0, dYmin = 0.0, dCellsize = 0.0, dNoData = 0.0, dZFactor = 0.0;
int nLineCount = 0;
char szDataFormat[20] = "DOUBLE";
char szByteOrderBig[10] = "FALSE";
char szTopToBottom[10] = "FALSE";
char **papszHDR = NULL;
while( (pszLine = CPLReadLineL( fp )) != NULL )
{
char **papszTokens;
nLineCount++;
if( nLineCount > 50 || strlen(pszLine) > 1000 )
break;
papszHDR = CSLAddString( papszHDR, pszLine );
papszTokens = CSLTokenizeStringComplex( pszLine, " =", TRUE, FALSE );
if( CSLCount( papszTokens ) < 2 )
{
CSLDestroy( papszTokens );
continue;
}
if( EQUALN(papszTokens[0],"CELLCOUNT_X",strlen("CELLCOUNT_X")) )
nCols = atoi(papszTokens[1]);
else if( EQUALN(papszTokens[0],"CELLCOUNT_Y",strlen("CELLCOUNT_Y")) )
nRows = atoi(papszTokens[1]);
else if( EQUALN(papszTokens[0],"POSITION_XMIN",strlen("POSITION_XMIN")) )
dXmin = CPLAtofM(papszTokens[1]);
else if( EQUALN(papszTokens[0],"POSITION_YMIN",strlen("POSITION_YMIN")) )
dYmin = CPLAtofM(papszTokens[1]);
else if( EQUALN(papszTokens[0],"CELLSIZE",strlen("CELLSIZE")) )
dCellsize = CPLAtofM(papszTokens[1]);
else if( EQUALN(papszTokens[0],"NODATA_VALUE",strlen("NODATA_VALUE")) )
dNoData = CPLAtofM(papszTokens[1]);
else if( EQUALN(papszTokens[0],"DATAFORMAT",strlen("DATAFORMAT")) )
strncpy( szDataFormat, papszTokens[1], sizeof(szDataFormat)-1 );
else if( EQUALN(papszTokens[0],"BYTEORDER_BIG",strlen("BYTEORDER_BIG")) )
strncpy( szByteOrderBig, papszTokens[1], sizeof(szByteOrderBig)-1 );
else if( EQUALN(papszTokens[0],"TOPTOBOTTOM",strlen("TOPTOBOTTOM")) )
strncpy( szTopToBottom, papszTokens[1], sizeof(szTopToBottom)-1 );
else if( EQUALN(papszTokens[0],"Z_FACTOR",strlen("Z_FACTOR")) )
dZFactor = CPLAtofM(papszTokens[1]);
CSLDestroy( papszTokens );
}
VSIFCloseL( fp );
CSLDestroy( papszHDR );
/* -------------------------------------------------------------------- */
/* Did we get the required keywords? If not we return with */
/* this never having been considered to be a match. This isn't */
/* an error! */
/* -------------------------------------------------------------------- */
if( nRows == -1 || nCols == -1 )
{
return NULL;
}
if (!GDALCheckDatasetDimensions(nCols, nRows))
{
return NULL;
//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,代码来源:sagadataset.cpp
示例8: osOriginalFilename
GDALDataset *HF2Dataset::Open( GDALOpenInfo * poOpenInfo )
{
CPLString osOriginalFilename(poOpenInfo->pszFilename);
if (!Identify(poOpenInfo))
return NULL;
GDALOpenInfo* poOpenInfoToDelete = NULL;
/* GZipped .hf2 files are common, so automagically open them */
/* if the /vsigzip/ has not been explicitly passed */
CPLString osFilename(poOpenInfo->pszFilename);
if ((EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "hfz") ||
(strlen(poOpenInfo->pszFilename) > 6 &&
EQUAL(poOpenInfo->pszFilename + strlen(poOpenInfo->pszFilename) - 6, "hf2.gz"))) &&
!EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))
{
osFilename = "/vsigzip/";
osFilename += poOpenInfo->pszFilename;
poOpenInfo = poOpenInfoToDelete =
new GDALOpenInfo(osFilename.c_str(), GA_ReadOnly,
poOpenInfo->GetSiblingFiles());
}
/* -------------------------------------------------------------------- */
/* Parse header */
/* -------------------------------------------------------------------- */
int nXSize, nYSize;
memcpy(&nXSize, poOpenInfo->pabyHeader + 6, 4);
CPL_LSBPTR32(&nXSize);
memcpy(&nYSize, poOpenInfo->pabyHeader + 10, 4);
CPL_LSBPTR32(&nYSize);
GUInt16 nTileSize;
memcpy(&nTileSize, poOpenInfo->pabyHeader + 14, 2);
CPL_LSBPTR16(&nTileSize);
float fVertPres, fHorizScale;
memcpy(&fVertPres, poOpenInfo->pabyHeader + 16, 4);
CPL_LSBPTR32(&fVertPres);
memcpy(&fHorizScale, poOpenInfo->pabyHeader + 20, 4);
CPL_LSBPTR32(&fHorizScale);
GUInt32 nExtendedHeaderLen;
memcpy(&nExtendedHeaderLen, poOpenInfo->pabyHeader + 24, 4);
CPL_LSBPTR32(&nExtendedHeaderLen);
delete poOpenInfoToDelete;
poOpenInfoToDelete = NULL;
if (nTileSize < 8)
return NULL;
if (nXSize <= 0 || nXSize > INT_MAX - nTileSize ||
nYSize <= 0 || nYSize > INT_MAX - nTileSize)
return NULL;
/* To avoid later potential int overflows */
if (nExtendedHeaderLen > 1024 * 65536)
return NULL;
if (!GDALCheckDatasetDimensions(nXSize, nYSize))
{
return NULL;
}
/* -------------------------------------------------------------------- */
/* Parse extended blocks */
/* -------------------------------------------------------------------- */
VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb");
if (fp == NULL)
return NULL;
VSIFSeekL(fp, 28, SEEK_SET);
int bHasExtent = FALSE;
double dfMinX = 0, dfMaxX = 0, dfMinY = 0, dfMaxY = 0;
int bHasUTMZone = FALSE;
GInt16 nUTMZone = 0;
int bHasEPSGDatumCode = FALSE;
GInt16 nEPSGDatumCode = 0;
int bHasEPSGCode = FALSE;
GInt16 nEPSGCode = 0;
int bHasRelativePrecision = FALSE;
float fRelativePrecision = 0;
char szApplicationName[256];
szApplicationName[0] = 0;
GUInt32 nExtendedHeaderOff = 0;
while(nExtendedHeaderOff < nExtendedHeaderLen)
{
char pabyBlockHeader[24];
VSIFReadL(pabyBlockHeader, 24, 1, fp);
char szBlockName[16 + 1];
memcpy(szBlockName, pabyBlockHeader + 4, 16);
szBlockName[16] = 0;
GUInt32 nBlockSize;
memcpy(&nBlockSize, pabyBlockHeader + 20, 4);
CPL_LSBPTR32(&nBlockSize);
//.........这里部分代码省略.........
开发者ID:MattLatt,项目名称:GDAL_2.0.x_VC,代码行数:101,代码来源:hf2dataset.cpp
示例9: GTXDataset
GDALDataset *GTXDataset::Open( GDALOpenInfo * poOpenInfo )
{
if( !Identify( poOpenInfo ) )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
GTXDataset *poDS = new GTXDataset();
poDS->eAccess = poOpenInfo->eAccess;
/* -------------------------------------------------------------------- */
/* Open the file. */
/* -------------------------------------------------------------------- */
if( poOpenInfo->eAccess == GA_ReadOnly )
poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" );
else
poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" );
if( poDS->fpImage == NULL )
{
delete poDS;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
poDS->adfGeoTransform[2] = 0.0;
poDS->adfGeoTransform[4] = 0.0;
CPL_IGNORE_RET_VAL(VSIFReadL( poDS->adfGeoTransform+3, 8, 1,
poDS->fpImage ));
CPL_IGNORE_RET_VAL(VSIFReadL( poDS->adfGeoTransform+0, 8, 1,
poDS->fpImage ));
CPL_IGNORE_RET_VAL(VSIFReadL( poDS->adfGeoTransform+5, 8, 1,
poDS->fpImage ));
CPL_IGNORE_RET_VAL(VSIFReadL( poDS->adfGeoTransform+1, 8, 1,
poDS->fpImage ));
CPL_IGNORE_RET_VAL(VSIFReadL( &(poDS->nRasterYSize), 4, 1, poDS->fpImage ));
CPL_IGNORE_RET_VAL(VSIFReadL( &(poDS->nRasterXSize), 4, 1, poDS->fpImage ));
CPL_MSBPTR32( &(poDS->nRasterYSize) );
CPL_MSBPTR32( &(poDS->nRasterXSize) );
CPL_MSBPTR64( poDS->adfGeoTransform + 0 );
CPL_MSBPTR64( poDS->adfGeoTransform + 1 );
CPL_MSBPTR64( poDS->adfGeoTransform + 3 );
CPL_MSBPTR64( poDS->adfGeoTransform + 5 );
poDS->adfGeoTransform[3] +=
poDS->adfGeoTransform[5] * (poDS->nRasterYSize-1);
poDS->adfGeoTransform[0] -= poDS->adfGeoTransform[1] * 0.5;
poDS->adfGeoTransform[3] += poDS->adfGeoTransform[5] * 0.5;
poDS->adfGeoTransform[5] *= -1;
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
{
delete poDS;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Guess the data type. Since October 1, 2009, it should be */
/* Float32. Before it was double. */
/* -------------------------------------------------------------------- */
CPL_IGNORE_RET_VAL(VSIFSeekL(poDS->fpImage, 0, SEEK_END));
const vsi_l_offset nSize = VSIFTellL(poDS->fpImage);
GDALDataType eDT = GDT_Float32;
if( nSize == 40 + 8 * static_cast<vsi_l_offset>(poDS->nRasterXSize) *
poDS->nRasterYSize )
eDT = GDT_Float64;
const int nDTSize = GDALGetDataTypeSizeBytes(eDT);
/* -------------------------------------------------------------------- */
/* Create band information object. */
/* -------------------------------------------------------------------- */
RawRasterBand *poBand = new RawRasterBand(
poDS, 1, poDS->fpImage,
(poDS->nRasterYSize-1) * poDS->nRasterXSize*nDTSize + 40,
nDTSize, poDS->nRasterXSize * -nDTSize,
eDT,
!CPL_IS_LSB, TRUE, FALSE );
poBand->SetNoDataValue( -88.8888 );
poDS->SetBand( 1, poBand );
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
/* -------------------------------------------------------------------- */
/* Check for overviews. */
//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,代码来源:gtxdataset.cpp
示例10: VSIFOpenL
//.........这里部分代码省略.........
{
CSLDestroy( papszHeader );
CPLError( CE_Failure, CPLE_NotSupported,
"The NDF driver does not support update access to existing"
" datasets.\n" );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NDFDataset *poDS;
poDS = new NDFDataset();
poDS->papszHeader = papszHeader;
poDS->nRasterXSize = atoi(poDS->Get("PIXELS_PER_LINE",""));
poDS->nRasterYSize = atoi(poDS->Get("LINES_PER_DATA_FILE",""));
/* -------------------------------------------------------------------- */
/* Create a raw raster band for each file. */
/* -------------------------------------------------------------------- */
int iBand;
const char* pszBand = CSLFetchNameValue(papszHeader,
"NUMBER_OF_BANDS_IN_VOLUME");
if (pszBand == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined, "Cannot find band count");
delete poDS;
return NULL;
}
int nBands = atoi(pszBand);
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) ||
!GDALCheckBandCount(nBands, FALSE))
{
delete poDS;
return NULL;
}
for( iBand = 0; iBand < nBands; iBand++ )
{
char szKey[100];
CPLString osFilename;
sprintf( szKey, "BAND%d_FILENAME", iBand+1 );
osFilename = poDS->Get(szKey,"");
// NDF1 file do not include the band filenames.
if( osFilename.size() == 0 )
{
char szBandExtension[15];
sprintf( szBandExtension, "I%d", iBand+1 );
osFilename = CPLResetExtension( poOpenInfo->pszFilename,
szBandExtension );
}
else
{
CPLString osBasePath = CPLGetPath(poOpenInfo->pszFilename);
osFilename = CPLFormFilename( osBasePath, osFilename, NULL);
}
VSILFILE *fpRaw = VSIFOpenL( osFilename, "rb" );
if( fpRaw == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:67,代码来源:ndfdataset.cpp
示例11: DTEDOpenEx
GDALDataset *DTEDDataset::Open( GDALOpenInfo * poOpenInfo )
{
int i;
DTEDInfo *psDTED;
if (!Identify(poOpenInfo) || poOpenInfo->fpL == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Try opening the dataset. */
/* -------------------------------------------------------------------- */
VSILFILE* fp = poOpenInfo->fpL;
poOpenInfo->fpL = NULL;
psDTED = DTEDOpenEx( fp, poOpenInfo->pszFilename,
(poOpenInfo->eAccess == GA_Update) ? "rb+" : "rb", TRUE );
if( psDTED == NULL )
return( NULL );
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
DTEDDataset *poDS;
poDS = new DTEDDataset();
poDS->SetFileName(poOpenInfo->pszFilename);
poDS->eAccess = poOpenInfo->eAccess;
poDS->psDTED = psDTED;
/* -------------------------------------------------------------------- */
/* Capture some information from the file that is of interest. */
/* -------------------------------------------------------------------- */
poDS->nRasterXSize = psDTED->nXSize;
poDS->nRasterYSize = psDTED->nYSize;
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
{
delete poDS;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->nBands = 1;
for( i = 0; i < poDS->nBands; i++ )
poDS->SetBand( i+1, new DTEDRasterBand( poDS, i+1 ) );
/* -------------------------------------------------------------------- */
/* Collect any metadata available. */
/* -------------------------------------------------------------------- */
char *pszValue;
pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTACCURACY_UHL );
poDS->SetMetadataItem( "DTED_VerticalAccuracy_UHL", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTACCURACY_ACC );
poDS->SetMetadataItem( "DTED_VerticalAccuracy_ACC", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_SECURITYCODE_UHL );
poDS->SetMetadataItem( "DTED_SecurityCode_UHL", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_SECURITYCODE_DSI );
poDS->SetMetadataItem( "DTED_SecurityCode_DSI", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_UNIQUEREF_UHL );
poDS->SetMetadataItem( "DTED_UniqueRef_UHL", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_UNIQUEREF_DSI );
poDS->SetMetadataItem( "DTED_UniqueRef_DSI", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_DATA_EDITION );
poDS->SetMetadataItem( "DTED_DataEdition", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_VERSION );
poDS->SetMetadataItem( "DTED_MatchMergeVersion", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DATE );
poDS->SetMetadataItem( "DTED_MaintenanceDate", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_DATE );
poDS->SetMetadataItem( "DTED_MatchMergeDate", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DESCRIPTION );
poDS->SetMetadataItem( "DTED_MaintenanceDescription", pszValue );
CPLFree( pszValue );
pszValue = DTEDGetMetadata( psDTED, DTEDMD_PRODUCER );
//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,代码来源:dteddataset.cpp
示例12: VSIFOpenL
//.........这里部分代码省略.........
CSLDestroy( papszTokens );
CSLDestroy( papszHDR );
VSIFCloseL( fp );
return NULL;
}
}
else if( EQUAL(papszTokens[0],"BYTE_ORDER") )
{
// M for MSB, L for LSB
chByteOrder = (char) toupper(papszTokens[1][0]);
}
else if( EQUAL(papszTokens[0],"DATA_OFFSET") )
{
nSkipBytes = atoi(papszTokens[1]); // TBD: is this mapping right?
}
CSLDestroy( papszTokens );
}
VSIFCloseL( fp );
/* -------------------------------------------------------------------- */
/* Did we get the required keywords? If not we return with */
/* this never having been considered to be a match. This isn't */
/* an error! */
/* -------------------------------------------------------------------- */
if( nRows == -1 || nCols == -1 )
{
CSLDestroy( papszHDR );
return NULL;
}
if (!GDALCheckDatasetDimensions(nCols, nRows) ||
!GDALCheckBandCount(nBands, FALSE))
{
CSLDestroy( papszHDR );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Confirm the requested access is supported. */
/* -------------------------------------------------------------------- */
if( poOpenInfo->eAccess == GA_Update )
{
CSLDestroy( papszHDR );
CPLError( CE_Failure, CPLE_NotSupported,
"The EIR driver does not support update access to existing"
" datasets.\n" );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
EIRDataset *poDS;
poDS = new EIRDataset();
/* -------------------------------------------------------------------- */
/* Capture some information from the file that is of interest. */
/* -------------------------------------------------------------------- */
poDS->nRasterXSize = nCols;
poDS->nRasterYSize = nRows;
poDS->papszHDR = papszHDR;
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:65,代码来源:eirdataset.cpp
示例13: CSLTokenizeStringComplex
GDALDataset *MEMDataset::Open( GDALOpenInfo * poOpenInfo )
{
char **papszOptions;
/* -------------------------------------------------------------------- */
/* Do we have the special filename signature for MEM format */
/* description strings? */
/* -------------------------------------------------------------------- */
if( !EQUALN(poOpenInfo->pszFilename,"MEM:::",6)
|| poOpenInfo->fp != NULL )
return NULL;
papszOptions = CSLTokenizeStringComplex(poOpenInfo->pszFilename+6, ",",
TRUE, FALSE );
/* -------------------------------------------------------------------- */
/* Verify we have all required fields */
/* -------------------------------------------------------------------- */
if( CSLFetchNameValue( papszOptions, "PIXELS" ) == NULL
|| CSLFetchNameValue( papszOptions, "LINES" ) == NULL
|| CSLFetchNameValue( papszOptions, "DATAPOINTER" ) == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing required field (one of PIXELS, LINES or DATAPOINTER)\n"
"Unable to access in-memory array." );
CSLDestroy( papszOptions );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the new MEMDataset object. */
/* -------------------------------------------------------------------- */
MEMDataset *poDS;
poDS = new MEMDataset();
poDS->nRasterXSize = atoi(CSLFetchNameValue(papszOptions,"PIXELS"));
poDS->nRasterYSize = atoi(CSLFetchNameValue(papszOptions,"LINES"));
poDS->eAccess = GA_Update;
/* -------------------------------------------------------------------- */
/* 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;
}
}
//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,代码来源:memdataset.cpp
示例14: CPLParseXMLString
GDALDataset *VRTDataset::OpenXML( const char *pszXML, const char *pszVRTPath,
GDALAccess eAccess)
{
/* -------------------------------------------------------------------- */
/* Parse the XML. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psTree;
psTree = CPLParseXMLString( pszXML );
if( psTree == NULL )
return NULL;
CPLXMLNode *psRoot = CPLGetXMLNode( psTree, "=VRTDataset" );
if (psRoot == NULL)
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing VRTDataset element." );
CPLDestroyXMLNode( psTree );
return NULL;
}
if( CPLGetXMLNode( psRoot, "rasterXSize" ) == NULL
|| CPLGetXMLNode( psRoot, "rasterYSize" ) == NULL
|| CPLGetXMLNode( psRoot, "VRTRasterBand" ) == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing one of rasterXSize, rasterYSize or bands on"
" VRTDataset." );
CPLDestroyXMLNode( psTree );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the new virtual dataset object. */
/* -------------------------------------------------------------------- */
VRTDataset *poDS;
int nXSize = atoi(CPLGetXMLValue(psRoot,"rasterXSize","0"));
int nYSize = atoi(CPLGetXMLValue(psRoot,"rasterYSize","0"));
if ( !GDALCheckDatasetDimensions(nXSize, nYSize) )
{
CPLDestroyXMLNode( psTree );
return NULL;
}
if( strstr(pszXML,"VRTWarpedDataset") != NULL )
poDS = new VRTWarpedDataset( nXSize, nYSize );
else
{
poDS = new VRTDataset( nXSize, nYSize );
poDS->eAccess = eAccess;
}
if( poDS->XMLInit( psRoot, pszVRTPath ) != CE_None )
{
delete poDS;
poDS = NULL;
}
/* -------------------------------------------------------------------- */
/* Try to return a regular handle on the file. */
/* -------------------------------------------------------------------- */
CPLDestroyXMLNode( psTree );
return poDS;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:68,代码来源:vrtdataset.cpp
示例15: CSLTokenizeString2
int AAIGDataset::ParseHeader(const char *pszHeader, const char *pszDataType)
{
char **papszTokens = CSLTokenizeString2(pszHeader, " \n\r\t", 0);
const int nTokens = CSLCount(papszTokens);
int i = 0;
if ( (i = CSLFindString(papszTokens, "ncols")) < 0 ||
i + 1 >= nTokens)
{
CSLDestroy(papszTokens);
return FALSE;
}
nRasterXSize = atoi(papszTokens[i + 1]);
if ( (i = CSLFindString(papszTokens, "nrows")) < 0 ||
i + 1 >= nTokens)
{
CSLDestroy(papszTokens);
return FALSE;
}
nRasterYSize = atoi(papszTokens[i + 1]);
if (!GDALCheckDatasetDimensions(nRasterXSize, nRasterYSize))
{
CSLDestroy(papszTokens);
return FALSE;
}
// TODO(schwehr): Would be good to also factor the file size into the max.
// TODO(schwehr): Allow the user to disable this check.
// The driver allocates a panLineOffset array based on nRasterYSize
constexpr int kMaxDimSize = 10000000; // 1e7 cells.
if (nRasterXSize > kMaxDimSize || nRasterYSize > kMaxDimSize)
{
CSLDestroy(papszTokens);
return FALSE;
}
double dfCellDX = 0.0;
double dfCellDY = 0.0;
if ( (i = CSLFindString(papszTokens, "cellsize")) < 0 )
{
int iDX, iDY;
if( (iDX = CSLFindString(papszTokens, "dx")) < 0 ||
(iDY = CSLFindString(papszTokens, "dy")) < 0 ||
iDX + 1 >= nTokens ||
iDY + 1 >= nTokens )
{
CSLDestroy(papszTokens);
return FALSE;
}
dfCellDX = CPLAtofM(papszTokens[iDX + 1]);
dfCellDY = CPLAtofM(papszTokens[iDY + 1]);
}
else
{
if (i + 1 >= nTokens)
{
CSLDestroy(papszTokens);
return FALSE;
}
dfCellDY = CPLAtofM(papszTokens[i + 1]);
dfCellDX = dfCellDY;
}
int j = 0;
if ((i = CSLFindString(papszTokens, "xllcorner")) >= 0 &&
(j = CSLFindString(papszTokens, "yllcorner")) >= 0 &&
i + 1 < nTokens && j + 1 < nTokens)
{
adfGeoTransform[0] = CPLAtofM(papszTokens[i + 1]);
// Small hack to compensate from insufficient precision in cellsize
// parameter in datasets of
// http://ccafs-climate.org/data/A2a_2020s/hccpr_hadcm3
if ((nRasterXSize % 360) == 0 &&
fabs(adfGeoTransform[0] - (-180.0)) < 1e-12 &&
dfCellDX == dfCellDY &&
fabs(dfCellDX - (3
|
请发表评论