当前位置: 首页>>代码示例>>C++>>正文


C++ CPLAtof函数代码示例

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


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

示例1: ParseXY

static int ParseXY( const char **ppszNext, double *padfXY )

{
    int iStartY;
    const char *pszNext = *ppszNext;

    for( iStartY = 0; ; iStartY++ )
    {
        if( pszNext[iStartY] == '\0' )
            return FALSE;

        if( pszNext[iStartY] == ',' )
        {
            iStartY++;
            break;
        }
    }

    padfXY[0] = CPLAtof(pszNext);
    padfXY[1] = CPLAtof(pszNext + iStartY);

    int iEnd;

    for( iEnd = iStartY;
         pszNext[iEnd] != ')';
         iEnd++ )
    {
        if( pszNext[iEnd] == '\0' )
            return FALSE;
    }
    
    *ppszNext += iEnd;

    return TRUE;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:35,代码来源:ogringreslayer.cpp

示例2: GetLatLon

static int GetLatLon(const char* pszLat,
                     char        chLatHemisphere,
                     const char* pszLon,
                     char        chLonHemisphere,
                     int         nSecLen,
                     double& dfLat, double& dfLon)
{
    char szDeg[4] = { pszLat[0], pszLat[1], 0 };
    char szMin[3] = { pszLat[3], pszLat[4], 0 };
    char szSec[10];
    memcpy(szSec, pszLat + 6, std::max((int)sizeof(szSec) - 1, nSecLen));
    szSec[std::max((int)sizeof(szSec) - 1, nSecLen)] = 0;

    dfLat = atoi(szDeg) + atoi(szMin) / 60. + CPLAtof(szSec) / 3600.;
    if (chLatHemisphere == 'S')
        dfLat = -dfLat;

    szDeg[0] = pszLon[0];
    szDeg[1] = pszLon[1];
    szDeg[2] = pszLon[2];
    szDeg[3] = 0;
    szMin[0] = pszLon[4];
    szMin[1] = pszLon[5];
    szMin[2] = 0;
    memcpy(szSec, pszLon + 7, std::max((int)sizeof(szSec) - 1, nSecLen));
    szSec[std::max((int)sizeof(szSec) - 1, nSecLen)] = 0;

    dfLon = atoi(szDeg) + atoi(szMin) / 60. + CPLAtof(szSec) / 3600.;
    if (chLonHemisphere == ' ' || chLonHemisphere == 'W')
        dfLon = -dfLon;

    return TRUE;
}
开发者ID:koordinates,项目名称:gdal,代码行数:33,代码来源:ograeronavfaalayer.cpp

示例3: CPLURLAddKVP

OGRErr OGRESRIFeatureServiceLayer::GetExtent(OGREnvelope *psExtent, int bForce)
{
    OGRErr eErr = OGRERR_FAILURE;
    CPLString osNewURL = CPLURLAddKVP(poDS->GetURL(), "returnExtentOnly", "true");
    osNewURL = CPLURLAddKVP(osNewURL, "f", "geojson");
    CPLErrorReset();
    CPLHTTPResult* pResult = CPLHTTPFetch( osNewURL, NULL );
    if( pResult != NULL && pResult->nDataLen != 0 && CPLGetLastErrorNo() == 0 &&
        pResult->nStatus == 0 )
    {
        const char* pszBBox = strstr((const char*)pResult->pabyData, "\"bbox\"");
        if( pszBBox )
        {
            pszBBox = strstr(pszBBox, ":[");
            if( pszBBox )
            {
                pszBBox+=2;
                char** papszTokens = CSLTokenizeString2(pszBBox, ",", 0);
                if( CSLCount(papszTokens) >= 4 )
                {
                    psExtent->MinX = CPLAtof(papszTokens[0]);
                    psExtent->MinY = CPLAtof(papszTokens[1]);
                    psExtent->MaxX = CPLAtof(papszTokens[2]);
                    psExtent->MaxY = CPLAtof(papszTokens[3]);
                    eErr = OGRERR_NONE;
                }
                CSLDestroy(papszTokens);
            }
        }
    }
    CPLHTTPDestroyResult( pResult );
    if( eErr == OGRERR_FAILURE )
        eErr = OGRLayer::GetExtent(psExtent, bForce);
    return eErr;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:35,代码来源:ogrgeojsondriver.cpp

示例4: CSLFetchNameValue

void OGROCIWritableLayer::ParseDIMINFO( const char *pszOptionName, 
                                        double *pdfMin, 
                                        double *pdfMax,
                                        double *pdfRes )

{
    const char *pszUserDIMINFO;
    char **papszTokens;

    pszUserDIMINFO = CSLFetchNameValue( papszOptions, pszOptionName );
    if( pszUserDIMINFO == NULL )
        return;

    papszTokens = 
        CSLTokenizeStringComplex( pszUserDIMINFO, ",", FALSE, FALSE );
    if( CSLCount(papszTokens) != 3 )
    {
        CSLDestroy( papszTokens );
        CPLError( CE_Warning, CPLE_AppDefined, 
                  "Ignoring %s, it does not contain three comma separated values.", 
                  pszOptionName );
        return;
    }

    *pdfMin = CPLAtof(papszTokens[0]);
    *pdfMax = CPLAtof(papszTokens[1]);
    *pdfRes = CPLAtof(papszTokens[2]);

    CSLDestroy( papszTokens );
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:30,代码来源:ogrociwritablelayer.cpp

示例5: oSRS

CPLErr TerragenDataset::SetProjection( const char * pszNewProjection )
{
    // Terragen files aren't really georeferenced, but
    // we should get the projection's linear units so
    // that we can scale elevations correctly.

    //m_dSCAL = 30.0; // default

    OGRSpatialReference oSRS( pszNewProjection );

/* -------------------------------------------------------------------- */
/*      Linear units.                                                   */
/* -------------------------------------------------------------------- */
    m_bIsGeo = oSRS.IsGeographic() != FALSE;
    if(m_bIsGeo)
    {
        // The caller is using degrees. We need to convert
        // to meters, otherwise we can't derive a SCAL
        // value to scale elevations with.
        m_bIsGeo = true;
    }
    else
    {
        const double dfLinear = oSRS.GetLinearUnits();

        if( approx_equal(dfLinear, 0.3048))
            m_dMetersPerGroundUnit = 0.3048;
        else if( approx_equal(dfLinear, CPLAtof(SRS_UL_US_FOOT_CONV)) )
            m_dMetersPerGroundUnit = CPLAtof(SRS_UL_US_FOOT_CONV);
        else
            m_dMetersPerGroundUnit = 1.0;
    }

    return CE_None;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:35,代码来源:terragendataset.cpp

示例6: MITABExtractCoordSysBounds

GBool MITABExtractCoordSysBounds( const char * pszCoordSys,
                                  double &dXMin, double &dYMin,
                                  double &dXMax, double &dYMax )

{
    char        **papszFields;

    if( pszCoordSys == NULL )
        return FALSE;
    
    papszFields = CSLTokenizeStringComplex( pszCoordSys, " ,()", TRUE, FALSE );

    int iBounds = CSLFindString( papszFields, "Bounds" );

    if (iBounds >= 0 && iBounds + 4 < CSLCount(papszFields))
    {
        dXMin = CPLAtof(papszFields[++iBounds]);
        dYMin = CPLAtof(papszFields[++iBounds]);
        dXMax = CPLAtof(papszFields[++iBounds]);
        dYMax = CPLAtof(papszFields[++iBounds]);
        CSLDestroy( papszFields );
        return TRUE;
    }

    CSLDestroy( papszFields );
    return FALSE;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:27,代码来源:mitab_coordsys.cpp

示例7: ParseXY

static bool ParseXY( const char **ppszNext, double *padfXY )

{
    const char *pszNext = *ppszNext;

    int iStartY = 0;  // Used after for.
    for( ; ; iStartY++ )
    {
        if( pszNext[iStartY] == '\0' )
            return false;

        if( pszNext[iStartY] == ',' )
        {
            iStartY++;
            break;
        }
    }

    padfXY[0] = CPLAtof(pszNext);
    padfXY[1] = CPLAtof(pszNext + iStartY);

    int iEnd = iStartY;  // Used after for.
    for( ; pszNext[iEnd] != ')'; iEnd++ )
    {
        if( pszNext[iEnd] == '\0' )
            return false;
    }

    *ppszNext += iEnd;

    return true;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:32,代码来源:ogringreslayer.cpp

示例8: ParseCoordinate

static
Coordinate* ParseCoordinate(std::string const& text)
{
    int pos = 0;
    const char* pszStr = text.c_str();
    Coordinate *psTmp = new Coordinate();

    // X coordinate
    psTmp->dfLongitude = CPLAtof(pszStr);
    while(isNumberDigit(pszStr[pos++]));

    // Y coordinate
    if(pszStr[pos - 1] != ',')
    {
        delete psTmp;
        return NULL;
    }

    psTmp->dfLatitude = CPLAtof(pszStr + pos);
    while(isNumberDigit(pszStr[pos++]));

    // Z coordinate
    if(pszStr[pos - 1] != ',')
    {
        psTmp->bHasZ = FALSE;
        psTmp->dfAltitude = 0;
        return psTmp;
    }

    psTmp->bHasZ = TRUE;
    psTmp->dfAltitude = CPLAtof(pszStr + pos);

    return psTmp;
}
开发者ID:garnertb,项目名称:gdal,代码行数:34,代码来源:kmlnode.cpp

示例9: CSLFetchNameValue

CPLErr PAuxDataset::GetGeoTransform( double * padfGeoTransform )

{
    if( CSLFetchNameValue(papszAuxLines, "UpLeftX") != NULL
        && CSLFetchNameValue(papszAuxLines, "UpLeftY") != NULL
        && CSLFetchNameValue(papszAuxLines, "LoRightX") != NULL
        && CSLFetchNameValue(papszAuxLines, "LoRightY") != NULL )
    {
        const double dfUpLeftX = CPLAtof(CSLFetchNameValue(papszAuxLines, "UpLeftX" ));
        const double dfUpLeftY = CPLAtof(CSLFetchNameValue(papszAuxLines, "UpLeftY" ));
        const double dfLoRightX = CPLAtof(CSLFetchNameValue(papszAuxLines, "LoRightX" ));
        const double dfLoRightY = CPLAtof(CSLFetchNameValue(papszAuxLines, "LoRightY" ));

        padfGeoTransform[0] = dfUpLeftX;
        padfGeoTransform[1] = (dfLoRightX - dfUpLeftX) / GetRasterXSize();
        padfGeoTransform[2] = 0.0;
        padfGeoTransform[3] = dfUpLeftY;
        padfGeoTransform[4] = 0.0;
        padfGeoTransform[5] = (dfLoRightY - dfUpLeftY) / GetRasterYSize();

        return CE_None;
    }
    else
    {
        padfGeoTransform[0] = 0.0;
        padfGeoTransform[1] = 1.0;
        padfGeoTransform[2] = 0.0;
        padfGeoTransform[3] = 0.0;
        padfGeoTransform[4] = 0.0;
        padfGeoTransform[5] = 1.0;

        return CE_Failure;
    }
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:34,代码来源:pauxdataset.cpp

示例10: PamParseHistogram

int
PamParseHistogram( CPLXMLNode *psHistItem,
                   double *pdfMin, double *pdfMax,
                   int *pnBuckets, GUIntBig **ppanHistogram,
                   CPL_UNUSED int *pbIncludeOutOfRange,
                   CPL_UNUSED int *pbApproxOK )
{
    if( psHistItem == NULL )
        return FALSE;

    *pdfMin = CPLAtof(CPLGetXMLValue( psHistItem, "HistMin", "0"));
    *pdfMax = CPLAtof(CPLGetXMLValue( psHistItem, "HistMax", "1"));
    *pnBuckets = atoi(CPLGetXMLValue( psHistItem, "BucketCount","2"));

    if (*pnBuckets <= 0 || *pnBuckets > INT_MAX / 2)
        return FALSE;

    if( ppanHistogram == NULL )
        return TRUE;

    // Fetch the histogram and use it.
    int iBucket;
    const char *pszHistCounts = CPLGetXMLValue( psHistItem,
                                                "HistCounts", "" );

    /* Sanity check to test consistency of BucketCount and HistCounts */
    if( strlen(pszHistCounts) < 2 * (size_t)(*pnBuckets) -1 )
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "HistCounts content isn't consistent with BucketCount value");
        return FALSE;
    }

    *ppanHistogram = (GUIntBig *) VSICalloc(sizeof(GUIntBig),*pnBuckets);
    if (*ppanHistogram == NULL)
    {
        CPLError(CE_Failure, CPLE_OutOfMemory,
                 "Cannot allocate memory for %d buckets", *pnBuckets);
        return FALSE;
    }

    for( iBucket = 0; iBucket < *pnBuckets; iBucket++ )
    {
        (*ppanHistogram)[iBucket] = CPLAtoGIntBig(pszHistCounts);

        // skip to next number.
        while( *pszHistCounts != '\0' && *pszHistCounts != '|' )
            pszHistCounts++;
        if( *pszHistCounts == '|' )
            pszHistCounts++;
    }

    return TRUE;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:54,代码来源:gdalpamrasterband.cpp

示例11: GetMetadataItem

CPLErr HDF5ImageDataset::CreateODIMH5Projection()
{
    const char* const pszProj4String = GetMetadataItem("where_projdef");
    const char* const pszLL_lon = GetMetadataItem("where_LL_lon");
    const char* const pszLL_lat = GetMetadataItem("where_LL_lat");
    const char* const pszUR_lon = GetMetadataItem("where_UR_lon");
    const char* const pszUR_lat = GetMetadataItem("where_UR_lat");
    if( pszProj4String == NULL ||
        pszLL_lon == NULL || pszLL_lat == NULL ||
        pszUR_lon == NULL || pszUR_lat == NULL )
        return CE_Failure;

    if( oSRS.importFromProj4( pszProj4String ) != OGRERR_NONE )
        return CE_Failure;

    OGRSpatialReference oSRSWGS84;
    oSRSWGS84.SetWellKnownGeogCS( "WGS84" );

    OGRCoordinateTransformation* poCT =
        OGRCreateCoordinateTransformation( &oSRSWGS84, &oSRS );
    if( poCT == NULL )
        return CE_Failure;

    /* Reproject corners from long,lat WGS84 to the target SRS */
    double dfLLX = CPLAtof(pszLL_lon);
    double dfLLY = CPLAtof(pszLL_lat);
    double dfURX = CPLAtof(pszUR_lon);
    double dfURY = CPLAtof(pszUR_lat);
    if( !poCT->Transform(1, &dfLLX, &dfLLY) ||
        !poCT->Transform(1, &dfURX, &dfURY) )
    {
        delete poCT;
        return CE_Failure;
    }
    delete poCT;

    /* Compute the geotransform now */
    const double dfPixelX = (dfURX - dfLLX) / nRasterXSize;
    const double dfPixelY = (dfURY - dfLLY) / nRasterYSize;

    bHasGeoTransform = true;
    adfGeoTransform[0] = dfLLX;
    adfGeoTransform[1] = dfPixelX;
    adfGeoTransform[2] = 0;
    adfGeoTransform[3] = dfURY;
    adfGeoTransform[4] = 0;
    adfGeoTransform[5] = -dfPixelY;

    CPLFree( pszProjection );
    oSRS.exportToWkt( &pszProjection );

    return CE_None;
}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:53,代码来源:hdf5imagedataset.cpp

示例12: while

int GDALRasterBlock::FlushCacheBlock( int bDirtyBlocksOnly )

{
    GDALRasterBlock *poTarget;

    {
        INITIALIZE_LOCK;
        poTarget = poOldest;

        while( poTarget != NULL )
        {
            if( !bDirtyBlocksOnly || poTarget->GetDirty() )
            {
                if( CPLAtomicCompareAndExchange(
                        &(poTarget->nLockCount), 0, -1) )
                    break;
            }
            poTarget = poTarget->poPrevious;
        }

        if( poTarget == NULL )
            return FALSE;
        if( bSleepsForBockCacheDebug )
            CPLSleep(CPLAtof(
                CPLGetConfigOption(
                    "GDAL_RB_FLUSHBLOCK_SLEEP_AFTER_DROP_LOCK", "0")));

        poTarget->Detach_unlocked();
        poTarget->GetBand()->UnreferenceBlock(poTarget);
    }

    if( bSleepsForBockCacheDebug )
        CPLSleep(CPLAtof(
            CPLGetConfigOption("GDAL_RB_FLUSHBLOCK_SLEEP_AFTER_RB_LOCK", "0")));

    if( poTarget->GetDirty() )
    {
        const CPLErr eErr = poTarget->Write();
        if( eErr != CE_None )
        {
            // Save the error for later reporting.
            poTarget->GetBand()->SetFlushBlockErr(eErr);
        }
    }

    VSIFree(poTarget->pData);
    poTarget->pData = NULL;
    poTarget->GetBand()->AddBlockToFreeList(poTarget);

    return TRUE;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:51,代码来源:gdalrasterblock.cpp

示例13: swq_compare_real

static int FORCE_CDECL swq_compare_real( const void *item1, const void *item2 )
{
    double  v1, v2;

    v1 = CPLAtof(*((const char **) item1));
    v2 = CPLAtof(*((const char **) item2));

    if( v1 < v2 )
        return -1;
    else if( v1 == v2 )
        return 0;
    else
        return 1;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:14,代码来源:swq.cpp

示例14: CSLTokenizeString

std::vector<double>
OGRDXFWriterLayer::PrepareLineTypeDefinition( OGRStylePen *poPen )
{

/* -------------------------------------------------------------------- */
/*      Fetch pattern.                                                  */
/* -------------------------------------------------------------------- */
    GBool bDefault;
    const char *pszPattern = poPen->Pattern( bDefault );

    if( bDefault || strlen(pszPattern) == 0 )
        return std::vector<double>();

/* -------------------------------------------------------------------- */
/*      Split into pen up / pen down bits.                              */
/* -------------------------------------------------------------------- */
    char **papszTokens = CSLTokenizeString(pszPattern);
    std::vector<double> adfWeightTokens;

    for( int i = 0; papszTokens != nullptr && papszTokens[i] != nullptr; i++ )
    {
        const char *pszToken = papszTokens[i];
        CPLString osAmount;
        CPLString osDXFEntry;

        // Split amount and unit.
        const char *pszUnit = pszToken;  // Used after for.
        for( ;
             strchr( "0123456789.", *pszUnit) != nullptr;
             pszUnit++ ) {}

        osAmount.assign(pszToken,(int) (pszUnit-pszToken));

        // If the unit is other than 'g' we really should be trying to
        // do some type of transformation - but what to do?  Pretty hard.

        // Even entries are "pen down" represented as positive in DXF.
        // "Pen up" entries (gaps) are represented as negative.
        if( i%2 == 0 )
            adfWeightTokens.push_back( CPLAtof( osAmount ) );
        else
            adfWeightTokens.push_back( -CPLAtof( osAmount ) );
    }

    CSLDestroy( papszTokens );

    return adfWeightTokens;
}
开发者ID:OSGeo,项目名称:gdal,代码行数:48,代码来源:ogrdxfwriterlayer.cpp

示例15: OPTGetParameterInfo

int OPTGetParameterInfo( const char * pszProjectionMethod,
                         const char * pszParameterName,
                         char ** ppszUserName,
                         char ** ppszType,
                         double *pdfDefaultValue )

{
    int         i;

    (void) pszProjectionMethod;

    for( i = 0; papszParameterDefinitions[i] != NULL; i += 4 )
    {
        if( EQUAL(papszParameterDefinitions[i],pszParameterName) )
        {
            if( ppszUserName != NULL )
                *ppszUserName = (char *)papszParameterDefinitions[i+1];
            if( ppszType != NULL )
                *ppszType = (char *)papszParameterDefinitions[i+2];
            if( pdfDefaultValue != NULL )
                *pdfDefaultValue = CPLAtof(papszParameterDefinitions[i+3]);

            return TRUE;
        }
    }

    return FALSE;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:28,代码来源:ogr_opt.cpp


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