您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GDALGetDataTypeSize函数代码示例

51自学网 2021-06-01 20:49:45
  C++
这篇教程C++ GDALGetDataTypeSize函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GDALGetDataTypeSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GDALGetDataTypeSize函数的具体用法?C++ GDALGetDataTypeSize怎么用?C++ GDALGetDataTypeSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GDALGetDataTypeSize函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例19: GDALGetDataTypeSize

/***************************************************** * /brief Read a natural block of raster band data *****************************************************/CPLErr PostGISRasterRasterBand::IReadBlock(int nBlockXOff,        int nBlockYOff, void * pImage){    PGresult * poResult = NULL;    CPLString osCommand;    int nXOff = 0;    int nYOff = 0;    int nNaturalBlockXSize = 0;    int nNaturalBlockYSize = 0;    double adfProjWin[8];    PostGISRasterDataset * poRDS = (PostGISRasterDataset *)poDS;    int nPixelSize = GDALGetDataTypeSize(eDataType) / 8;    // Construct a polygon to intersect with    GetBlockSize(&nNaturalBlockXSize, &nNaturalBlockYSize);    nXOff = nBlockXOff * nNaturalBlockXSize;    nYOff = nBlockYOff * nNaturalBlockYSize;    poRDS->PolygonFromCoords(nXOff, nYOff, nXOff + nNaturalBlockXSize, nYOff + nNaturalBlockYSize, adfProjWin);    // Raise the query    if (poRDS->pszWhere == NULL) {        osCommand.Printf("SELECT st_band(%s, %d) FROM %s.%s "            "WHERE st_intersects(%s, ST_PolygonFromText"            "('POLYGON((%.17f %.17f, %.17f %.17f, %.17f %.17f, %.17f "            "%.17f, %.17f %.17f))', %d))", pszColumn, nBand, pszSchema,            pszTable, pszColumn, adfProjWin[0], adfProjWin[1],            adfProjWin[2], adfProjWin[3],  adfProjWin[4], adfProjWin[5],            adfProjWin[6], adfProjWin[7], adfProjWin[0], adfProjWin[1],            poRDS->nSrid);    }    else {        osCommand.Printf("SELECT st_band(%s, %d) FROM %s.%s WHERE (%s) "            "AND st_intersects(%s, ST_PolygonFromText"            "('POLYGON((%.17f %.17f, %.17f %.17f, %.17f %.17f, %.17f "            "%.17f, %.17f %.17f))', %d))", pszColumn, nBand, pszSchema,            pszTable, poRDS->pszWhere, pszColumn, adfProjWin[0],            adfProjWin[1], adfProjWin[2], adfProjWin[3], adfProjWin[4],            adfProjWin[5], adfProjWin[6], adfProjWin[7], adfProjWin[0],            adfProjWin[1], poRDS->nSrid);    }#ifdef DEBUG_QUERY    CPLDebug("PostGIS_Raster",        "PostGISRasterRasterBand::IReadBlock(): Query = %s",            osCommand.c_str());#endif    poResult = PQexec(poRDS->poConn, osCommand.c_str());    if (poResult == NULL ||        PQresultStatus(poResult) != PGRES_TUPLES_OK ||        PQntuples(poResult) < 0) {        if (poResult)            PQclear(poResult);        ReportError(CE_Failure, CPLE_AppDefined,            "Error retrieving raster data FROM database");        CPLDebug("PostGIS_Raster",            "PostGISRasterRasterBand::IRasterIO(): %s",                PQerrorMessage(poRDS->poConn));        return CE_Failure;    }    /**     * No data. Return the buffer filled with nodata values     **/    else if (PQntuples(poResult) == 0) {        PQclear(poResult);        CPLDebug("PostGIS_Raster",            "PostGISRasterRasterBand::IRasterIO(): Null block");        NullBlock(pImage);        return CE_None;    }    /**     * Ok, we get the data. Only data size, without payload     *     * TODO: Check byte order     **/    int nExpectedDataSize = nNaturalBlockXSize * nNaturalBlockYSize *        nPixelSize;    int nWKBLength = 0;    GByte * pbyData = CPLHexToBinary(PQgetvalue(poResult, 0, 0),        &nWKBLength);//.........这里部分代码省略.........
开发者ID:jorgeas80,项目名称:postgis_raster,代码行数:101,


示例20: switch

CPLErr GDALNoDataValuesMaskBand::IReadBlock( int nXBlockOff, int nYBlockOff,                                         void * pImage ){    int iBand;    GDALDataType eWrkDT;  /* -------------------------------------------------------------------- *//*      Decide on a working type.                                       *//* -------------------------------------------------------------------- */    switch( poDS->GetRasterBand(1)->GetRasterDataType() )     {      case GDT_Byte:        eWrkDT = GDT_Byte;        break;      case GDT_UInt16:      case GDT_UInt32:        eWrkDT = GDT_UInt32;        break;      case GDT_Int16:      case GDT_Int32:      case GDT_CInt16:      case GDT_CInt32:        eWrkDT = GDT_Int32;        break;      case GDT_Float32:      case GDT_CFloat32:        eWrkDT = GDT_Float32;        break;          case GDT_Float64:      case GDT_CFloat64:        eWrkDT = GDT_Float64;        break;          default:        CPLAssert( FALSE );        eWrkDT = GDT_Float64;        break;    }/* -------------------------------------------------------------------- *//*      Read the image data.                                            *//* -------------------------------------------------------------------- */    GByte *pabySrc;    CPLErr eErr;    int nBands = poDS->GetRasterCount();    pabySrc = (GByte *) VSIMalloc3( nBands * GDALGetDataTypeSize(eWrkDT)/8, nBlockXSize, nBlockYSize );    if (pabySrc == NULL)    {        CPLError( CE_Failure, CPLE_OutOfMemory,                  "GDALNoDataValuesMaskBand::IReadBlock: Out of memory for buffer." );        return CE_Failure;    }    int nXSizeRequest = nBlockXSize;    if (nXBlockOff * nBlockXSize + nBlockXSize > nRasterXSize)        nXSizeRequest = nRasterXSize - nXBlockOff * nBlockXSize;    int nYSizeRequest = nBlockYSize;    if (nYBlockOff * nBlockYSize + nBlockYSize > nRasterYSize)        nYSizeRequest = nRasterYSize - nYBlockOff * nBlockYSize;    if (nXSizeRequest != nBlockXSize || nYSizeRequest != nBlockYSize)    {        /* memset the whole buffer to avoid Valgrind warnings in case we can't */        /* fetch a full block */        memset(pabySrc, 0, nBands * GDALGetDataTypeSize(eWrkDT)/8 * nBlockXSize * nBlockYSize );    }    int nBlockOffsetPixels = nBlockXSize * nBlockYSize;    int nBandOffsetByte = (GDALGetDataTypeSize(eWrkDT)/8) * nBlockXSize * nBlockYSize;    for(iBand=0;iBand<nBands;iBand++)    {        eErr = poDS->GetRasterBand(iBand + 1)->RasterIO(                                   GF_Read,                                   nXBlockOff * nBlockXSize, nYBlockOff * nBlockYSize,                                   nXSizeRequest, nYSizeRequest,                                   pabySrc + iBand * nBandOffsetByte, nXSizeRequest, nYSizeRequest,                                   eWrkDT, 0, nBlockXSize * (GDALGetDataTypeSize(eWrkDT)/8),                                   NULL);        if( eErr != CE_None )            return eErr;    }/* -------------------------------------------------------------------- *//*      Process different cases.                                        *//* -------------------------------------------------------------------- */    int i;    switch( eWrkDT )    {      case GDT_Byte:      {          GByte* pabyNoData = (GByte*) CPLMalloc(nBands * sizeof(GByte));          for(iBand=0;iBand<nBands;iBand++)          {              pabyNoData[iBand] = (GByte)padfNodataValues[iBand];//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,


示例21: CPLError

//.........这里部分代码省略.........    {        VSIFWriteL("bin/0", 4, 1, fp);        memset(szBlockName, 0, 16 + 1);        strcpy(szBlockName, "georef-utm");        VSIFWriteL(szBlockName, 16, 1, fp);        WriteInt(fp, 2);        WriteShort(fp, (GInt16) ((bNorth) ? nUTMZone : -nUTMZone));    }    if (nDatumCode != -2)    {        VSIFWriteL("bin/0", 4, 1, fp);        memset(szBlockName, 0, 16 + 1);        strcpy(szBlockName, "georef-datum");        VSIFWriteL(szBlockName, 16, 1, fp);        WriteInt(fp, 2);        WriteShort(fp, (GInt16) nDatumCode);    }    if (nEPSGCode != 0)    {        VSIFWriteL("bin/0", 4, 1, fp);        memset(szBlockName, 0, 16 + 1);        strcpy(szBlockName, "georef-epsg-prj");        VSIFWriteL(szBlockName, 16, 1, fp);        WriteInt(fp, 2);        WriteShort(fp, (GInt16) nEPSGCode);    }/* -------------------------------------------------------------------- *//*      Copy imagery                                                    *//* -------------------------------------------------------------------- */    int nXBlocks = (nXSize + nTileSize - 1) / nTileSize;    int nYBlocks = (nYSize + nTileSize - 1) / nTileSize;    void* pTileBuffer = (void*) VSIMalloc(nTileSize * nTileSize * (GDALGetDataTypeSize(eReqDT) / 8));    if (pTileBuffer == NULL)    {        CPLError( CE_Failure, CPLE_OutOfMemory, "Out of memory");        VSIFCloseL(fp);        return NULL;    }    int i, j, k, l;    CPLErr eErr = CE_None;    for(j=0;j<nYBlocks && eErr == CE_None;j++)    {        for(i=0;i<nXBlocks && eErr == CE_None;i++)        {            int nReqXSize = MIN(nTileSize, nXSize - i * nTileSize);            int nReqYSize = MIN(nTileSize, nYSize - j * nTileSize);            eErr = poSrcDS->GetRasterBand(1)->RasterIO(GF_Read,                                                i * nTileSize, MAX(0, nYSize - (j + 1) * nTileSize),                                                nReqXSize, nReqYSize,                                                pTileBuffer, nReqXSize, nReqYSize,                                                eReqDT, 0, 0, NULL);            if (eErr != CE_None)                break;            if (eReqDT == GDT_Int16)            {                WriteFloat(fp, 1); /* scale */                WriteFloat(fp, 0); /* offset */                for(k=0;k<nReqYSize;k++)                {                    int nLastVal = ((short*)pTileBuffer)[(nReqYSize - k - 1) * nReqXSize + 0];                    GByte nWordSize = 1;                    for(l=1;l<nReqXSize;l++)
开发者ID:MattLatt,项目名称:GDAL_2.0.x_VC,代码行数:67,


示例22: memset

CPLErr HDF5ImageRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,                                        void * pImage ){    herr_t      status;    hsize_t     count[3];    H5OFFSET_TYPE offset[3];    int         nSizeOfData;    hid_t       memspace;    hsize_t     col_dims[3];    hsize_t     rank;    HDF5ImageDataset    *poGDS = ( HDF5ImageDataset * ) poDS;    if( poGDS->eAccess == GA_Update ) {        memset( pImage, 0,            nBlockXSize * nBlockYSize *            GDALGetDataTypeSize( eDataType )/8 );        return CE_None;    }    rank=2;    if( poGDS->ndims == 3 ){        rank=3;        offset[0]   = nBand-1;        count[0]    = 1;        col_dims[0] = 1;    }    offset[poGDS->ndims - 2] = nBlockYOff*nBlockYSize;    offset[poGDS->ndims - 1] = nBlockXOff*nBlockXSize;    count[poGDS->ndims - 2]  = nBlockYSize;    count[poGDS->ndims - 1]  = nBlockXSize;    nSizeOfData = H5Tget_size( poGDS->native );    memset( pImage,0,nBlockXSize*nBlockYSize*nSizeOfData );/*  blocksize may not be a multiple of imagesize */    count[poGDS->ndims - 2]  = MIN( size_t(nBlockYSize),                                    poDS->GetRasterYSize() -                                            offset[poGDS->ndims - 2]);    count[poGDS->ndims - 1]  = MIN( size_t(nBlockXSize),                                    poDS->GetRasterXSize()-                                            offset[poGDS->ndims - 1]);/* -------------------------------------------------------------------- *//*      Select block from file space                                    *//* -------------------------------------------------------------------- */    status =  H5Sselect_hyperslab( poGDS->dataspace_id,                                   H5S_SELECT_SET,                                   offset, NULL,                                   count, NULL );/* -------------------------------------------------------------------- *//*      Create memory space to receive the data                         *//* -------------------------------------------------------------------- */    col_dims[poGDS->ndims-2]=nBlockYSize;    col_dims[poGDS->ndims-1]=nBlockXSize;    memspace = H5Screate_simple( (int) rank, col_dims, NULL );    H5OFFSET_TYPE mem_offset[3] = {0, 0, 0};    status =  H5Sselect_hyperslab(memspace,                                  H5S_SELECT_SET,                                  mem_offset, NULL,                                  count, NULL);    status = H5Dread ( poGDS->dataset_id,                       poGDS->native,                       memspace,                       poGDS->dataspace_id,                       H5P_DEFAULT,                       pImage );    H5Sclose( memspace );    if( status < 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "H5Dread() failed for block." );        return CE_Failure;    }    else        return CE_None;}
开发者ID:afarnham,项目名称:gdal,代码行数:83,


示例23: CPLDebug

//.........这里部分代码省略.........    if( poRDS->bBuildQuadTreeDynamically && !bSameWindowAsOtherBand )    {        if( !(poRDS->LoadSources(nXOff, nYOff, nXSize, nYSize, nBand)) )            return CE_Failure;    }    // Matching sources, to avoid a dumb for loop over the sources    PostGISRasterTileDataset ** papsMatchingTiles =        (PostGISRasterTileDataset **)            CPLQuadTreeSearch(poRDS->hQuadTree, &sAoi, &nFeatureCount);    // No blocks found. This is not an error (the raster may have holes)    if (nFeatureCount == 0) {        CPLFree(papsMatchingTiles);        return CE_None;    }    int i;    /**     * We need to store the max, min coords for the missing tiles in     * any place. This is as good as any other     **/    sAoi.minx = 0.0;    sAoi.miny = 0.0;    sAoi.maxx = 0.0;    sAoi.maxy = 0.0;    GIntBig nMemoryRequiredForTiles = 0;    CPLString osIDsToFetch;    int nTilesToFetch = 0;    int nBandDataTypeSize = GDALGetDataTypeSize(eDataType) / 8;    // Loop just over the intersecting sources    for(i = 0; i < nFeatureCount; i++) {        PostGISRasterTileDataset *poTile = papsMatchingTiles[i];        PostGISRasterTileRasterBand* poTileBand =            (PostGISRasterTileRasterBand *)poTile->GetRasterBand(nBand);        nMemoryRequiredForTiles += poTileBand->GetXSize() * poTileBand->GetYSize() *            nBandDataTypeSize;        // Missing tile: we'll need to query for it        if (!poTileBand->IsCached()) {            // If we have a PKID, add the tile PKID to the list            if (poTile->pszPKID != NULL)            {                if( osIDsToFetch.size() != 0 )                    osIDsToFetch += ",";                osIDsToFetch += "'";                osIDsToFetch += poTile->pszPKID;                osIDsToFetch += "'";            }            double dfTileMinX, dfTileMinY, dfTileMaxX, dfTileMaxY;            poTile->GetExtent(&dfTileMinX, &dfTileMinY,                              &dfTileMaxX, &dfTileMaxY);            /**             * We keep the general max and min values of all the missing             * tiles, to raise a query that intersect just that area.             *             * TODO: In case of just a few tiles and very separated,
开发者ID:jorgeas80,项目名称:postgis_raster,代码行数:67,


示例24: CPLError

/** * Read/write a region of image data for this band. * * Each of the sources for this derived band will be read and passed to * the derived band pixel function.  The pixel function is responsible * for applying whatever algorithm is necessary to generate this band's * pixels from the sources. * * The sources will be read using the transfer type specified for sources * using SetSourceTransferType().  If no transfer type has been set for * this derived band, the band's data type will be used as the transfer type. * * @see gdalrasterband * * @param eRWFlag Either GF_Read to read a region of data, or GT_Write to * write a region of data. * * @param nXOff The pixel offset to the top left corner of the region * of the band to be accessed.  This would be zero to start from the left side. * * @param nYOff The line offset to the top left corner of the region * of the band to be accessed.  This would be zero to start from the top. * * @param nXSize The width of the region of the band to be accessed in pixels. * * @param nYSize The height of the region of the band to be accessed in lines. * * @param pData The buffer into which the data should be read, or from which * it should be written.  This buffer must contain at least nBufXSize * * nBufYSize words of type eBufType.  It is organized in left to right, * top to bottom pixel order.  Spacing is controlled by the nPixelSpace, * and nLineSpace parameters. * * @param nBufXSize The width of the buffer image into which the desired * region is to be read, or from which it is to be written. * * @param nBufYSize The height of the buffer image into which the desired * region is to be read, or from which it is to be written. * * @param eBufType The type of the pixel values in the pData data buffer.  The * pixel values will automatically be translated to/from the GDALRasterBand * data type as needed. * * @param nPixelSpace The byte offset from the start of one pixel value in * pData to the start of the next pixel value within a scanline.  If defaulted * (0) the size of the datatype eBufType is used. * * @param nLineSpace The byte offset from the start of one scanline in * pData to the start of the next.  If defaulted the size of the datatype * eBufType * nBufXSize is used. * * @return CE_Failure if the access fails, otherwise CE_None. */CPLErr VRTDerivedRasterBand::IRasterIO(GDALRWFlag eRWFlag,				       int nXOff, int nYOff, int nXSize, 				       int nYSize, void * pData, int nBufXSize,				       int nBufYSize, GDALDataType eBufType,				       int nPixelSpace, int nLineSpace ){    GDALDerivedPixelFunc pfnPixelFunc;    void **pBuffers;    CPLErr eErr = CE_None;    int iSource, ii, typesize, sourcesize;    GDALDataType eSrcType;    if( eRWFlag == GF_Write )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "Writing through VRTSourcedRasterBand is not supported." );        return CE_Failure;    }    typesize = GDALGetDataTypeSize(eBufType) / 8;    if (GDALGetDataTypeSize(eBufType) % 8 > 0) typesize++;    eSrcType = this->eSourceTransferType;    if ((eSrcType == GDT_Unknown) || (eSrcType >= GDT_TypeCount)) {	eSrcType = eBufType;    }    sourcesize = GDALGetDataTypeSize(eSrcType) / 8;/* -------------------------------------------------------------------- *//*      Initialize the buffer to some background value. Use the         *//*      nodata value if available.                                      *//* -------------------------------------------------------------------- */    if ( nPixelSpace == typesize &&         (!bNoDataValueSet || dfNoDataValue == 0) ) {        memset( pData, 0, nBufXSize * nBufYSize * 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, //.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例25: GDALGetDataTypeSize

CPLErr RawRasterBand::IRasterIO( GDALRWFlag eRWFlag,                                 int nXOff, int nYOff, int nXSize, int nYSize,                                 void * pData, int nBufXSize, int nBufYSize,                                 GDALDataType eBufType,                                 int nPixelSpace, int nLineSpace ){    int         nBandDataSize = GDALGetDataTypeSize(eDataType) / 8;    int         nBufDataSize = GDALGetDataTypeSize( eBufType ) / 8;    int         nBytesToRW = nPixelOffset * nXSize;/* -------------------------------------------------------------------- *//* Use direct IO without caching if:                                    *//*                                                                      *//* GDAL_ONE_BIG_READ is enabled                                         *//*                                                                      *//* or                                                                   *//*                                                                      *//* the length of a scanline on disk is more than 50000 bytes, and the   *//* width of the requested chunk is less than 40% of the whole scanline  *//* and none of the requested scanlines are already in the cache.        *//* -------------------------------------------------------------------- */    if( nPixelOffset < 0 )     {        return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff,                                          nXSize, nYSize,                                          pData, nBufXSize, nBufYSize,                                          eBufType,                                          nPixelSpace, nLineSpace );    }    if ( !CSLTestBoolean( CPLGetConfigOption( "GDAL_ONE_BIG_READ", "NO") ) )    {        if ( nLineSize < 50000             || nBytesToRW > nLineSize / 5 * 2             || IsLineLoaded( nYOff, nYSize ) )        {            return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff,                                              nXSize, nYSize,                                              pData, nBufXSize, nBufYSize,                                              eBufType,                                              nPixelSpace, nLineSpace );        }    }/* ==================================================================== *//*   Read data.                                                         *//* ==================================================================== */    if ( eRWFlag == GF_Read )    {/* -------------------------------------------------------------------- *//*      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;        }/* ==================================================================== *//*   1. Simplest case when we should get contiguous block               *//*   of uninterleaved pixels.                                           *//* ==================================================================== */        if ( nXSize == GetXSize()              && nXSize == nBufXSize             && nYSize == nBufYSize             && eBufType == eDataType             && nPixelOffset == nBandDataSize             && nPixelSpace == nBufDataSize             && nLineSpace == nPixelSpace * nXSize )        {            if ( AccessBlock( nImgOffset                              + (vsi_l_offset)nYOff * nLineOffset + nXOff,                              nXSize * nYSize * nBandDataSize, pData ) != CE_None )            {                CPLError( CE_Failure, CPLE_FileIO,                          "Failed to read %d bytes at %lu.",                          nXSize * nYSize * nBandDataSize,                          (unsigned long)                          (nImgOffset + (vsi_l_offset)nYOff * nLineOffset                           + nXOff) );            }        }/* ==================================================================== *//*   2. Case when we need deinterleave and/or subsample data.           *//* ==================================================================== */        else        {            GByte   *pabyData;            double  dfSrcXInc, dfSrcYInc;            int     iLine;                        dfSrcXInc = (double)nXSize / nBufXSize;            dfSrcYInc = (double)nYSize / nBufYSize;//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例26: CPLAssert

CPLErr RawRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff,                                   void * pImage ){    CPLErr		eErr = CE_None;    CPLAssert( nBlockXOff == 0 );    if (pLineBuffer == NULL)        return CE_Failure;/* -------------------------------------------------------------------- *//*      If the data for this band is completely contiguous we don't     *//*      have to worry about pre-reading from disk.                      *//* -------------------------------------------------------------------- */    if( ABS(nPixelOffset) > GDALGetDataTypeSize(eDataType) / 8 )        eErr = AccessLine( nBlockYOff );/* -------------------------------------------------------------------- *//*	Copy data from user buffer into disk buffer.                    *//* -------------------------------------------------------------------- */    GDALCopyWords( pImage, eDataType, GDALGetDataTypeSize(eDataType)/8,                   pLineStart, eDataType, nPixelOffset,                   nBlockXSize );/* -------------------------------------------------------------------- *//*      Byte swap (if necessary) back into disk order before writing.   *//* -------------------------------------------------------------------- */    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) );    }/* -------------------------------------------------------------------- *//*      Figure out where to start reading.                              *//* -------------------------------------------------------------------- */    vsi_l_offset nWriteStart;    if( nPixelOffset >= 0 )        nWriteStart = nImgOffset + (vsi_l_offset)nBlockYOff * nLineOffset;    else    {        nWriteStart = nImgOffset + (vsi_l_offset)nBlockYOff * nLineOffset            - ABS(nPixelOffset) * (nBlockXSize-1);    }/* -------------------------------------------------------------------- *//*      Seek to correct location.                                       *//* -------------------------------------------------------------------- */    if( Seek( nWriteStart, SEEK_SET ) == -1 )     {        CPLError( CE_Failure, CPLE_FileIO,                  "Failed to seek to scanline %d @ %d to write to file./n",                  nBlockYOff, (int) (nImgOffset + nBlockYOff * nLineOffset) );                eErr = CE_Failure;    }/* -------------------------------------------------------------------- *//*      Write data buffer.                                              *//* -------------------------------------------------------------------- */    int	nBytesToWrite;    nBytesToWrite = ABS(nPixelOffset) * (nBlockXSize - 1)         + GDALGetDataTypeSize(GetRasterDataType()) / 8;    if( eErr == CE_None         && Write( pLineBuffer, 1, nBytesToWrite ) < (size_t) nBytesToWrite )    {        CPLError( CE_Failure, CPLE_FileIO,                  "Failed to write scanline %d to file./n",                  nBlockYOff );                eErr = CE_Failure;    }    /* -------------------------------------------------------------------- *//*      Byte swap (if necessary) back into machine order so the         *//*      buffer is still usable for reading purposes.                    *//* -------------------------------------------------------------------- */    if( !bNativeOrder && eDataType != GDT_Byte )    {        if( GDALDataTypeIsComplex( eDataType ) )        {            int nWordSize;            nWordSize = GDALGetDataTypeSize(eDataType)/16;            GDALSwapWords( pLineBuffer, nWordSize, nBlockXSize,                            ABS(nPixelOffset) );//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例27: GDALGetDataTypeSize

CPLErr RawRasterBand::IRasterIO( GDALRWFlag eRWFlag,                                 int nXOff, int nYOff, int nXSize, int nYSize,                                 void * pData, int nBufXSize, int nBufYSize,                                 GDALDataType eBufType,                                 int nPixelSpace, int nLineSpace ){    int         nBandDataSize = GDALGetDataTypeSize(eDataType) / 8;    int         nBufDataSize = GDALGetDataTypeSize( eBufType ) / 8;    int         nBytesToRW = nPixelOffset * nXSize;    if( !CanUseDirectIO(nXOff, nYOff, nXSize, nYSize, eBufType ) )    {        return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff,                                          nXSize, nYSize,                                          pData, nBufXSize, nBufYSize,                                          eBufType,                                          nPixelSpace, nLineSpace );    }    CPLDebug("RAW", "Using direct IO implementation");/* ==================================================================== *//*   Read data.                                                         *//* ==================================================================== */    if ( eRWFlag == GF_Read )    {/* -------------------------------------------------------------------- *//*      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;        }/* ==================================================================== *//*   1. Simplest case when we should get contiguous block               *//*   of uninterleaved pixels.                                           *//* ==================================================================== */        if ( nXSize == GetXSize()              && nXSize == nBufXSize             && nYSize == nBufYSize             && eBufType == eDataType             && nPixelOffset == nBandDataSize             && nPixelSpace == nBufDataSize             && nLineSpace == nPixelSpace * nXSize )        {            vsi_l_offset nOffset = nImgOffset                              + (vsi_l_offset)nYOff * nLineOffset + nXOff;            if ( AccessBlock( nOffset,                              nXSize * nYSize * nBandDataSize, pData ) != CE_None )            {                CPLError( CE_Failure, CPLE_FileIO,                          "Failed to read %d bytes at " CPL_FRMT_GUIB ".",                          nXSize * nYSize * nBandDataSize, nOffset);            }        }/* ==================================================================== *//*   2. Case when we need deinterleave and/or subsample data.           *//* ==================================================================== */        else        {            GByte   *pabyData;            double  dfSrcXInc, dfSrcYInc;            int     iLine;                        dfSrcXInc = (double)nXSize / nBufXSize;            dfSrcYInc = (double)nYSize / nBufYSize;            pabyData = (GByte *) CPLMalloc( nBytesToRW );            for ( iLine = 0; iLine < nBufYSize; iLine++ )            {                vsi_l_offset nOffset = nImgOffset                                  + ((vsi_l_offset)nYOff                                  + (vsi_l_offset)(iLine * dfSrcYInc)) * nLineOffset                                  + nXOff * nPixelOffset;                if ( AccessBlock( nOffset,                                  nBytesToRW, pabyData ) != CE_None )                {                    CPLError( CE_Failure, CPLE_FileIO,                              "Failed to read %d bytes at " CPL_FRMT_GUIB ".",                              nBytesToRW, nOffset );                }/* -------------------------------------------------------------------- *//*      Copy data from disk buffer to user block buffer and subsample,  *//*      if needed.                                                      *//* -------------------------------------------------------------------- */                if ( nXSize == nBufXSize && nYSize == nBufYSize )                {                    GDALCopyWords( pabyData, eDataType, nPixelOffset,                                   (GByte *)pData + (vsi_l_offset)iLine * nLineSpace,//.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,


示例28: CPLError

//.........这里部分代码省略.........    else if( EQUAL(pszDataType,"SWORD") && EQUALN(pszSampleType,"COMPLEX",7) )        eDataType = GDT_CInt16;    else if( EQUAL(pszDataType,"SWORD") )        eDataType = GDT_Int16;    else if( EQUALN(pszProduct,"ATS_TOA_1",8) )    {        /* all 16bit data, no line length provided */        eDataType = GDT_Int16;        poDS->nRasterXSize = (dsr_size - 20) / 2;    }    else if( poDS->nRasterXSize == 0 )    {        CPLError( CE_Warning, CPLE_AppDefined,                  "Envisat product format not recognised.  Assuming 8bit/n"                  "with no per-record prefix data.  Results may be useless!" );        eDataType = GDT_Byte;        poDS->nRasterXSize = dsr_size;    }    else    {        if( dsr_size >= 2 * poDS->nRasterXSize )            eDataType = GDT_UInt16;        else            eDataType = GDT_Byte;    }#ifdef CPL_LSB    bNative = FALSE;#else    bNative = TRUE;#endif    nPrefixBytes = dsr_size -        ((GDALGetDataTypeSize(eDataType) / 8) * poDS->nRasterXSize);/* -------------------------------------------------------------------- *//*      Fail out if we didn't get non-zero sizes.                       *//* -------------------------------------------------------------------- */    if( poDS->nRasterXSize < 1 || poDS->nRasterYSize < 1 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Unable to determine organization of dataset.  It would/n"                  "appear this is an Envisat dataset, but an unsupported/n"                  "data product.  Unable to utilize." );        delete poDS;        return NULL;    }    poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" );    if( poDS->fpImage == NULL )    {        delete poDS;        return NULL;    }/* -------------------------------------------------------------------- *//*      Try to collect GCPs.                                            *//* -------------------------------------------------------------------- *//* -------------------------------------------------------------------- *//*      Scan for all datasets matching the reference dataset.           *//* -------------------------------------------------------------------- */    int num_dsr2, dsr_size2, iBand = 0;    const char *pszDSName;    char szBandName[128];    bool bMiltiChannel;
开发者ID:afarnham,项目名称:gdal,代码行数:67,


示例29: CSLFetchNameValue

GDALDataset *PAuxDataset::Create( const char * pszFilename,                                  int nXSize, int nYSize, int nBands,                                  GDALDataType eType,                                  char **papszOptions ){    const char *pszInterleave = CSLFetchNameValue( papszOptions, "INTERLEAVE" );    if( pszInterleave == NULL )        pszInterleave = "BAND";/* -------------------------------------------------------------------- *//*      Verify input options.                                           *//* -------------------------------------------------------------------- */    if( eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16        && eType != GDT_Int16 )    {        CPLError( CE_Failure, CPLE_AppDefined,              "Attempt to create PCI .Aux labelled dataset with an illegal/n"              "data type (%s)./n",              GDALGetDataTypeName(eType) );        return NULL;    }/* -------------------------------------------------------------------- *//*      Sum the sizes of the band pixel types.                          *//* -------------------------------------------------------------------- */    int nPixelSizeSum = 0;    for( int iBand = 0; iBand < nBands; iBand++ )        nPixelSizeSum += (GDALGetDataTypeSize(eType)/8);/* -------------------------------------------------------------------- *//*      Try to create the file.                                         *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( pszFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file `%s' failed./n",                  pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Just write out a couple of bytes to establish the binary        *//*      file, and then close it.                                        *//* -------------------------------------------------------------------- */    CPL_IGNORE_RET_VAL(VSIFWriteL( reinterpret_cast<void *>( const_cast<char *>( "/0/0" ) ),                2, 1, fp ));    CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));/* -------------------------------------------------------------------- *//*      Create the aux filename.                                        *//* -------------------------------------------------------------------- */    char *pszAuxFilename = reinterpret_cast<char *>(        CPLMalloc( strlen( pszFilename ) + 5 ) );    strcpy( pszAuxFilename, pszFilename );;    for( int i = static_cast<int>(strlen(pszAuxFilename))-1; i > 0; i-- )    {        if( pszAuxFilename[i] == '.' )        {            pszAuxFilename[i] = '/0';            break;        }    }    strcat( pszAuxFilename, ".aux" );/* -------------------------------------------------------------------- *//*      Open the file.                                                  *//* -------------------------------------------------------------------- */    fp = VSIFOpenL( pszAuxFilename, "wt" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file `%s' failed./n",                  pszAuxFilename );        return NULL;    }    CPLFree( pszAuxFilename );/* -------------------------------------------------------------------- *//*      We need to write out the original filename but without any      *//*      path components in the AuxilaryTarget line.  Do so now.         *//* -------------------------------------------------------------------- */    int iStart = static_cast<int>(strlen(pszFilename))-1;    while( iStart > 0 && pszFilename[iStart-1] != '/'           && pszFilename[iStart-1] != '//' )        iStart--;    CPL_IGNORE_RET_VAL(VSIFPrintfL( fp, "AuxilaryTarget: %s/n", pszFilename + iStart ));/* -------------------------------------------------------------------- *//*      Write out the raw definition for the dataset as a whole.        *//* -------------------------------------------------------------------- */    CPL_IGNORE_RET_VAL(VSIFPrintfL( fp, "RawDefinition: %d %d %d/n",                nXSize, nYSize, nBands ));//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,



注:本文中的GDALGetDataTypeSize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GDALGetDriverByName函数代码示例
C++ GDALGetDataTypeName函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。