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


C++ OGRLinearRing::exportToWkt方法代码示例

本文整理汇总了C++中OGRLinearRing::exportToWkt方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLinearRing::exportToWkt方法的具体用法?C++ OGRLinearRing::exportToWkt怎么用?C++ OGRLinearRing::exportToWkt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRLinearRing的用法示例。


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

示例1: exportToWkt

OGRErr OGRPolygon::exportToWkt( char ** ppszDstText,
                                OGRwkbVariant eWkbVariant ) const

{
    bool bMustWriteComma = false;

/* -------------------------------------------------------------------- */
/*      If we have no valid exterior ring, return POLYGON EMPTY.        */
/* -------------------------------------------------------------------- */
    if( getExteriorRing() == NULL ||
        getExteriorRing()->IsEmpty() )
    {
        if( eWkbVariant == wkbVariantIso )
        {
            if( (flags & OGR_G_3D) && (flags & OGR_G_MEASURED) )
                *ppszDstText = CPLStrdup((CPLString(getGeometryName()) + " ZM EMPTY").c_str());
            else if( flags & OGR_G_MEASURED )
                *ppszDstText = CPLStrdup((CPLString(getGeometryName()) + " M EMPTY").c_str());
            else if( flags & OGR_G_3D )
                *ppszDstText = CPLStrdup((CPLString(getGeometryName()) + " Z EMPTY").c_str());
            else
                *ppszDstText = CPLStrdup((CPLString(getGeometryName()) + " EMPTY").c_str());
        }
        else
            *ppszDstText = CPLStrdup((CPLString(getGeometryName()) + " EMPTY").c_str());
        return OGRERR_NONE;
    }

/* -------------------------------------------------------------------- */
/*      Build a list of strings containing the stuff for each ring.     */
/* -------------------------------------------------------------------- */
    char **papszRings =
        static_cast<char **>(CPLCalloc(sizeof(char *), oCC.nCurveCount));
    size_t nCumulativeLength = 0;
    size_t nNonEmptyRings = 0;
    size_t *pnRingBeginning =
        static_cast<size_t *>(CPLCalloc(sizeof(size_t), oCC.nCurveCount));

    OGRErr eErr;
    for( int iRing = 0; iRing < oCC.nCurveCount; iRing++ )
    {
        OGRLinearRing* poLR = (OGRLinearRing*) oCC.papoCurves[iRing];
        //poLR->setFlags( getFlags() );
        poLR->set3D(Is3D());
        poLR->setMeasured(IsMeasured());
        if( poLR->getNumPoints() == 0 )
        {
            papszRings[iRing] = NULL;
            continue;
        }

        eErr = poLR->exportToWkt( &(papszRings[iRing]), eWkbVariant );
        if( eErr != OGRERR_NONE )
            goto error;

        if( STARTS_WITH_CI(papszRings[iRing], "LINEARRING ZM (") )
            pnRingBeginning[iRing] = 14;
        else if( STARTS_WITH_CI(papszRings[iRing], "LINEARRING M (") )
            pnRingBeginning[iRing] = 13;
        else if( STARTS_WITH_CI(papszRings[iRing], "LINEARRING Z (") )
            pnRingBeginning[iRing] = 13;
        else if( STARTS_WITH_CI(papszRings[iRing], "LINEARRING (") )
            pnRingBeginning[iRing] = 11;
        else
        {
            CPLAssert(false);
        }

        nCumulativeLength += strlen(papszRings[iRing] + pnRingBeginning[iRing]);

        nNonEmptyRings++;
    }

/* -------------------------------------------------------------------- */
/*      Allocate exactly the right amount of space for the              */
/*      aggregated string.                                              */
/* -------------------------------------------------------------------- */
    *ppszDstText = (char *) VSI_MALLOC_VERBOSE(
        nCumulativeLength + nNonEmptyRings + strlen(getGeometryName()) + strlen(" ZM ()") + 1);

    if( *ppszDstText == NULL )
    {
        eErr = OGRERR_NOT_ENOUGH_MEMORY;
        goto error;
    }

/* -------------------------------------------------------------------- */
/*      Build up the string, freeing temporary strings as we go.        */
/* -------------------------------------------------------------------- */
    if( eWkbVariant == wkbVariantIso )
    {
        if( (flags & OGR_G_3D) && (flags & OGR_G_MEASURED) )
            strcpy( *ppszDstText, (CPLString(getGeometryName()) + " ZM (").c_str() );
        else if( flags & OGR_G_MEASURED )
            strcpy( *ppszDstText, (CPLString(getGeometryName()) + " M (").c_str() );
        else if( flags & OGR_G_3D )
            strcpy( *ppszDstText, (CPLString(getGeometryName()) + " Z (").c_str() );
        else
            strcpy( *ppszDstText, (CPLString(getGeometryName()) + " (").c_str() );
    }
//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,代码来源:ogrpolygon.cpp


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