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

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

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

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

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

示例1: return

double KGDAL2CV::range_cast_inv(const GDALDataType& gdalType,	const int& cvDepth,	const double& value){	// uint8 -> uint8	if (gdalType == GDT_Byte && cvDepth == CV_8U){		return value;	}	// uint16 -> uint8	if (gdalType == GDT_Byte && (cvDepth == CV_16U || cvDepth == CV_16S)){		return std::floor(value / 256.f);	}	// uint32 -> uint8	if (gdalType == GDT_Byte && (cvDepth == CV_32F || cvDepth == CV_32S)){		return std::floor(value / 16777216.f);	}	// int8 -> uint16	if ((gdalType == GDT_UInt16 || gdalType == GDT_Int16) && cvDepth == CV_8U){		return (value * 256.f);	}	// int16 -> int16	if ((gdalType == GDT_UInt16 || gdalType == GDT_Int16) &&		(cvDepth == CV_16U || cvDepth == CV_16S)){		return value;	}	// float32 -> float32	// float64 -> float64	if ((gdalType == GDT_Float32 || gdalType == GDT_Float64) &&		(cvDepth == CV_32F || cvDepth == CV_64F)){		return value;	}	std::cout << GDALGetDataTypeName(gdalType) << std::endl;	std::cout << "warning: unknown range cast requested." << std::endl;	return (value);}
开发者ID:PlainSailing,项目名称:GDAL2CV,代码行数:40,


示例2: CPLCreateXMLNode

CPLXMLNode *VRTDerivedRasterBand::SerializeToXML(const char *pszVRTPath){    CPLXMLNode *psTree;    psTree = VRTSourcedRasterBand::SerializeToXML( pszVRTPath );/* -------------------------------------------------------------------- *//*      Set subclass.                                                   *//* -------------------------------------------------------------------- */    CPLCreateXMLNode(         CPLCreateXMLNode( psTree, CXT_Attribute, "subClass" ),         CXT_Text, "VRTDerivedRasterBand" );    /* ---- Encode DerivedBand-specific fields ---- */    if( pszFuncName != NULL && strlen(pszFuncName) > 0 )        CPLSetXMLValue(psTree, "PixelFunctionType", this->pszFuncName);    if( this->eSourceTransferType != GDT_Unknown)        CPLSetXMLValue(psTree, "SourceTransferType", 		       GDALGetDataTypeName(this->eSourceTransferType));    return psTree;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:22,


示例3: CPLError

GDALDataset *SAGADataset::Create( const char * pszFilename,				  int nXSize, int nYSize, int nBands,				  GDALDataType eType,				  char **papszParmList ){    if( nXSize <= 0 || nYSize <= 0 )    {        CPLError( CE_Failure, CPLE_IllegalArg,                  "Unable to create grid, both X and Y size must be "                  "non-negative./n" );        return NULL;    }        if( nBands != 1 )    {        CPLError( CE_Failure, CPLE_IllegalArg,                  "SAGA Binary Grid only supports 1 band" );        return NULL;    }    if( eType != GDT_Byte && eType != GDT_UInt16 && eType != GDT_Int16        && eType != GDT_UInt32 && eType != GDT_Int32 && eType != GDT_Float32        && eType != GDT_Float64 )    {        CPLError( CE_Failure, CPLE_AppDefined,		  "SAGA Binary Grid only supports Byte, UInt16, Int16, "		  "UInt32, Int32, Float32 and Float64 datatypes.  Unable to "		  "create with type %s./n", GDALGetDataTypeName( eType ) );        return NULL;    }    VSILFILE *fp = VSIFOpenL( pszFilename, "w+b" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file '%s' failed./n",                  pszFilename );        return NULL;    }        char abyNoData[8];    double dfNoDataVal = 0.0;    const char* pszNoDataValue = CSLFetchNameValue(papszParmList, "NODATA_VALUE");    if (pszNoDataValue)    {        dfNoDataVal = CPLAtofM(pszNoDataValue);    }    else    {      switch (eType)	/* GDT_Byte, GDT_UInt16, GDT_Int16, GDT_UInt32  */      {				/* GDT_Int32, GDT_Float32, GDT_Float64 */        case (GDT_Byte):        {            dfNoDataVal = SG_NODATA_GDT_Byte;            break;        }        case (GDT_UInt16):        {            dfNoDataVal = SG_NODATA_GDT_UInt16;            break;        }        case (GDT_Int16):        {            dfNoDataVal = SG_NODATA_GDT_Int16;            break;        }        case (GDT_UInt32):        {            dfNoDataVal = SG_NODATA_GDT_UInt32;            break;        }        case (GDT_Int32):        {            dfNoDataVal = SG_NODATA_GDT_Int32;            break;        }        default:        case (GDT_Float32):        {            dfNoDataVal = SG_NODATA_GDT_Float32;            break;        }        case (GDT_Float64):        {            dfNoDataVal = SG_NODATA_GDT_Float64;            break;        }      }    }    GDALCopyWords(&dfNoDataVal, GDT_Float64, 0,                  abyNoData, eType, 0, 1);    CPLString osHdrFilename = CPLResetExtension( pszFilename, "sgrd" );    CPLErr eErr = WriteHeader( osHdrFilename, eType,//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,


示例4: CPLError

GDALDataset *WEBPDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS,                        int bStrict, char ** papszOptions,                        GDALProgressFunc pfnProgress, void * pProgressData ){    int  nBands = poSrcDS->GetRasterCount();    int  nXSize = poSrcDS->GetRasterXSize();    int  nYSize = poSrcDS->GetRasterYSize();/* -------------------------------------------------------------------- *//*      WEBP library initialization                                     *//* -------------------------------------------------------------------- */    WebPPicture sPicture;    if (!WebPPictureInit(&sPicture))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureInit() failed");        return NULL;    }/* -------------------------------------------------------------------- *//*      Some some rudimentary checks                                    *//* -------------------------------------------------------------------- */    if( nXSize > 16383 || nYSize > 16383 )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "WEBP maximum image dimensions are 16383 x 16383.");        return NULL;    }    if( nBands != 3#if WEBP_ENCODER_ABI_VERSION >= 0x0100        && nBands != 4#endif        )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "WEBP driver doesn't support %d bands. Must be 3 (RGB) "#if WEBP_ENCODER_ABI_VERSION >= 0x0100                  "or 4 (RGBA) "#endif                  "bands.",                  nBands );        return NULL;    }    GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType();    if( eDT != GDT_Byte )    {        CPLError( (bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported,                  "WEBP driver doesn't support data type %s. "                  "Only eight bit byte bands supported.",                  GDALGetDataTypeName(                      poSrcDS->GetRasterBand(1)->GetRasterDataType()) );        if (bStrict)            return NULL;    }/* -------------------------------------------------------------------- *//*      What options has the user selected?                             *//* -------------------------------------------------------------------- */    float fQuality = 75.0f;    const char* pszQUALITY = CSLFetchNameValue(papszOptions, "QUALITY");     if( pszQUALITY != NULL )    {        fQuality = (float) CPLAtof(pszQUALITY);        if( fQuality < 0.0f || fQuality > 100.0f )        {            CPLError( CE_Failure, CPLE_IllegalArg,                      "%s=%s is not a legal value.", "QUALITY", pszQUALITY);            return NULL;        }    }    WebPPreset nPreset = WEBP_PRESET_DEFAULT;    const char* pszPRESET = CSLFetchNameValueDef(papszOptions, "PRESET", "DEFAULT");    if (EQUAL(pszPRESET, "DEFAULT"))        nPreset = WEBP_PRESET_DEFAULT;    else if (EQUAL(pszPRESET, "PICTURE"))        nPreset = WEBP_PRESET_PICTURE;    else if (EQUAL(pszPRESET, "PHOTO"))        nPreset = WEBP_PRESET_PHOTO;    else if (EQUAL(pszPRESET, "PICTURE"))        nPreset = WEBP_PRESET_PICTURE;    else if (EQUAL(pszPRESET, "DRAWING"))        nPreset = WEBP_PRESET_DRAWING;    else if (EQUAL(pszPRESET, "ICON"))        nPreset = WEBP_PRESET_ICON;    else if (EQUAL(pszPRESET, "TEXT"))        nPreset = WEBP_PRESET_TEXT;    else    {        CPLError( CE_Failure, CPLE_IllegalArg,                  "%s=%s is not a legal value.", "PRESET", pszPRESET );//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例5: CSLTokenizeStringComplex

GDALDataset *MEMDataset::Open( GDALOpenInfo * poOpenInfo ){    char    **papszOptions;/* -------------------------------------------------------------------- *//*      Do we have the special filename signature for MEM format        *//*      description strings?                                            *//* -------------------------------------------------------------------- */    if( !EQUALN(poOpenInfo->pszFilename,"MEM:::",6)         || poOpenInfo->fp != NULL )        return NULL;    papszOptions = CSLTokenizeStringComplex(poOpenInfo->pszFilename+6, ",",                                            TRUE, FALSE );/* -------------------------------------------------------------------- *//*      Verify we have all required fields                              *//* -------------------------------------------------------------------- */    if( CSLFetchNameValue( papszOptions, "PIXELS" ) == NULL        || CSLFetchNameValue( papszOptions, "LINES" ) == NULL        || CSLFetchNameValue( papszOptions, "DATAPOINTER" ) == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,               "Missing required field (one of PIXELS, LINES or DATAPOINTER)/n"              "Unable to access in-memory array." );        CSLDestroy( papszOptions );        return NULL;    }/* -------------------------------------------------------------------- *//*      Create the new MEMDataset object.                               *//* -------------------------------------------------------------------- */    MEMDataset *poDS;    poDS = new MEMDataset();    poDS->nRasterXSize = atoi(CSLFetchNameValue(papszOptions,"PIXELS"));    poDS->nRasterYSize = atoi(CSLFetchNameValue(papszOptions,"LINES"));    poDS->eAccess = GA_Update;/* -------------------------------------------------------------------- *//*      Extract other information.                                      *//* -------------------------------------------------------------------- */    const char *pszOption;    GDALDataType eType;    int nBands, nPixelOffset, nLineOffset;    size_t nBandOffset;    const char *pszDataPointer;    GByte *pabyData;    pszOption = CSLFetchNameValue(papszOptions,"BANDS");    if( pszOption == NULL )        nBands = 1;    else    {        nBands = atoi(pszOption);    }    if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize) ||        !GDALCheckBandCount(nBands, TRUE))    {        CSLDestroy( papszOptions );        delete poDS;        return NULL;    }    pszOption = CSLFetchNameValue(papszOptions,"DATATYPE");    if( pszOption == NULL )        eType = GDT_Byte;    else    {        if( atoi(pszOption) > 0 && atoi(pszOption) < GDT_TypeCount )            eType = (GDALDataType) atoi(pszOption);        else        {            int iType;                        eType = GDT_Unknown;            for( iType = 0; iType < GDT_TypeCount; iType++ )            {                if( EQUAL(GDALGetDataTypeName((GDALDataType) iType),                          pszOption) )                {                    eType = (GDALDataType) iType;                    break;                }            }                        if( eType == GDT_Unknown )            {                CPLError( CE_Failure, CPLE_AppDefined,                          "DATATYPE=%s not recognised.",                           pszOption );                CSLDestroy( papszOptions );                delete poDS;                return NULL;            }        }//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,


示例6: main

int main( int argc, char ** argv ){    GDALDatasetH	hDataset, hOutDS;    int			i;    const char		*pszSource=NULL, *pszDest=NULL, *pszFormat = "GTiff";    GDALDriverH		hDriver;    GDALDataType	eOutputType = GDT_Unknown;    char                **papszCreateOptions = NULL;    GDALProgressFunc    pfnProgress = GDALTermProgress;    int                 nLUTBins = 256;    const char         *pszMethod = "minmax";//    double              dfStdDevMult = 0.0;    double             *padfScaleMin = NULL;    double             *padfScaleMax = NULL;    int               **papanLUTs = NULL;    int                 iBand;    const char         *pszConfigFile = NULL;    /* Check strict compilation and runtime library version as we use C++ API */    if (! GDAL_CHECK_VERSION(argv[0]))        exit(1);/* -------------------------------------------------------------------- *//*      Register standard GDAL drivers, and process generic GDAL        *//*      command options.                                                *//* -------------------------------------------------------------------- */    GDALAllRegister();    argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );    if( argc < 1 )        exit( -argc );/* -------------------------------------------------------------------- *//*      Handle command line arguments.                                  *//* -------------------------------------------------------------------- */    for( i = 1; i < argc; i++ )    {        if( EQUAL(argv[i], "--utility_version") )        {            printf("%s was compiled against GDAL %s and is running against GDAL %s/n",                   argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));            return 0;        }        else if( EQUAL(argv[i],"-of") && i < argc-1 )            pszFormat = argv[++i];        else if( EQUAL(argv[i],"-ot") && i < argc-1 )        {            int	iType;                        for( iType = 1; iType < GDT_TypeCount; iType++ )            {                if( GDALGetDataTypeName((GDALDataType)iType) != NULL                    && EQUAL(GDALGetDataTypeName((GDALDataType)iType),                             argv[i+1]) )                {                    eOutputType = (GDALDataType) iType;                }            }            if( eOutputType == GDT_Unknown )            {                printf( "Unknown output pixel type: %s/n", argv[i+1] );                Usage();                GDALDestroyDriverManager();                exit( 2 );            }            i++;        }        else if( EQUALN(argv[i],"-s_nodata",9) )        {            // TODO            i += 1;        }           else if( EQUAL(argv[i],"-co") && i < argc-1 )        {            papszCreateOptions = CSLAddString( papszCreateOptions, argv[++i] );        }           else if( EQUALN(argv[i],"-src_scale",10) && i < argc-2)        {            // TODO            i += 2;        }        else if( EQUALN(argv[i],"-dst_scale",10) && i < argc-2 )        {            // TODO            i += 2;        }        else if( EQUAL(argv[i],"-config") && i < argc-1 )        {            pszConfigFile = argv[++i];        }        else if( EQUAL(argv[i],"-equalize") )        {            pszMethod = "equalize";//.........这里部分代码省略.........
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:101,


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


示例8: CPLError

GDALDataset *GTXDataset::Create( const char * pszFilename,                                 int nXSize,                                 int nYSize,                                 int /* nBands */,                                 GDALDataType eType,                                 char ** /* papszOptions */ ){    if( eType != GDT_Float32 )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Attempt to create gtx file with unsupported data type '%s'.",                  GDALGetDataTypeName( eType ) );        return NULL;    }    if( !EQUAL(CPLGetExtension(pszFilename),"gtx") )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Attempt to create gtx file with extension other than gtx." );        return NULL;    }/* -------------------------------------------------------------------- *//*      Try to create the file.                                         *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( pszFilename, "wb" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file `%s' failed./n",                  pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Write out the header with stub georeferencing.                  *//* -------------------------------------------------------------------- */    unsigned char header[40] = { '/0' };    double dfYOrigin = 0.0;    memcpy( header + 0, &dfYOrigin, 8 );    CPL_MSBPTR64( header + 0 );    double dfXOrigin = 0.0;    memcpy( header + 8, &dfXOrigin, 8 );    CPL_MSBPTR64( header + 8 );    double dfYSize = 0.01;    memcpy( header + 16, &dfYSize, 8 );    CPL_MSBPTR64( header + 16 );    double dfXSize = 0.01;    memcpy( header + 24, &dfXSize, 8 );    CPL_MSBPTR64( header + 24 );    GInt32 nYSize32 = nYSize;    memcpy( header + 32, &nYSize32, 4 );    CPL_MSBPTR32( header + 32 );    GInt32 nXSize32 = nXSize;    memcpy( header + 36, &nXSize32, 4 );    CPL_MSBPTR32( header + 36 );    CPL_IGNORE_RET_VAL(VSIFWriteL( header, 40, 1, fp ));    CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));    return reinterpret_cast<GDALDataset *>(        GDALOpen( pszFilename, GA_Update ) );}
开发者ID:ryandavid,项目名称:rotobox,代码行数:69,


示例9: BSBCreateCopy

static GDALDataset *BSBCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,                int bStrict, char ** papszOptions,                GDALProgressFunc pfnProgress, void * pProgressData ){    int  nBands = poSrcDS->GetRasterCount();    int  nXSize = poSrcDS->GetRasterXSize();    int  nYSize = poSrcDS->GetRasterYSize();/* -------------------------------------------------------------------- *//*      Some some rudimentary checks                                    *//* -------------------------------------------------------------------- */    if( nBands != 1 )    {        CPLError( CE_Failure, CPLE_NotSupported,                   "BSB driver only supports one band images./n" );        return NULL;    }    if( poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte         && bStrict )    {        CPLError( CE_Failure, CPLE_NotSupported,                   "BSB driver doesn't support data type %s. "                  "Only eight bit bands supported./n",                   GDALGetDataTypeName(                       poSrcDS->GetRasterBand(1)->GetRasterDataType()) );        return NULL;    }/* -------------------------------------------------------------------- *//*      Open the output file.                                           *//* -------------------------------------------------------------------- */    BSBInfo *psBSB;    psBSB = BSBCreate( pszFilename, 0, 200, nXSize, nYSize );    if( psBSB == NULL )        return NULL;/* -------------------------------------------------------------------- *//*      Prepare initial color table.colortable.                         *//* -------------------------------------------------------------------- */    GDALRasterBand	*poBand = poSrcDS->GetRasterBand(1);    int			iColor;    unsigned char       abyPCT[771];    int                 nPCTSize;    int                 anRemap[256];    abyPCT[0] = 0;    abyPCT[1] = 0;    abyPCT[2] = 0;    if( poBand->GetColorTable() == NULL )    {        /* map greyscale down to 63 grey levels. */        for( iColor = 0; iColor < 256; iColor++ )        {            int nOutValue = (int) (iColor / 4.1) + 1;            anRemap[iColor] = nOutValue;            abyPCT[nOutValue*3 + 0] = (unsigned char) iColor;            abyPCT[nOutValue*3 + 1] = (unsigned char) iColor;            abyPCT[nOutValue*3 + 2] = (unsigned char) iColor;        }        nPCTSize = 64;    }    else    {        GDALColorTable	*poCT = poBand->GetColorTable();        int nColorTableSize = poCT->GetColorEntryCount();        if (nColorTableSize > 255)            nColorTableSize = 255;        for( iColor = 0; iColor < nColorTableSize; iColor++ )        {            GDALColorEntry	sEntry;            poCT->GetColorEntryAsRGB( iColor, &sEntry );            anRemap[iColor] = iColor + 1;            abyPCT[(iColor+1)*3 + 0] = (unsigned char) sEntry.c1;            abyPCT[(iColor+1)*3 + 1] = (unsigned char) sEntry.c2;            abyPCT[(iColor+1)*3 + 2] = (unsigned char) sEntry.c3;        }        nPCTSize = nColorTableSize + 1;        // Add entries for pixel values which apparently will not occur.        for( iColor = nPCTSize; iColor < 256; iColor++ )            anRemap[iColor] = 1;    }/* -------------------------------------------------------------------- *//*      Boil out all duplicate entries.                                 *//* -------------------------------------------------------------------- */    int  i;//.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,


示例10: TerragenDataset

GDALDataset* TerragenDataset::Create(	const char* pszFilename,    int nXSize, int nYSize, int nBands,    GDALDataType eType, char** papszOptions ){    TerragenDataset* poDS = new TerragenDataset();    poDS->eAccess = GA_Update;		poDS->m_pszFilename = CPLStrdup(pszFilename);	// -------------------------------------------------------------------- 	//      Verify input options.                                           	// --------------------------------------------------------------------     const char* pszValue = CSLFetchNameValue( 		papszOptions,"MINUSERPIXELVALUE");    if( pszValue != NULL )        poDS->m_dLogSpan[0] = atof( pszValue );    pszValue = CSLFetchNameValue( 		papszOptions,"MAXUSERPIXELVALUE");    if( pszValue != NULL )        poDS->m_dLogSpan[1] = atof( pszValue );	if( poDS->m_dLogSpan[1] <= poDS->m_dLogSpan[0] )	{        CPLError( CE_Failure, CPLE_AppDefined,              "Inverted, flat, or unspecified span for Terragen file." );		delete poDS;        return NULL;	}    if( eType != GDT_Float32 )    {        CPLError( CE_Failure, CPLE_AppDefined,              "Attempt to create Terragen dataset with a non-float32/n"              "data type (%s)./n",              GDALGetDataTypeName(eType) );		delete poDS;        return NULL;    }    if( nBands != 1 )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "Terragen driver doesn't support %d bands. Must be 1./n",                  nBands );		delete poDS;        return NULL;    }// -------------------------------------------------------------------- //      Try to create the file.                                         // --------------------------------------------------------------------         poDS->m_fp = VSIFOpenL( pszFilename, "wb+" );    if( poDS->m_fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file `%s' failed./n",                  pszFilename );		delete poDS;        return NULL;    }    poDS->nRasterXSize = nXSize;    poDS->nRasterYSize = nYSize;    // Don't bother writing the header here; the first 	// call to IWriteBlock will do that instead, since 	// the elevation data's location depends on the	// header size.// -------------------------------------------------------------------- //      Instance a band.                                                // --------------------------------------------------------------------     poDS->SetBand( 1, new TerragenRasterBand( poDS ) );	     //VSIFClose( poDS->m_fp );    //return (GDALDataset *) GDALOpen( pszFilename, GA_Update );    return (GDALDataset *) poDS;}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:96,


示例11: main

int main( int argc, char ** argv ){    GDALDriverH     hDriver;    const char      *pszSource=NULL, *pszDest=NULL, *pszFormat = "GTiff";    int             bFormatExplicitelySet = FALSE;    char            **papszLayers = NULL;    const char      *pszBurnAttribute = NULL;    double          dfIncreaseBurnValue = 0.0;    double          dfMultiplyBurnValue = 1.0;    const char      *pszWHERE = NULL, *pszSQL = NULL;    GDALDataType    eOutputType = GDT_Float64;    char            **papszCreateOptions = NULL;    GUInt32         nXSize = 0, nYSize = 0;    double          dfXMin = 0.0, dfXMax = 0.0, dfYMin = 0.0, dfYMax = 0.0;    int             bIsXExtentSet = FALSE, bIsYExtentSet = FALSE;    GDALGridAlgorithm eAlgorithm = GGA_InverseDistanceToAPower;    void            *pOptions = NULL;    char            *pszOutputSRS = NULL;    int             bQuiet = FALSE;    GDALProgressFunc pfnProgress = GDALTermProgress;    int             i;    OGRGeometry     *poSpatialFilter = NULL;    int             bClipSrc = FALSE;    OGRGeometry     *poClipSrc = NULL;    const char      *pszClipSrcDS = NULL;    const char      *pszClipSrcSQL = NULL;    const char      *pszClipSrcLayer = NULL;    const char      *pszClipSrcWhere = NULL;    /* Check strict compilation and runtime library version as we use C++ API */    if (! GDAL_CHECK_VERSION(argv[0]))        exit(1);    GDALAllRegister();    OGRRegisterAll();    argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );    if( argc < 1 )        exit( -argc );/* -------------------------------------------------------------------- *//*      Parse arguments.                                                *//* -------------------------------------------------------------------- */    for( i = 1; i < argc; i++ )    {        if( EQUAL(argv[i], "--utility_version") )        {            printf("%s was compiled against GDAL %s and is running against GDAL %s/n",                   argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));            return 0;        }        else if( EQUAL(argv[i],"--help") )            Usage();        else if( EQUAL(argv[i],"-of") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);            pszFormat = argv[++i];            bFormatExplicitelySet = TRUE;        }        else if( EQUAL(argv[i],"-q") || EQUAL(argv[i],"-quiet") )        {            bQuiet = TRUE;            pfnProgress = GDALDummyProgress;        }        else if( EQUAL(argv[i],"-ot") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);            int	iType;                        for( iType = 1; iType < GDT_TypeCount; iType++ )            {                if( GDALGetDataTypeName((GDALDataType)iType) != NULL                    && EQUAL(GDALGetDataTypeName((GDALDataType)iType),                             argv[i+1]) )                {                    eOutputType = (GDALDataType) iType;                }            }            if( eOutputType == GDT_Unknown )            {                Usage(CPLSPrintf("Unknown output pixel type: %s.",                                 argv[i + 1] ));            }            i++;        }        else if( EQUAL(argv[i],"-txe") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(2);            dfXMin = atof(argv[++i]);            dfXMax = atof(argv[++i]);            bIsXExtentSet = TRUE;        }           else if( EQUAL(argv[i],"-tye") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(2);//.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,


示例12: ProcessLayer

static CPLErr ProcessLayer( OGRLayerH hSrcLayer, GDALDatasetH hDstDS,                          OGRGeometry *poClipSrc,                          GUInt32 nXSize, GUInt32 nYSize, int nBand,                          int& bIsXExtentSet, int& bIsYExtentSet,                          double& dfXMin, double& dfXMax,                          double& dfYMin, double& dfYMax,                          const char *pszBurnAttribute,                          const double dfIncreaseBurnValue,                          const double dfMultiplyBurnValue,                          GDALDataType eType,                          GDALGridAlgorithm eAlgorithm, void *pOptions,                          int bQuiet, GDALProgressFunc pfnProgress ){/* -------------------------------------------------------------------- *//*      Get field index, and check.                                     *//* -------------------------------------------------------------------- */    int iBurnField = -1;    if ( pszBurnAttribute )    {        iBurnField = OGR_FD_GetFieldIndex( OGR_L_GetLayerDefn( hSrcLayer ),                                           pszBurnAttribute );        if( iBurnField == -1 )        {            printf( "Failed to find field %s on layer %s, skipping./n",                    pszBurnAttribute,                     OGR_FD_GetName( OGR_L_GetLayerDefn( hSrcLayer ) ) );            return CE_Failure;        }    }/* -------------------------------------------------------------------- *//*      Collect the geometries from this layer, and build list of       *//*      values to be interpolated.                                      *//* -------------------------------------------------------------------- */    OGRFeature *poFeat;    std::vector<double> adfX, adfY, adfZ;    OGR_L_ResetReading( hSrcLayer );    while( (poFeat = (OGRFeature *)OGR_L_GetNextFeature( hSrcLayer )) != NULL )    {        OGRGeometry *poGeom = poFeat->GetGeometryRef();        double  dfBurnValue = 0.0;        if ( iBurnField >= 0 )            dfBurnValue = poFeat->GetFieldAsDouble( iBurnField );        ProcessCommonGeometry(poGeom, poClipSrc, iBurnField, dfBurnValue,            dfIncreaseBurnValue, dfMultiplyBurnValue, adfX, adfY, adfZ);        OGRFeature::DestroyFeature( poFeat );    }    if ( adfX.size() == 0 )    {        printf( "No point geometry found on layer %s, skipping./n",                OGR_FD_GetName( OGR_L_GetLayerDefn( hSrcLayer ) ) );        return CE_None;    }/* -------------------------------------------------------------------- *//*      Compute grid geometry.                                          *//* -------------------------------------------------------------------- */    if ( !bIsXExtentSet || !bIsYExtentSet )    {        OGREnvelope sEnvelope;        OGR_L_GetExtent( hSrcLayer, &sEnvelope, TRUE );        if ( !bIsXExtentSet )        {            dfXMin = sEnvelope.MinX;            dfXMax = sEnvelope.MaxX;            bIsXExtentSet = TRUE;        }        if ( !bIsYExtentSet )        {            dfYMin = sEnvelope.MinY;            dfYMax = sEnvelope.MaxY;            bIsYExtentSet = TRUE;        }    }/* -------------------------------------------------------------------- *//*      Perform gridding.                                               *//* -------------------------------------------------------------------- */    const double    dfDeltaX = ( dfXMax - dfXMin ) / nXSize;    const double    dfDeltaY = ( dfYMax - dfYMin ) / nYSize;    if ( !bQuiet )    {        printf( "Grid data type is /"%s/"/n", GDALGetDataTypeName(eType) );        printf( "Grid size = (%lu %lu)./n",                (unsigned long)nXSize, (unsigned long)nYSize );        printf( "Corner coordinates = (%f %f)-(%f %f)./n",                dfXMin - dfDeltaX / 2, dfYMax + dfDeltaY / 2,                dfXMax + dfDeltaX / 2, dfYMin - dfDeltaY / 2 );//.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,


示例13: getTileSize

bool OsmAnd::HeightmapTileProvider_P::obtainData(    const TileId tileId,    const ZoomLevel zoom,    std::shared_ptr<MapTiledData>& outTiledData,    const IQueryController* const queryController){    // Obtain raw data from DB    QByteArray data;    bool ok = _tileDb.obtainTileData(tileId, zoom, data);    if (!ok || data.length() == 0)    {        // There was no data at all, to avoid further requests, mark this tile as empty        outTiledData.reset();        return true;    }    // We have the data, use GDAL to decode this GeoTIFF    const auto tileSize = getTileSize();    bool success = false;    QString vmemFilename;    vmemFilename.sprintf("/vsimem/[email
C++ GDALGetDataTypeSize函数代码示例
C++ GDALDestroyDriverManager函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。