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

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

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

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

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

示例1: 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){/* -------------------------------------------------------------------- *//*      Provide default packing if needed.                              *//* -------------------------------------------------------------------- */    if( nPixelSpace == 0 )        nPixelSpace = GDALGetDataTypeSize(eBufType) / 8;    if( nLineSpace == 0 )        nLineSpace = nPixelSpace * nBufXSize;    if( nBandSpace == 0 )        nBandSpace = nLineSpace * nBufYSize;    /* -------------------------------------------------------------------- *//*      We should do a bit of validation first - perhaps add later.     *//* -------------------------------------------------------------------- */    /* -------------------------------------------------------------------- *//*      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);    memcpy( poReader->panBandMap, panBandMap, sizeof(int) * nBandCount );    poReader->nPixelSpace = nPixelSpace;    poReader->nLineSpace = nLineSpace;    poReader->nBandSpace = nBandSpace;/* -------------------------------------------------------------------- *//*      Create a new view for this request.                             *//* -------------------------------------------------------------------- */    poReader->poFileView = OpenFileView( GetDescription(), true,                                          poReader->bUsingCustomStream );    if( poReader->poFileView == NULL )    {        delete poReader;        return NULL;    }    poReader->poFileView->SetClientData( poReader );    poReader->poFileView->SetRefreshCallback( ECWAsyncReader::RefreshCB );/* -------------------------------------------------------------------- *//*      Issue a corresponding SetView command.                          *//* -------------------------------------------------------------------- */    std::vector<UINT32> anBandIndices;    int   i;    NCSError     eNCSErr;    CNCSError    oErr;        for( i = 0; i < nBandCount; i++ )        anBandIndices.push_back( panBandMap[i] - 1 );    oErr = poReader->poFileView->SetView( nBandCount, &(anBandIndices[0]),                                          nXOff, nYOff,                                           nXOff + nXSize - 1,                                           nYOff + nYSize - 1,                                          nBufXSize, nBufYSize );    eNCSErr = oErr.GetErrorNumber();        if( eNCSErr != NCS_SUCCESS )    {        delete poReader;        CPLError( CE_Failure, CPLE_AppDefined,                   "%s", NCSGetErrorText(eNCSErr) );                return NULL;    }    return poReader;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:91,


示例2: CPLFormFilename

void GDALPamProxyDB::LoadDB(){/* -------------------------------------------------------------------- *//*      Open the database relating original names to proxy .aux.xml     *//*      file names.                                                     *//* -------------------------------------------------------------------- */    CPLString osDBName =        CPLFormFilename( osProxyDBDir, "gdal_pam_proxy", "dat" );    VSILFILE *fpDB = VSIFOpenL( osDBName, "r" );    nUpdateCounter = 0;    if( fpDB == NULL )        return;/* -------------------------------------------------------------------- *//*      Read header, verify and extract update counter.                 *//* -------------------------------------------------------------------- */    const size_t nHeaderSize = 100;    GByte abyHeader[nHeaderSize] = { '/0' };    if( VSIFReadL( abyHeader, 1, nHeaderSize, fpDB ) != nHeaderSize        || !STARTS_WITH(reinterpret_cast<char *>(abyHeader), "GDAL_PROXY") )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "Problem reading %s header - short or corrupt?",                  osDBName.c_str() );        CPL_IGNORE_RET_VAL(VSIFCloseL(fpDB));        return;    }    nUpdateCounter = atoi(reinterpret_cast<char *>(abyHeader) + 10);/* -------------------------------------------------------------------- *//*      Read the file in one gulp.                                      *//* -------------------------------------------------------------------- */    if( VSIFSeekL( fpDB, 0, SEEK_END ) != 0 )    {        CPL_IGNORE_RET_VAL(VSIFCloseL(fpDB));        return;    }    const int nBufLength = static_cast<int>(VSIFTellL(fpDB) - nHeaderSize);    if( VSIFSeekL( fpDB, nHeaderSize, SEEK_SET ) != 0 )    {        CPL_IGNORE_RET_VAL(VSIFCloseL(fpDB));        return;    }    char *pszDBData = static_cast<char *>( CPLCalloc(1,nBufLength+1) );    if( VSIFReadL( pszDBData, 1, nBufLength, fpDB ) !=        static_cast<size_t>(nBufLength) )    {        CPLFree(pszDBData);        CPL_IGNORE_RET_VAL(VSIFCloseL(fpDB));        return;    }    CPL_IGNORE_RET_VAL(VSIFCloseL( fpDB ));/* -------------------------------------------------------------------- *//*      Parse the list of in/out names.                                 *//* -------------------------------------------------------------------- */    int iNext = 0;    while( iNext < nBufLength )    {        CPLString osOriginal;        osOriginal.assign( pszDBData + iNext );        for( ; iNext < nBufLength && pszDBData[iNext] != '/0'; iNext++ ) {}        if( iNext == nBufLength )            break;        iNext++;        CPLString osProxy = osProxyDBDir;        osProxy += "/";        osProxy += pszDBData + iNext;        for( ; iNext < nBufLength && pszDBData[iNext] != '/0'; iNext++ ) {}        iNext++;        aosOriginalFiles.push_back( osOriginal );        aosProxyFiles.push_back( osProxy );    }    CPLFree( pszDBData );}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:88,


示例3: VSIFSeekL

void PALSARJaxaDataset::ReadMetadata( PALSARJaxaDataset *poDS, FILE *fp ) {    /* seek to the end fo the leader file descriptor */    VSIFSeekL( fp, LEADER_FILE_DESCRIPTOR_LENGTH, SEEK_SET );    if (poDS->nFileType == level_11) {        poDS->SetMetadataItem( "PRODUCT_LEVEL", "1.1" );        poDS->SetMetadataItem( "AZIMUTH_LOOKS", "1.0" );    }    else {        poDS->SetMetadataItem( "PRODUCT_LEVEL", "1.5" );        /* extract equivalent number of looks */        VSIFSeekL( fp, LEADER_FILE_DESCRIPTOR_LENGTH +                   EFFECTIVE_LOOKS_AZIMUTH_OFFSET, SEEK_SET );        char pszENL[17];        double dfENL;        READ_CHAR_FLOAT(dfENL, 16, fp);        sprintf( pszENL, "%-16.1f", dfENL );        poDS->SetMetadataItem( "AZIMUTH_LOOKS", pszENL );        /* extract pixel spacings */        VSIFSeekL( fp, LEADER_FILE_DESCRIPTOR_LENGTH +                  DATA_SET_SUMMARY_LENGTH + PIXEL_SPACING_OFFSET, SEEK_SET );        double dfPixelSpacing;        double dfLineSpacing;        char pszPixelSpacing[33];        char pszLineSpacing[33];        READ_CHAR_FLOAT(dfPixelSpacing, 16, fp);        READ_CHAR_FLOAT(dfLineSpacing, 16, fp);        sprintf( pszPixelSpacing, "%-32.1f",dfPixelSpacing );        sprintf( pszLineSpacing, "%-32.1f", dfLineSpacing );        poDS->SetMetadataItem( "PIXEL_SPACING", pszPixelSpacing );        poDS->SetMetadataItem( "LINE_SPACING", pszPixelSpacing );        /* Alphanumeric projection name */        VSIFSeekL( fp, LEADER_FILE_DESCRIPTOR_LENGTH +                  DATA_SET_SUMMARY_LENGTH + ALPHANUMERIC_PROJECTION_NAME_OFFSET,                  SEEK_SET );        char pszProjName[33];        READ_STRING(pszProjName, 32, fp);        poDS->SetMetadataItem( "PROJECTION_NAME", pszProjName );		        /* Extract corner GCPs */        poDS->nGCPCount = 4;        poDS->pasGCPList = (GDAL_GCP *)CPLCalloc( sizeof(GDAL_GCP),                                                   poDS->nGCPCount );        GDALInitGCPs( poDS->nGCPCount, poDS->pasGCPList );        /* setup the GCPs */        int i;        for (i = 0; i < poDS->nGCPCount; i++) {            char pszID[2];            sprintf( pszID, "%d", i + 1);            CPLFree(poDS->pasGCPList[i].pszId);            poDS->pasGCPList[i].pszId = CPLStrdup( pszID );            poDS->pasGCPList[i].dfGCPZ = 0.0;        }        double dfTemp = 0.0;        /* seek to start of GCPs */        VSIFSeekL( fp, LEADER_FILE_DESCRIPTOR_LENGTH +                  DATA_SET_SUMMARY_LENGTH + TOP_LEFT_LAT_OFFSET, SEEK_SET );		        /* top-left GCP */        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[0].dfGCPY = dfTemp;        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[0].dfGCPX = dfTemp;        poDS->pasGCPList[0].dfGCPLine = 0.5;        poDS->pasGCPList[0].dfGCPPixel = 0.5;        /* top right GCP */        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[1].dfGCPY = dfTemp;        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[1].dfGCPX = dfTemp;        poDS->pasGCPList[1].dfGCPLine = 0.5;        poDS->pasGCPList[1].dfGCPPixel = poDS->nRasterYSize - 0.5;        /* bottom right GCP */        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[2].dfGCPY = dfTemp;        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[2].dfGCPX = dfTemp;        poDS->pasGCPList[2].dfGCPLine = poDS->nRasterYSize - 0.5;        poDS->pasGCPList[2].dfGCPPixel = poDS->nRasterYSize - 0.5;        /* bottom left GCP */        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[3].dfGCPY = dfTemp;        READ_CHAR_FLOAT(dfTemp, 16, fp);        poDS->pasGCPList[3].dfGCPX = dfTemp;        poDS->pasGCPList[3].dfGCPLine = poDS->nRasterYSize - 0.5;        poDS->pasGCPList[3].dfGCPPixel = 0.5;    }    /* some generic metadata items */    poDS->SetMetadataItem( "SENSOR_BAND", "L" ); /* PALSAR is L-band */    poDS->SetMetadataItem( "RANGE_LOOKS", "1.0" );    /* Check if this is a PolSAR dataset */    if ( poDS->GetRasterCount() == 4 ) {//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,


示例4: OGRMultiPolygon

OGRMultiPolygon* OGRILI1Layer::Polygonize( OGRGeometryCollection* poLines, bool fix_crossing_lines ){    if (poLines->getNumGeometries() == 0)    {        return new OGRMultiPolygon();    }#if defined(HAVE_GEOS)    GEOSGeom *ahInGeoms = NULL;    OGRGeometryCollection *poNoncrossingLines = poLines;    GEOSGeom hResultGeom = NULL;    OGRGeometry *poMP = NULL;    if (fix_crossing_lines && poLines->getNumGeometries() > 0)    {        CPLDebug( "OGR_ILI", "Fixing crossing lines");        //A union of the geometry collection with one line fixes invalid geometries        OGRGeometry* poUnion = poLines->Union(poLines->getGeometryRef(0));        if( poUnion != NULL )        {            if( wkbFlatten(poUnion->getGeometryType()) == wkbGeometryCollection ||                    wkbFlatten(poUnion->getGeometryType()) == wkbMultiLineString )            {                poNoncrossingLines = dynamic_cast<OGRGeometryCollection*>(poUnion);                CPLDebug( "OGR_ILI", "Fixed lines: %d", poNoncrossingLines->getNumGeometries()-poLines->getNumGeometries());            }            else            {                delete poUnion;            }        }    }    GEOSContextHandle_t hGEOSCtxt = OGRGeometry::createGEOSContext();    ahInGeoms = (GEOSGeom *) CPLCalloc(sizeof(void*),poNoncrossingLines->getNumGeometries());    for( int i = 0; i < poNoncrossingLines->getNumGeometries(); i++ )        ahInGeoms[i] = poNoncrossingLines->getGeometryRef(i)->exportToGEOS(hGEOSCtxt);    hResultGeom = GEOSPolygonize_r( hGEOSCtxt,                                    ahInGeoms,                                    poNoncrossingLines->getNumGeometries() );    for( int i = 0; i < poNoncrossingLines->getNumGeometries(); i++ )        GEOSGeom_destroy_r( hGEOSCtxt, ahInGeoms[i] );    CPLFree( ahInGeoms );    if (poNoncrossingLines != poLines) delete poNoncrossingLines;    if( hResultGeom == NULL )    {        OGRGeometry::freeGEOSContext( hGEOSCtxt );        return new OGRMultiPolygon();    }    poMP = OGRGeometryFactory::createFromGEOS( hGEOSCtxt, hResultGeom );    GEOSGeom_destroy_r( hGEOSCtxt, hResultGeom );    OGRGeometry::freeGEOSContext( hGEOSCtxt );    poMP = OGRGeometryFactory::forceToMultiPolygon( poMP );    if( poMP && wkbFlatten(poMP->getGeometryType()) == wkbMultiPolygon )        return dynamic_cast<OGRMultiPolygon *>(poMP);    else    {        delete poMP;        return new OGRMultiPolygon();    }#else    return new OGRMultiPolygon();#endif}
开发者ID:garnertb,项目名称:gdal,代码行数:71,


示例5: strlen

//.........这里部分代码省略.........            psProcessingInfo, "ellipsoidName", "" );        const double minor_axis = CPLAtof(CPLGetXMLValue(            psProcessingInfo, "ellipsoidSemiMinorAxis", "0.0" ));        const double major_axis = CPLAtof(CPLGetXMLValue(            psProcessingInfo, "ellipsoidSemiMajorAxis", "0.0" ));        if ( EQUAL(pszEllipsoidName, "") || ( minor_axis == 0.0 ) ||             ( major_axis == 0.0 ) )        {            CPLError(CE_Warning,CPLE_AppDefined,"Warning- incomplete"                     " ellipsoid information.  Using wgs-84 parameters./n");            oLL.SetWellKnownGeogCS( "WGS84" );            oPrj.SetWellKnownGeogCS( "WGS84" );        }        else if ( EQUAL( pszEllipsoidName, "WGS84" ) ) {            oLL.SetWellKnownGeogCS( "WGS84" );            oPrj.SetWellKnownGeogCS( "WGS84" );        }        else {            const double inv_flattening = major_axis/(major_axis - minor_axis);            oLL.SetGeogCS( "","",pszEllipsoidName, major_axis,                           inv_flattening);            oPrj.SetGeogCS( "","",pszEllipsoidName, major_axis,                            inv_flattening);        }        CPLFree( poDS->pszGCPProjection );        poDS->pszGCPProjection = nullptr;        oLL.exportToWkt( &(poDS->pszGCPProjection) );    }/* -------------------------------------------------------------------- *//*      Collect GCPs.                                                   *//* -------------------------------------------------------------------- */    CPLXMLNode *psGeoGrid =        CPLGetXMLNode( psAnnotation,                       "=product.geolocationGrid.geolocationGridPointList" );    if( psGeoGrid != nullptr ) {        /* count GCPs */        poDS->nGCPCount = 0;        for( CPLXMLNode *psNode = psGeoGrid->psChild; psNode != nullptr;             psNode = psNode->psNext )        {            if( EQUAL(psNode->pszValue,"geolocationGridPoint") )                poDS->nGCPCount++ ;        }        poDS->pasGCPList = reinterpret_cast<GDAL_GCP *>(            CPLCalloc( sizeof(GDAL_GCP), poDS->nGCPCount ) );        poDS->nGCPCount = 0;        for( CPLXMLNode *psNode = psGeoGrid->psChild; psNode != nullptr;             psNode = psNode->psNext )        {            GDAL_GCP *psGCP = poDS->pasGCPList + poDS->nGCPCount;            if( !EQUAL(psNode->pszValue,"geolocationGridPoint") )                continue;            poDS->nGCPCount++ ;            char szID[32];            snprintf( szID, sizeof(szID), "%d", poDS->nGCPCount );            psGCP->pszId = CPLStrdup( szID );            psGCP->pszInfo = CPLStrdup("");            psGCP->dfGCPPixel = CPLAtof(CPLGetXMLValue(psNode,"pixel","0"));            psGCP->dfGCPLine = CPLAtof(CPLGetXMLValue(psNode,"line","0"));            psGCP->dfGCPX = CPLAtof(CPLGetXMLValue(psNode,"longitude",""));            psGCP->dfGCPY = CPLAtof(CPLGetXMLValue(psNode,"latitude",""));            psGCP->dfGCPZ = CPLAtof(CPLGetXMLValue(psNode,"height",""));        }    }    CPLDestroyXMLNode(psAnnotation);/* -------------------------------------------------------------------- *//*      Initialize any PAM information.                                 *//* -------------------------------------------------------------------- */    const CPLString osDescription = osMDFilename;/* -------------------------------------------------------------------- *//*      Initialize any PAM information.                                 *//* -------------------------------------------------------------------- */    poDS->SetDescription( osDescription );    poDS->SetPhysicalFilename( osMDFilename );    poDS->SetSubdatasetName( osDescription );    poDS->TryLoadXML();/* -------------------------------------------------------------------- *//*      Check for overviews.                                            *//* -------------------------------------------------------------------- */    poDS->oOvManager.Initialize( poDS, ":::VIRTUAL:::" );    return poDS;}
开发者ID:tbonfort,项目名称:gdal,代码行数:101,


示例6: CPLCalloc

/** * Retrieves and stores the GCPs from a COSMO-SKYMED dataset * It only retrieves the GCPs for L0, L1A and L1B products * for L1C and L1D products, geotransform is provided. * The GCPs provided will be the Image's corners. * @param iProductType type of CSK product @see HDF5CSKProductEnum */void HDF5ImageDataset::CaptureCSKGCPs(int iProductType){    //Only retrieve GCPs for L0,L1A and L1B products    if(iProductType == PROD_CSK_L0||iProductType == PROD_CSK_L1A||       iProductType == PROD_CSK_L1B)    {        int i;        double *pdCornerCoordinates;        nGCPCount=4;        pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),4);        CPLString osCornerName[4];        double pdCornerPixel[4];        double pdCornerLine[4];        const char *pszSubdatasetName = GetSubdatasetName();        //Load the subdataset name first        for(i=0;i <4;i++)            osCornerName[i] = pszSubdatasetName;        //Load the attribute name, and raster coordinates for        //all the corners        osCornerName[0] += "/Top Left Geodetic Coordinates";        pdCornerPixel[0] = 0;        pdCornerLine[0] = 0;        osCornerName[1] += "/Top Right Geodetic Coordinates";        pdCornerPixel[1] = GetRasterXSize();        pdCornerLine[1] = 0;        osCornerName[2] += "/Bottom Left Geodetic Coordinates";        pdCornerPixel[2] = 0;        pdCornerLine[2] = GetRasterYSize();        osCornerName[3] += "/Bottom Right Geodetic Coordinates";        pdCornerPixel[3] = GetRasterXSize();        pdCornerLine[3] = GetRasterYSize();        //For all the image's corners        for(i=0;i<4;i++)        {            GDALInitGCPs( 1, pasGCPList + i );            CPLFree( pasGCPList[i].pszId );            pasGCPList[i].pszId = NULL;            //Retrieve the attributes            if(HDF5ReadDoubleAttr(osCornerName[i].c_str(),                                   &pdCornerCoordinates) == CE_Failure)            {                CPLError( CE_Failure, CPLE_OpenFailed,                             "Error retrieving CSK GCPs/n" );                // Free on failure, e.g. in case of QLK subdataset.                for( int i = 0; i < 4; i++ )                {                    if( pasGCPList[i].pszId )                        CPLFree( pasGCPList[i].pszId );                    if( pasGCPList[i].pszInfo )                        CPLFree( pasGCPList[i].pszInfo );	            }                CPLFree( pasGCPList );                pasGCPList = NULL;                nGCPCount = 0;                break;            }            //Fill the GCPs name            pasGCPList[i].pszId = CPLStrdup( osCornerName[i].c_str() );            //Fill the coordinates            pasGCPList[i].dfGCPX = pdCornerCoordinates[1];            pasGCPList[i].dfGCPY = pdCornerCoordinates[0];            pasGCPList[i].dfGCPZ = pdCornerCoordinates[2];            pasGCPList[i].dfGCPPixel = pdCornerPixel[i];            pasGCPList[i].dfGCPLine = pdCornerLine[i];            //Free the returned coordinates            CPLFree(pdCornerCoordinates);        }    }}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:89,


示例7: switch

CPLErr HDF5ImageDataset::CreateProjections(){    switch(iSubdatasetType)    {    case CSK_PRODUCT:    {        const char *osMissionLevel = NULL;        int productType = PROD_UNKNOWN;        if(GetMetadataItem("Product_Type")!=NULL)        {            //Get the format's level            osMissionLevel = HDF5Dataset::GetMetadataItem("Product_Type");            if(EQUALN(osMissionLevel,"RAW",3))                productType  = PROD_CSK_L0;            if(EQUALN(osMissionLevel,"SSC",3))                productType  = PROD_CSK_L1A;            if(EQUALN(osMissionLevel,"DGM",3))                productType  = PROD_CSK_L1B;            if(EQUALN(osMissionLevel,"GEC",3))                productType  = PROD_CSK_L1C;            if(EQUALN(osMissionLevel,"GTC",3))                productType  = PROD_CSK_L1D;        }                    CaptureCSKGeoTransform(productType);        CaptureCSKGeolocation(productType);        CaptureCSKGCPs(productType);                break;    }    case UNKNOWN_PRODUCT:    {#define NBGCPLAT 100#define NBGCPLON 30    hid_t LatitudeDatasetID  = -1;    hid_t LongitudeDatasetID = -1;    hid_t LatitudeDataspaceID;    hid_t LongitudeDataspaceID;    float* Latitude;    float* Longitude;    int    i,j;    int   nDeltaLat;    int   nDeltaLon;    nDeltaLat = nRasterYSize / NBGCPLAT;    nDeltaLon = nRasterXSize / NBGCPLON;    if( nDeltaLat == 0 || nDeltaLon == 0 )        return CE_None;    /* -------------------------------------------------------------------- */    /*      Create HDF5 Data Hierarchy in a link list                       */    /* -------------------------------------------------------------------- */    poH5Objects=HDF5FindDatasetObjects( poH5RootGroup,  "Latitude" );    if( !poH5Objects ) {        return CE_None;    }    /* -------------------------------------------------------------------- */    /*      The Lattitude and Longitude arrays must have a rank of 2 to     */    /*      retrieve GCPs.                                                  */    /* -------------------------------------------------------------------- */    if( poH5Objects->nRank != 2 ) {        return CE_None;    }    /* -------------------------------------------------------------------- */    /*      Retrieve HDF5 data information                                  */    /* -------------------------------------------------------------------- */    LatitudeDatasetID   = H5Dopen( hHDF5,poH5Objects->pszPath );    LatitudeDataspaceID = H5Dget_space( dataset_id );    poH5Objects=HDF5FindDatasetObjects( poH5RootGroup, "Longitude" );    LongitudeDatasetID   = H5Dopen( hHDF5,poH5Objects->pszPath );    LongitudeDataspaceID = H5Dget_space( dataset_id );    if( ( LatitudeDatasetID > 0 ) && ( LongitudeDatasetID > 0) ) {        Latitude         = ( float * ) CPLCalloc(  nRasterYSize*nRasterXSize,                            sizeof( float ) );        Longitude         = ( float * ) CPLCalloc( nRasterYSize*nRasterXSize,                            sizeof( float ) );        memset( Latitude, 0, nRasterXSize*nRasterYSize*sizeof(  float ) );        memset( Longitude, 0, nRasterXSize*nRasterYSize*sizeof( float ) );        H5Dread ( LatitudeDatasetID,            H5T_NATIVE_FLOAT,            H5S_ALL,            H5S_ALL,            H5P_DEFAULT,            Latitude );        H5Dread ( LongitudeDatasetID,            H5T_NATIVE_FLOAT,//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,


示例8: DIV_ROUND_UP

void E00GRIDDataset::ReadMetadata(){    if (bHasReadMetadata)        return;    bHasReadMetadata = TRUE;    if (e00ReadPtr == nullptr)    {        const int nRoundedBlockXSize =            DIV_ROUND_UP(nRasterXSize, VALS_PER_LINE) * VALS_PER_LINE;        if( static_cast<vsi_l_offset>(nRasterYSize) >                                    GUINTBIG_MAX / nRoundedBlockXSize )        {            return;        }        const vsi_l_offset nValsToSkip =                               (vsi_l_offset)nRasterYSize * nRoundedBlockXSize;        const vsi_l_offset nLinesToSkip = nValsToSkip / VALS_PER_LINE;        const int nBytesPerLine = VALS_PER_LINE * E00_FLOAT_SIZE + nBytesEOL;        const vsi_l_offset nPos = nDataStart + nLinesToSkip * nBytesPerLine;        VSIFSeekL(fp, nPos, SEEK_SET);    }    else    {        nLastYOff = -1;        const unsigned int BUFFER_SIZE = 65536;        const unsigned int NEEDLE_SIZE = 3*5;        const unsigned int nToRead = BUFFER_SIZE - NEEDLE_SIZE;        char* pabyBuffer = (char*)CPLCalloc(1, BUFFER_SIZE+NEEDLE_SIZE);        int nRead;        int bEOGFound = FALSE;        VSIFSeekL(fp, 0, SEEK_END);        vsi_l_offset nEndPos = VSIFTellL(fp);        if (nEndPos > BUFFER_SIZE)            nEndPos -= BUFFER_SIZE;        else            nEndPos = 0;        VSIFSeekL(fp, nEndPos, SEEK_SET);#define GOTO_NEXT_CHAR() /    i ++; /    if (pabyBuffer[i] == 13 || pabyBuffer[i] == 10) /    { /        i++; /        if (pabyBuffer[i] == 10) /            i++; /    } /        while ((nRead = static_cast<int>(VSIFReadL(pabyBuffer, 1, nToRead, fp))) != 0)        {            int i;            for(i = 0; i < nRead; i++)            {                if (pabyBuffer[i] == 'E')                {                    GOTO_NEXT_CHAR();                    if (pabyBuffer[i] == 'O')                    {                        GOTO_NEXT_CHAR();                        if (pabyBuffer[i] == 'G')                        {                            GOTO_NEXT_CHAR();                            if (pabyBuffer[i] == '~')                            {                                GOTO_NEXT_CHAR();                                if (pabyBuffer[i] == '}')                                {                                    bEOGFound = TRUE;                                    break;                                }                            }                        }                    }                }            }            if (bEOGFound)            {                VSIFSeekL(fp, VSIFTellL(fp) - nRead + i + 1, SEEK_SET);                e00ReadPtr->iInBufPtr = 0;                e00ReadPtr->szInBuf[0] = '/0';                break;            }            if (nEndPos == 0)                break;            if ((unsigned int)nRead == nToRead)            {                memmove(pabyBuffer + nToRead, pabyBuffer, NEEDLE_SIZE);                if (nEndPos >= (vsi_l_offset)nToRead)                    nEndPos -= nToRead;                else                    nEndPos = 0;                VSIFSeekL(fp, nEndPos, SEEK_SET);            }//.........这里部分代码省略.........
开发者ID:hdfeos,项目名称:gdal,代码行数:101,


示例9: CPLError

int GMLReader::ResolveXlinks( const char *pszFile,                              int* pbOutIsTempFile,                              char **papszSkip,                              const int bStrict){    *pbOutIsTempFile = FALSE;// Check if the original source file is set.    if( m_pszFilename == NULL )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "GML source file needs to be set first with "                  "GMLReader::SetSourceFile()." );        return FALSE;    }/* -------------------------------------------------------------------- *//*      Load the raw XML file into a XML Node tree.                     *//* -------------------------------------------------------------------- */    CPLXMLNode **papsSrcTree;    papsSrcTree = (CPLXMLNode **)CPLCalloc( 2, sizeof(CPLXMLNode *));    papsSrcTree[0] = CPLParseXMLFile( m_pszFilename );    if( papsSrcTree[0] == NULL )    {        CPLFree(papsSrcTree);        return FALSE;    }    //make all the URLs absolute    CPLXMLNode *psSibling = NULL;    for( psSibling = papsSrcTree[0]; psSibling != NULL; psSibling = psSibling->psNext )        CorrectURLs( psSibling, m_pszFilename );    //setup resource data structure    char **papszResourceHREF = NULL;    // "" is the href of the original source file    papszResourceHREF = CSLAddString( papszResourceHREF, m_pszFilename );    //call resolver    CPLErr eReturned = CE_None;    eReturned = Resolve( papsSrcTree[0], &papsSrcTree, &papszResourceHREF, papszSkip, bStrict );    int bReturn = TRUE;    if( eReturned != CE_Failure )    {        char *pszTmpName = NULL;        int bTryWithTempFile = FALSE;        if( EQUALN(pszFile, "/vsitar/", strlen("/vsitar/")) ||            EQUALN(pszFile, "/vsigzip/", strlen("/vsigzip/")) ||            EQUALN(pszFile, "/vsizip/", strlen("/vsizip/")) )        {            bTryWithTempFile = TRUE;        }        else if( !CPLSerializeXMLTreeToFile( papsSrcTree[0], pszFile ) )        {            CPLError( CE_Failure, CPLE_FileIO,                      "Cannot serialize resolved file %s to %s.",                      m_pszFilename, pszFile );            bTryWithTempFile = TRUE;        }        if (bTryWithTempFile)        {            pszTmpName = CPLStrdup( CPLGenerateTempFilename( "ResolvedGML" ) );            if( !CPLSerializeXMLTreeToFile( papsSrcTree[0], pszTmpName ) )            {                CPLError( CE_Failure, CPLE_FileIO,                          "Cannot serialize resolved file %s to %s either.",                          m_pszFilename, pszTmpName );                CPLFree( pszTmpName );                bReturn = FALSE;            }            else            {            //set the source file to the resolved file                CPLFree( m_pszFilename );                m_pszFilename = pszTmpName;                *pbOutIsTempFile = TRUE;            }        }        else        {        //set the source file to the resolved file            CPLFree( m_pszFilename );            m_pszFilename = CPLStrdup( pszFile );        }    }    else    {        bReturn = FALSE;    }    int nItems = CSLCount( papszResourceHREF );    CSLDestroy( papszResourceHREF );    while( nItems > 0 )        CPLDestroyXMLNode( papsSrcTree[--nItems] );    CPLFree( papsSrcTree );//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,


示例10: CPLError

GDALDataset *CTable2Dataset::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 CTable2 file with unsupported data type '%s'.",                 GDALGetDataTypeName( eType ) );        return NULL;    }/* -------------------------------------------------------------------- *//*      Try to open or create file.                                     *//* -------------------------------------------------------------------- */    VSILFILE	*fp;    fp = VSIFOpenL( pszFilename, "wb" );        if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Attempt to create file `%s' failed./n",                  pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Create a file header, with a defaulted georeferencing.          *//* -------------------------------------------------------------------- */    char achHeader[160];    int nValue32;    double dfValue;    memset( achHeader, 0, sizeof(achHeader));    memcpy( achHeader+0, "CTABLE V2.0     ", 16 );        if( CSLFetchNameValue( papszOptions, "DESCRIPTION" ) != NULL )        strncpy( achHeader + 16,                  CSLFetchNameValue( papszOptions, "DESCRIPTION" ),                  80 );        // lower left origin (longitude, center of pixel, radians)    dfValue = 0;    CPL_LSBPTR64( &dfValue );    memcpy( achHeader + 96, &dfValue, 8 );    // lower left origin (latitude, center of pixel, radians)    dfValue = 0;    CPL_LSBPTR64( &dfValue );    memcpy( achHeader + 104, &dfValue, 8 );    // pixel width (radians)    dfValue = 0.01 * M_PI / 180.0;    CPL_LSBPTR64( &dfValue );    memcpy( achHeader + 112, &dfValue, 8 );    // pixel height (radians)    dfValue = 0.01 * M_PI / 180.0;    CPL_LSBPTR64( &dfValue );    memcpy( achHeader + 120, &dfValue, 8 );    // raster width in pixels    nValue32 = nXSize;    CPL_LSBPTR32( &nValue32 );    memcpy( achHeader + 128, &nValue32, 4 );    // raster width in pixels    nValue32 = nYSize;    CPL_LSBPTR32( &nValue32 );    memcpy( achHeader + 132, &nValue32, 4 );    VSIFWriteL( achHeader, 1, sizeof(achHeader), fp );/* -------------------------------------------------------------------- *//*      Write zeroed grid data.                                         *//* -------------------------------------------------------------------- */    float *pafLine = (float *) CPLCalloc(sizeof(float)*2,nXSize);    int i;    for( i = 0; i < nYSize; i++ )    {        if( (int)VSIFWriteL( pafLine, sizeof(float)*2, nXSize, fp ) != nXSize )         {            CPLError( CE_Failure, CPLE_FileIO,                       "Write failed at line %d, perhaps the disk is full?",                      i );            return NULL;        }    }    /* -------------------------------------------------------------------- *//*      Cleanup and return.                                             *//* -------------------------------------------------------------------- */    CPLFree( pafLine );    VSIFCloseL( fp );//.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,


示例11: OGRCalloc

void * OGRCalloc( size_t count, size_t size ){    return CPLCalloc( count, size );}
开发者ID:bjfbm,项目名称:mitab,代码行数:5,


示例12: OGRWktReadPoints

const char * OGRWktReadPoints( const char * pszInput,                               OGRRawPoint ** ppaoPoints, double **ppadfZ,                               int * pnMaxPoints,                               int * pnPointsRead ){    const char *pszOrigInput = pszInput;    *pnPointsRead = 0;    if( pszInput == NULL )        return NULL;    /* -------------------------------------------------------------------- *//*      Eat any leading white space.                                    *//* -------------------------------------------------------------------- */    while( *pszInput == ' ' || *pszInput == '/t' )        pszInput++;/* -------------------------------------------------------------------- *//*      If this isn't an opening bracket then we have a problem!        *//* -------------------------------------------------------------------- */    if( *pszInput != '(' )    {        CPLDebug( "OGR",                  "Expected '(', but got %s in OGRWktReadPoints()./n",                  pszInput );                          return pszInput;    }    pszInput++;/* ==================================================================== *//*      This loop reads a single point.  It will continue till we       *//*      run out of well formed points, or a closing bracket is          *//*      encountered.                                                    *//* ==================================================================== */    char        szDelim[OGR_WKT_TOKEN_MAX];        do {/* -------------------------------------------------------------------- *//*      Read the X and Y values, verify they are numeric.               *//* -------------------------------------------------------------------- */        char    szTokenX[OGR_WKT_TOKEN_MAX];        char    szTokenY[OGR_WKT_TOKEN_MAX];        pszInput = OGRWktReadToken( pszInput, szTokenX );        pszInput = OGRWktReadToken( pszInput, szTokenY );        if( (!isdigit(szTokenX[0]) && szTokenX[0] != '-' && szTokenX[0] != '.' )            || (!isdigit(szTokenY[0]) && szTokenY[0] != '-' && szTokenY[0] != '.') )            return NULL;/* -------------------------------------------------------------------- *//*      Do we need to grow the point list to hold this point?           *//* -------------------------------------------------------------------- */        if( *pnPointsRead == *pnMaxPoints )        {            *pnMaxPoints = *pnMaxPoints * 2 + 10;            *ppaoPoints = (OGRRawPoint *)                CPLRealloc(*ppaoPoints, sizeof(OGRRawPoint) * *pnMaxPoints);            if( *ppadfZ != NULL )            {                *ppadfZ = (double *)                    CPLRealloc(*ppadfZ, sizeof(double) * *pnMaxPoints);            }        }/* -------------------------------------------------------------------- *//*      Add point to list.                                              *//* -------------------------------------------------------------------- */        (*ppaoPoints)[*pnPointsRead].x = atof(szTokenX);        (*ppaoPoints)[*pnPointsRead].y = atof(szTokenY);/* -------------------------------------------------------------------- *//*      Do we have a Z coordinate?                                      *//* -------------------------------------------------------------------- */        pszInput = OGRWktReadToken( pszInput, szDelim );        if( isdigit(szDelim[0]) || szDelim[0] == '-' || szDelim[0] == '.' )        {            if( *ppadfZ == NULL )            {                *ppadfZ = (double *) CPLCalloc(sizeof(double),*pnMaxPoints);            }            (*ppadfZ)[*pnPointsRead] = atof(szDelim);                        pszInput = OGRWktReadToken( pszInput, szDelim );        }                (*pnPointsRead)++;/* -------------------------------------------------------------------- *//*      Do we have a M coordinate?                                      *//*      If we do, just skip it.                                         *//* -------------------------------------------------------------------- */        if( isdigit(szDelim[0]) || szDelim[0] == '-' || szDelim[0] == '.' )        {//.........这里部分代码省略.........
开发者ID:bjfbm,项目名称:mitab,代码行数:101,


示例13: CPLPushErrorHandler

int OGRAVCBinDataSource::Open( const char * pszNewName, int bTestOpen ){/* -------------------------------------------------------------------- *//*      Open the source file.  Suppress error reporting if we are in    *//*      TestOpen mode.                                                  *//* -------------------------------------------------------------------- */    if( bTestOpen )        CPLPushErrorHandler( CPLQuietErrorHandler );    psAVC = AVCE00ReadOpen( pszNewName );    if( bTestOpen )    {        CPLPopErrorHandler();        CPLErrorReset();    }    if( psAVC == NULL )        return FALSE;    pszName = CPLStrdup( pszNewName );    pszCoverageName = CPLStrdup( psAVC->pszCoverName );/* -------------------------------------------------------------------- *//*      Create layers for the "interesting" sections of the coverage.   *//* -------------------------------------------------------------------- */    int		iSection;    papoLayers = (OGRLayer **)        CPLCalloc( sizeof(OGRLayer *), psAVC->numSections );    nLayers = 0;    for( iSection = 0; iSection < psAVC->numSections; iSection++ )    {        AVCE00Section *psSec = psAVC->pasSections + iSection;        switch( psSec->eType )        {          case AVCFileARC:          case AVCFilePAL:          case AVCFileCNT:          case AVCFileLAB:          case AVCFileRPL:          case AVCFileTXT:          case AVCFileTX6:            papoLayers[nLayers++] = new OGRAVCBinLayer( this, psSec );            break;          case AVCFilePRJ:          {              char 	**papszPRJ;              AVCBinFile *hFile;                            hFile = AVCBinReadOpen(psAVC->pszCoverPath,                                      psSec->pszFilename,                                      psAVC->eCoverType,                                      psSec->eType,                                     psAVC->psDBCSInfo);              if( hFile && poSRS == NULL )              {                  papszPRJ = AVCBinReadNextPrj( hFile );                  poSRS = new OGRSpatialReference();                  if( poSRS->importFromESRI( papszPRJ ) != OGRERR_NONE )                  {                      CPLError( CE_Warning, CPLE_AppDefined,                                 "Failed to parse PRJ section, ignoring." );                      delete poSRS;                      poSRS = NULL;                  }                  AVCBinReadClose( hFile );              }          }          break;          default:            ;        }    }        return nLayers > 0;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:83,


示例14: CPLError

//.........这里部分代码省略.........    {        CPLString osSessionName = pszPersistent;        CPLMutexHolder oHolder( &hSessionMapMutex );        if( oSessionMap.count( osSessionName ) == 0 )        {            oSessionMap[osSessionName] = curl_easy_init();            CPLDebug( "HTTP", "Establish persistent session named '%s'.",                      osSessionName.c_str() );        }        http_handle = oSessionMap[osSessionName];    }    /* -------------------------------------------------------------------- */    /*      Are we requested to close a persistent named session?          */    /* -------------------------------------------------------------------- */    else if (pszClosePersistent)    {        CPLString osSessionName = pszClosePersistent;        CPLMutexHolder oHolder( &hSessionMapMutex );        std::map<CPLString,CURL*>::iterator oIter = oSessionMap.find( osSessionName );        if( oIter != oSessionMap.end() )        {            curl_easy_cleanup(oIter->second);            oSessionMap.erase(oIter);            CPLDebug( "HTTP", "Ended persistent session named '%s'.",                      osSessionName.c_str() );        }        else        {            CPLDebug( "HTTP", "Could not find persistent session named '%s'.",                      osSessionName.c_str() );        }        return NULL;    }    else        http_handle = curl_easy_init();    /* -------------------------------------------------------------------- */    /*      Setup the request.                                              */    /* -------------------------------------------------------------------- */    char szCurlErrBuf[CURL_ERROR_SIZE+1];    CPLHTTPResult *psResult;    struct curl_slist *headers=NULL;    const char* pszArobase = strchr(pszURL, '@');    const char* pszSlash = strchr(pszURL, '/');    const char* pszColon = (pszSlash) ? strchr(pszSlash, ':') : NULL;    if (pszArobase != NULL && pszColon != NULL && pszArobase - pszColon > 0)    {        /* http://user:[email
C++ CPLCreateXMLNode函数代码示例
C++ CPLAtof函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。