本文整理汇总了C++中VSIFWriteL函数的典型用法代码示例。如果您正苦于以下问题:C++ VSIFWriteL函数的具体用法?C++ VSIFWriteL怎么用?C++ VSIFWriteL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSIFWriteL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: empty_output_buffer
empty_output_buffer (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
size_t bytes_to_write = OUTPUT_BUF_SIZE;
#ifdef IPPJ_HUFF
/*
* The Intel IPP performance libraries do not necessarily fill up
* the whole output buffer with each compression pass, so we only
* want to write out the parts of the buffer that are full.
*/
if(! cinfo->progressive_mode) {
bytes_to_write -= dest->pub.free_in_buffer;
}
#endif
if (VSIFWriteL(dest->buffer, 1, bytes_to_write, dest->outfile) != bytes_to_write)
ERREXIT(cinfo, JERR_FILE_WRITE);
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
return TRUE;
}
示例2: NITFDESExtractShapefile
int NITFDESExtractShapefile(NITFDES* psDES, const char* pszRadixFileName)
{
NITFSegmentInfo* psSegInfo;
const char* apszExt[3];
int anOffset[4];
int iShpFile;
char* pszFilename;
if ( CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE_USE") == NULL )
return FALSE;
psSegInfo = psDES->psFile->pasSegmentInfo + psDES->iSegment;
apszExt[0] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE1_NAME");
anOffset[0] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE1_START"));
apszExt[1] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE2_NAME");
anOffset[1] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE2_START"));
apszExt[2] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE3_NAME");
anOffset[2] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE3_START"));
anOffset[3] = (int) psSegInfo->nSegmentSize;
for(iShpFile = 0; iShpFile < 3; iShpFile ++)
{
if (!EQUAL(apszExt[iShpFile], "SHP") &&
!EQUAL(apszExt[iShpFile], "SHX") &&
!EQUAL(apszExt[iShpFile], "DBF"))
return FALSE;
if (anOffset[iShpFile] < 0 ||
anOffset[iShpFile] >= anOffset[iShpFile+1])
return FALSE;
}
pszFilename = (char*) VSIMalloc(strlen(pszRadixFileName) + 4 + 1);
if (pszFilename == NULL)
return FALSE;
for(iShpFile = 0; iShpFile < 3; iShpFile ++)
{
VSILFILE* fp;
GByte* pabyBuffer;
int nSize = anOffset[iShpFile+1] - anOffset[iShpFile];
pabyBuffer = (GByte*) VSIMalloc(nSize);
if (pabyBuffer == NULL)
{
VSIFree(pszFilename);
return FALSE;
}
VSIFSeekL(psDES->psFile->fp, psSegInfo->nSegmentStart + anOffset[iShpFile], SEEK_SET);
if (VSIFReadL(pabyBuffer, 1, nSize, psDES->psFile->fp) != nSize)
{
VSIFree(pabyBuffer);
VSIFree(pszFilename);
return FALSE;
}
sprintf(pszFilename, "%s.%s", pszRadixFileName, apszExt[iShpFile]);
fp = VSIFOpenL(pszFilename, "wb");
if (fp == NULL)
{
VSIFree(pabyBuffer);
VSIFree(pszFilename);
return FALSE;
}
VSIFWriteL(pabyBuffer, 1, nSize, fp);
VSIFCloseL(fp);
VSIFree(pabyBuffer);
}
VSIFree(pszFilename);
return TRUE;
}
示例3: CPLFree
void GTMTrackLayer::WriteFeatureAttributes( OGRFeature *poFeature )
{
char* psztrackname = nullptr;
int type = 1;
unsigned int color = 0;
for (int i = 0; i < poFeatureDefn->GetFieldCount(); ++i)
{
OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn( i );
if( poFeature->IsFieldSetAndNotNull( i ) )
{
const char* l_pszName = poFieldDefn->GetNameRef();
/* track name */
if (STARTS_WITH(l_pszName, "name"))
{
CPLFree(psztrackname);
psztrackname = CPLStrdup( poFeature->GetFieldAsString( i ) );
}
/* track type */
else if (STARTS_WITH(l_pszName, "type"))
{
type = poFeature->GetFieldAsInteger( i );
// Check if it is a valid type
if (type < 1 || type > 30)
type = 1;
}
/* track color */
else if (STARTS_WITH(l_pszName, "color"))
{
color = (unsigned int) poFeature->GetFieldAsInteger( i );
if (color > 0xFFFFFF)
color = 0xFFFFFFF;
}
}
}
if (psztrackname == nullptr)
psztrackname = CPLStrdup( "" );
const size_t trackNameLength = strlen(psztrackname);
const size_t bufferSize = 14 + trackNameLength;
void* pBuffer = CPLMalloc(bufferSize);
void* pBufferAux = pBuffer;
/* Write track string name size to buffer */
appendUShort(pBufferAux, (unsigned short) trackNameLength);
pBufferAux = (char*)pBufferAux + 2;
/* Write track name */
memcpy((char*)pBufferAux, psztrackname, trackNameLength);
pBufferAux = (char*)pBufferAux + trackNameLength;
/* Write track type */
appendUChar(pBufferAux, (unsigned char) type);
pBufferAux = (char*)pBufferAux + 1;
/* Write track color */
appendInt(pBufferAux, color);
pBufferAux = (char*)pBufferAux + 4;
/* Write track scale */
appendFloat(pBufferAux, 0);
pBufferAux = (char*)pBufferAux + 4;
/* Write track label */
appendUChar(pBufferAux, 0);
pBufferAux = (char*)pBufferAux + 1;
/* Write track layer */
appendUShort(pBufferAux, 0);
VSIFWriteL(pBuffer, bufferSize, 1, poDS->getTmpTracksFP());
poDS->incNumTracks();
CPLFree(psztrackname);
CPLFree(pBuffer);
}
示例4: RCreateCopy
GDALDataset *
RCreateCopy( const char * pszFilename,
GDALDataset *poSrcDS,
CPL_UNUSED int bStrict,
char ** papszOptions,
GDALProgressFunc pfnProgress,
void * pProgressData )
{
const int nBands = poSrcDS->GetRasterCount();
const int nXSize = poSrcDS->GetRasterXSize();
const int nYSize = poSrcDS->GetRasterYSize();
const bool bASCII = CPLFetchBool(papszOptions, "ASCII", false);
const bool bCompressed = CPLFetchBool(papszOptions, "COMPRESS", !bASCII);
// Some some rudimentary checks.
// Setup the filename to actually use. We prefix with
// /vsigzip/ if we want compressed output.
const CPLString osAdjustedFilename =
std::string(bCompressed ? "/vsigzip/" : "") + pszFilename;
// Create the file.
VSILFILE *fp = VSIFOpenL(osAdjustedFilename, "wb");
if( fp == NULL )
{
CPLError(CE_Failure, CPLE_OpenFailed,
"Unable to create file %s.",
pszFilename);
return NULL;
}
// Write header with version, etc.
if( bASCII )
{
const char *pszHeader = "RDA2\nA\n";
VSIFWriteL(pszHeader, 1, strlen(pszHeader), fp);
}
else
{
const char *pszHeader = "RDX2\nX\n";
VSIFWriteL(pszHeader, 1, strlen(pszHeader), fp);
}
RWriteInteger(fp, bASCII, 2);
RWriteInteger(fp, bASCII, 133377);
RWriteInteger(fp, bASCII, 131840);
// Establish the primary pairlist with one component object.
RWriteInteger(fp, bASCII, 1026);
RWriteInteger(fp, bASCII, 1);
// Write the object name. Eventually we should derive this
// from the filename, possible with override by a creation option.
RWriteString(fp, bASCII, "gg");
// For now we write the raster as a numeric array with attributes (526).
RWriteInteger(fp, bASCII, 526);
RWriteInteger(fp, bASCII, nXSize * nYSize * nBands);
// Write the raster data.
CPLErr eErr = CE_None;
double *padfScanline =
static_cast<double *>(CPLMalloc(nXSize * sizeof(double)));
for( int iBand = 0; iBand < nBands; iBand++ )
{
GDALRasterBand *poBand = poSrcDS->GetRasterBand(iBand + 1);
for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ )
{
eErr = poBand->RasterIO(GF_Read, 0, iLine, nXSize, 1,
padfScanline, nXSize, 1, GDT_Float64,
sizeof(double), 0, NULL);
if( bASCII )
{
for( int iValue = 0; iValue < nXSize; iValue++ )
{
char szValue[128] = { '\0' };
CPLsnprintf(szValue, sizeof(szValue), "%.16g\n",
padfScanline[iValue]);
VSIFWriteL(szValue, 1, strlen(szValue), fp);
}
}
else
{
for( int iValue = 0; iValue < nXSize; iValue++ )
CPL_MSBPTR64(padfScanline + iValue);
VSIFWriteL(padfScanline, 8, nXSize, fp);
}
if( eErr == CE_None &&
!pfnProgress((iLine + 1) / static_cast<double>(nYSize),
NULL, pProgressData) )
{
eErr = CE_Failure;
CPLError(CE_Failure, CPLE_UserInterrupt,
"User terminated CreateCopy()");
//.........这里部分代码省略.........
示例5: strncpy
//.........这里部分代码省略.........
const char* l_pszName = poFieldDefn->GetNameRef();
/* Waypoint name */
if (STARTS_WITH(l_pszName, "name"))
{
strncpy (psNameField, poFeature->GetFieldAsString( i ), 10);
CPLStrlcat (psNameField, " ", sizeof(psNameField));
}
/* Waypoint comment */
else if (STARTS_WITH(l_pszName, "comment"))
{
CPLFree(pszcomment);
pszcomment = CPLStrdup( poFeature->GetFieldAsString( i ) );
}
/* Waypoint icon */
else if (STARTS_WITH(l_pszName, "icon"))
{
icon = poFeature->GetFieldAsInteger( i );
// Check if it is a valid icon
if (icon < 1 || icon > 220)
icon = 48;
}
/* Waypoint date */
else if (EQUAL(l_pszName, "time"))
{
struct tm brokendowndate;
int year, month, day, hour, min, sec, TZFlag;
if (poFeature->GetFieldAsDateTime( i, &year, &month, &day, &hour, &min, &sec, &TZFlag))
{
brokendowndate.tm_year = year - 1900;
brokendowndate.tm_mon = month - 1;
brokendowndate.tm_mday = day;
brokendowndate.tm_hour = hour;
brokendowndate.tm_min = min;
brokendowndate.tm_sec = sec;
GIntBig unixTime = CPLYMDHMSToUnixTime(&brokendowndate);
if (TZFlag != 0)
unixTime -= (TZFlag - 100) * 15;
if (unixTime <= GTM_EPOCH || (unixTime - GTM_EPOCH) != (int)(unixTime - GTM_EPOCH))
{
CPLError(CE_Warning, CPLE_AppDefined,
"%04d/%02d/%02d %02d:%02d:%02d is not a valid datetime for GTM",
year, month, day, hour, min, sec);
}
else
{
date = (int)(unixTime - GTM_EPOCH);
}
}
}
}
}
if (pszcomment == nullptr)
pszcomment = CPLStrdup( "" );
const size_t commentLength = strlen(pszcomment);
const size_t bufferSize = 27 + commentLength;
void* pBuffer = CPLMalloc(bufferSize);
void* pBufferAux = pBuffer;
/* Write waypoint name to buffer */
memcpy((char*)pBufferAux, psNameField, 10);
/* Write waypoint string comment size to buffer */
pBufferAux = (char*)pBuffer+10;
appendUShort(pBufferAux, (unsigned short) commentLength);
/* Write waypoint string comment to buffer */
memcpy((char*)pBuffer+12, pszcomment, commentLength);
/* Write icon to buffer */
pBufferAux = (char*)pBuffer+12+commentLength;
appendUShort(pBufferAux, (unsigned short) icon);
/* Write dslp to buffer */
pBufferAux = (char*)pBufferAux + 2;
appendUChar(pBufferAux, 3);
/* Date */
pBufferAux = (char*)pBufferAux + 1;
appendInt(pBufferAux, date);
/* wrot */
pBufferAux = (char*)pBufferAux + 4;
appendUShort(pBufferAux, 0);
/* walt */
pBufferAux = (char*)pBufferAux + 2;
appendFloat(pBufferAux, altitude);
/* wlayer */
pBufferAux = (char*)pBufferAux + 4;
appendUShort(pBufferAux, 0);
VSIFWriteL(pBuffer, bufferSize, 1, poDS->getOutputFP());
poDS->incNumWaypoints();
CPLFree(pszcomment);
CPLFree(pBuffer);
}
示例6: EpsilonDatasetCreateCopy
//.........这里部分代码省略.........
/* Allocate work buffers */
/* -------------------------------------------------------------------- */
GByte* pabyBuffer = (GByte*)VSIMalloc3(nBlockXSize, nBlockYSize, nBands);
if (pabyBuffer == NULL)
{
VSIFCloseL(fp);
return NULL;
}
GByte* pabyOutBuf = (GByte*)VSIMalloc(nTargetBlockSize);
if (pabyOutBuf == NULL)
{
VSIFree(pabyBuffer);
VSIFCloseL(fp);
return NULL;
}
GByte** apapbyRawBuffer[3];
int i, j;
for(i=0;i<nBands;i++)
{
apapbyRawBuffer[i] = (GByte**) VSIMalloc(sizeof(GByte*) * nBlockYSize);
for(j=0;j<nBlockYSize;j++)
{
apapbyRawBuffer[i][j] =
pabyBuffer + (i * nBlockXSize + j) * nBlockYSize;
}
}
if (bRasterliteOutput)
{
const char* pszHeader = RASTERLITE_WAVELET_HEADER;
VSIFWriteL(pszHeader, 1, strlen(pszHeader) + 1, fp);
}
/* -------------------------------------------------------------------- */
/* Iterate over blocks */
/* -------------------------------------------------------------------- */
int nBlockXOff, nBlockYOff;
CPLErr eErr = CE_None;
for(nBlockYOff = 0;
eErr == CE_None && nBlockYOff < nYBlocks; nBlockYOff ++)
{
for(nBlockXOff = 0;
eErr == CE_None && nBlockXOff < nXBlocks; nBlockXOff ++)
{
int bMustMemset = FALSE;
int nReqXSize = nBlockXSize, nReqYSize = nBlockYSize;
if ((nBlockXOff+1) * nBlockXSize > nXSize)
{
bMustMemset = TRUE;
nReqXSize = nXSize - nBlockXOff * nBlockXSize;
}
if ((nBlockYOff+1) * nBlockYSize > nYSize)
{
bMustMemset = TRUE;
nReqYSize = nYSize - nBlockYOff * nBlockYSize;
}
if (bMustMemset)
memset(pabyBuffer, 0, nBands * nBlockXSize * nBlockYSize);
eErr = poSrcDS->RasterIO(GF_Read,
nBlockXOff * nBlockXSize,
nBlockYOff * nBlockYSize,
示例7: CPLAssert
int DDFModule::Create( const char *pszFilename )
{
CPLAssert( fpDDF == NULL );
/* -------------------------------------------------------------------- */
/* Create the file on disk. */
/* -------------------------------------------------------------------- */
fpDDF = VSIFOpenL( pszFilename, "wb+" );
if( fpDDF == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to create file %s, check path and permissions.",
pszFilename );
return FALSE;
}
bReadOnly = FALSE;
/* -------------------------------------------------------------------- */
/* Prepare all the field definition information. */
/* -------------------------------------------------------------------- */
int iField;
_recLength = 24
+ nFieldDefnCount * (_sizeFieldLength+_sizeFieldPos+_sizeFieldTag)
+ 1;
_fieldAreaStart = _recLength;
for( iField=0; iField < nFieldDefnCount; iField++ )
{
int nLength;
papoFieldDefns[iField]->GenerateDDREntry( this, NULL, &nLength );
_recLength += nLength;
}
/* -------------------------------------------------------------------- */
/* Setup 24 byte leader. */
/* -------------------------------------------------------------------- */
char achLeader[25];
snprintf( achLeader+0, sizeof(achLeader)-0, "%05d", (int) _recLength );
achLeader[5] = _interchangeLevel;
achLeader[6] = _leaderIden;
achLeader[7] = _inlineCodeExtensionIndicator;
achLeader[8] = _versionNumber;
achLeader[9] = _appIndicator;
snprintf( achLeader+10, sizeof(achLeader)-10, "%02d", (int) _fieldControlLength );
snprintf( achLeader+12, sizeof(achLeader)-12, "%05d", (int) _fieldAreaStart );
strncpy( achLeader+17, _extendedCharSet, 3 );
snprintf( achLeader+20, sizeof(achLeader)-20, "%1d", (int) _sizeFieldLength );
snprintf( achLeader+21, sizeof(achLeader)-21, "%1d", (int) _sizeFieldPos );
achLeader[22] = '0';
snprintf( achLeader+23, sizeof(achLeader)-23, "%1d", (int) _sizeFieldTag );
int bRet = VSIFWriteL( achLeader, 24, 1, fpDDF ) > 0;
/* -------------------------------------------------------------------- */
/* Write out directory entries. */
/* -------------------------------------------------------------------- */
int nOffset = 0;
for( iField=0; iField < nFieldDefnCount; iField++ )
{
char achDirEntry[255];
char szFormat[32];
int nLength;
CPLAssert(_sizeFieldLength + _sizeFieldPos + _sizeFieldTag < (int)sizeof(achDirEntry));
papoFieldDefns[iField]->GenerateDDREntry( this, NULL, &nLength );
CPLAssert( (int)strlen(papoFieldDefns[iField]->GetName()) == _sizeFieldTag );
strcpy( achDirEntry, papoFieldDefns[iField]->GetName() );
snprintf(szFormat, sizeof(szFormat), "%%0%dd", (int)_sizeFieldLength);
snprintf( achDirEntry + _sizeFieldTag, sizeof(achDirEntry) - _sizeFieldTag,
szFormat, nLength );
snprintf(szFormat, sizeof(szFormat), "%%0%dd", (int)_sizeFieldPos);
snprintf( achDirEntry + _sizeFieldTag + _sizeFieldLength,
sizeof(achDirEntry) - _sizeFieldTag - _sizeFieldLength,
szFormat, nOffset );
nOffset += nLength;
bRet &= VSIFWriteL( achDirEntry, _sizeFieldLength + _sizeFieldPos + _sizeFieldTag, 1, fpDDF ) > 0;
}
char chUT = DDF_FIELD_TERMINATOR;
bRet &= VSIFWriteL( &chUT, 1, 1, fpDDF ) > 0;
/* -------------------------------------------------------------------- */
/* Write out the field descriptions themselves. */
/* -------------------------------------------------------------------- */
for( iField = 0; iField < nFieldDefnCount; iField++ )
{
char *pachData = NULL;
int nLength = 0;
papoFieldDefns[iField]->GenerateDDREntry( this, &pachData, &nLength );
bRet &= VSIFWriteL( pachData, nLength, 1, fpDDF ) > 0;
CPLFree( pachData );
//.........这里部分代码省略.........
示例8: WriteDouble
static void WriteDouble(VSILFILE* fp, double val)
{
CPL_LSBPTR64(&val);
VSIFWriteL(&val, 8, 1, fp);
}
示例9: CPLError
//.........这里部分代码省略.........
double dfMaxX = adfGeoTransform[1] * (nXSize - 0.5) + adfGeoTransform[0];
double dfMinY = adfGeoTransform[5] * (nYSize - 0.5) + adfGeoTransform[3];
double dfMaxY = adfGeoTransform[3] + adfGeoTransform[5] / 2;
CPLErr eErr = WriteHeader( fp, nXSize, nYSize,
dfMinX, dfMaxX, dfMinY, dfMaxY, 0.0, 0.0 );
if( eErr != CE_None )
{
VSIFCloseL( fp );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Copy band data. */
/* -------------------------------------------------------------------- */
double *pfData = (double *)VSI_MALLOC2_VERBOSE( nXSize, sizeof( double ) );
if( pfData == NULL )
{
VSIFCloseL( fp );
return NULL;
}
int bSrcHasNDValue;
double dfSrcNoDataValue = poSrcBand->GetNoDataValue( &bSrcHasNDValue );
double dfMinZ = DBL_MAX;
double dfMaxZ = -DBL_MAX;
for( GInt32 iRow = nYSize - 1; iRow >= 0; iRow-- )
{
eErr = poSrcBand->RasterIO( GF_Read, 0, iRow,
nXSize, 1, pfData,
nXSize, 1, GDT_Float64, 0, 0, NULL );
if( eErr != CE_None )
{
VSIFCloseL( fp );
VSIFree( pfData );
return NULL;
}
for( int iCol=0; iCol<nXSize; iCol++ )
{
if( bSrcHasNDValue && pfData[iCol] == dfSrcNoDataValue )
{
pfData[iCol] = dfDefaultNoDataValue;
}
else
{
if( pfData[iCol] > dfMaxZ )
dfMaxZ = pfData[iCol];
if( pfData[iCol] < dfMinZ )
dfMinZ = pfData[iCol];
}
CPL_LSBPTR64( pfData+iCol );
}
if( VSIFWriteL( (void *)pfData, sizeof( double ), nXSize,
fp ) != static_cast<unsigned>(nXSize) )
{
VSIFCloseL( fp );
VSIFree( pfData );
CPLError( CE_Failure, CPLE_FileIO,
"Unable to write grid row. Disk full?\n" );
return NULL;
}
if( !pfnProgress( static_cast<double>(nYSize - iRow)/nYSize,
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 *poDS = (GDALPamDataset *)GDALOpen( pszFilename,
GA_Update );
if (poDS)
{
poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT );
}
return poDS;
}
示例10: CPLFormFilename
void GDALPamProxyDB::SaveDB()
{
/* -------------------------------------------------------------------- */
/* Open the database relating original names to proxy .aux.xml */
/* file names. */
/* -------------------------------------------------------------------- */
CPLString osDBName =
CPLFormFilename( osProxyDBDir, "gdal_pam_proxy", "dat" );
void *hLock = CPLLockFile( osDBName, 1.0 );
// proceed even if lock fails - we need CPLBreakLockFile()!
if( hLock == NULL )
{
CPLError( CE_Warning, CPLE_AppDefined,
"GDALPamProxyDB::SaveDB() - Failed to lock %s file, proceeding anyways.",
osDBName.c_str() );
}
FILE *fpDB = VSIFOpenL( osDBName, "w" );
if( fpDB == NULL )
{
if( hLock )
CPLUnlockFile( hLock );
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to save %s Pam Proxy DB.\n%s",
osDBName.c_str(),
VSIStrerror( errno ) );
return;
}
/* -------------------------------------------------------------------- */
/* Write header. */
/* -------------------------------------------------------------------- */
GByte abyHeader[100];
memset( abyHeader, ' ', sizeof(abyHeader) );
strncpy( (char *) abyHeader, "GDAL_PROXY", 10 );
sprintf( (char *) abyHeader + 10, "%9d", nUpdateCounter );
VSIFWriteL( abyHeader, 1, 100, fpDB );
/* -------------------------------------------------------------------- */
/* Write names. */
/* -------------------------------------------------------------------- */
unsigned int i;
for( i = 0; i < aosOriginalFiles.size(); i++ )
{
size_t nBytesWritten;
const char *pszProxyFile;
VSIFWriteL( aosOriginalFiles[i].c_str(), 1,
strlen(aosOriginalFiles[i].c_str())+1, fpDB );
pszProxyFile = CPLGetFilename(aosProxyFiles[i]);
nBytesWritten = VSIFWriteL( pszProxyFile, 1,
strlen(pszProxyFile)+1, fpDB );
if( nBytesWritten != strlen(pszProxyFile)+1 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to write complete %s Pam Proxy DB.\n%s",
osDBName.c_str(),
VSIStrerror( errno ) );
VSIFCloseL( fpDB );
VSIUnlink( osDBName );
return;
}
}
VSIFCloseL( fpDB );
if( hLock )
CPLUnlockFile( hLock );
}
示例11: CPL_LSBPTR64
bool LevellerDataset::write(double d)
{
CPL_LSBPTR64(&d);
return (1 == VSIFWriteL(&d, sizeof(d), 1, m_fp));
}
示例12: CPL_LSBPTR32
bool LevellerDataset::write(size_t n)
{
CPL_LSBPTR32(&n);
return (1 == VSIFWriteL(&n, sizeof(n), 1, m_fp));
}
示例13: return
bool LevellerDataset::write_byte(size_t n)
{
unsigned char uch = (unsigned char)n;
return (1 == VSIFWriteL(&uch, 1, 1, m_fp));
}
示例14: strcpy
bool LevellerDataset::write_header()
{
char szHeader[5];
strcpy(szHeader, "trrn");
szHeader[4] = 7; // TER v7 introduced w/ Lev 2.6.
if(1 != VSIFWriteL(szHeader, 5, 1, m_fp)
|| !this->write_tag("hf_w", (size_t)nRasterXSize)
|| !this->write_tag("hf_b", (size_t)nRasterYSize))
{
CPLError( CE_Failure, CPLE_FileIO, "Could not write header" );
return false;
}
m_dElevBase = 0.0;
m_dElevScale = 1.0;
if(m_pszProjection == NULL || m_pszProjection[0] == 0)
{
this->write_tag("csclass", LEV_COORDSYS_RASTER);
}
else
{
this->write_tag("coordsys_wkt", m_pszProjection);
const UNITLABEL units_elev = this->id_to_code(m_szElevUnits);
const int bHasECS =
(units_elev != UNITLABEL_PIXEL && units_elev != UNITLABEL_UNKNOWN);
this->write_tag("coordsys_haselevm", bHasECS);
OGRSpatialReference sr(m_pszProjection);
if(bHasECS)
{
if(!this->compute_elev_scaling(sr))
return false;
// Raw-to-real units scaling.
this->write_tag("coordsys_em_scale", m_dElevScale);
//elev offset, in real units.
this->write_tag("coordsys_em_base", m_dElevBase);
this->write_tag("coordsys_em_units", units_elev);
}
if(sr.IsLocal())
{
this->write_tag("csclass", LEV_COORDSYS_LOCAL);
const double dfLinear = sr.GetLinearUnits();
const int n = this->meter_measure_to_code(dfLinear);
this->write_tag("coordsys_units", n);
}
else
{
this->write_tag("csclass", LEV_COORDSYS_GEO);
}
if( m_adfTransform[2] != 0.0 || m_adfTransform[4] != 0.0)
{
CPLError( CE_Failure, CPLE_IllegalArg,
"Cannot handle rotated geotransform" );
return false;
}
// todo: GDAL gridpost spacing is based on extent / rastersize
// instead of extent / (rastersize-1) like Leveller.
// We need to look into this and adjust accordingly.
// Write north-south digital axis.
this->write_tag("coordsys_da0_style", LEV_DA_PIXEL_SIZED);
this->write_tag("coordsys_da0_fixedend", 0);
this->write_tag("coordsys_da0_v0", m_adfTransform[3]);
this->write_tag("coordsys_da0_v1", m_adfTransform[5]);
// Write east-west digital axis.
this->write_tag("coordsys_da1_style", LEV_DA_PIXEL_SIZED);
this->write_tag("coordsys_da1_fixedend", 0);
this->write_tag("coordsys_da1_v0", m_adfTransform[0]);
this->write_tag("coordsys_da1_v1", m_adfTransform[1]);
}
this->write_tag_start("hf_data",
sizeof(float) * nRasterXSize * nRasterYSize);
return true;
}
示例15: WriteInt
static void WriteInt(VSILFILE* fp, GInt32 val)
{
CPL_LSBPTR32(&val);
VSIFWriteL(&val, 4, 1, fp);
}