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


C++ DocumentPtr::add_styleselector方法代码示例

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


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

示例1: createkmlliststyle

void createkmlliststyle (
    KmlFactory * poKmlFactory,
    const char* pszBaseName,
    ContainerPtr poKmlLayerContainer,
    DocumentPtr poKmlDocument,
    const CPLString& osListStyleType,
    const CPLString& osListStyleIconHref)
{
    if( osListStyleType.size() || osListStyleIconHref.size() )
    {
        StylePtr poKmlStyle = poKmlFactory->CreateStyle (  );

        const char* pszStyleName = CPLSPrintf("%s_liststyle", OGRLIBKMLGetSanitizedNCName(pszBaseName).c_str());
        poKmlStyle->set_id ( pszStyleName );

        ListStylePtr poKmlListStyle = poKmlFactory->CreateListStyle (  );
        poKmlStyle->set_liststyle ( poKmlListStyle );
        if( osListStyleType.size() )
        {
            if( EQUAL(osListStyleType, "check") )
                poKmlListStyle->set_listitemtype( kmldom::LISTITEMTYPE_CHECK );
            else if( EQUAL(osListStyleType, "radioFolder") )
                poKmlListStyle->set_listitemtype( kmldom::LISTITEMTYPE_RADIOFOLDER );
            else if( EQUAL(osListStyleType, "checkOffOnly") )
                poKmlListStyle->set_listitemtype( kmldom::LISTITEMTYPE_CHECKOFFONLY );
            else if( EQUAL(osListStyleType, "checkHideChildren") )
                poKmlListStyle->set_listitemtype( kmldom::LISTITEMTYPE_CHECKHIDECHILDREN );
            else
            {
                CPLError(CE_Warning, CPLE_AppDefined,
                         "Invalid value for list style type: %s. Defaulting to Check",
                         osListStyleType.c_str());
                poKmlListStyle->set_listitemtype( kmldom::LISTITEMTYPE_CHECK );
            }
        }

        if( osListStyleIconHref.size() )
        {
            ItemIconPtr poItemIcon = poKmlFactory->CreateItemIcon (  );
            poItemIcon->set_href( osListStyleIconHref.c_str() );
            poKmlListStyle->add_itemicon(poItemIcon);
        }

        poKmlDocument->add_styleselector ( poKmlStyle );
        poKmlLayerContainer->set_styleurl( CPLSPrintf("#%s", pszStyleName) );
    }
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:47,代码来源:ogrlibkmlstyle.cpp

示例2: styletable2kml

void styletable2kml (
    OGRStyleTable * poOgrStyleTable,
    KmlFactory * poKmlFactory,
    ContainerPtr poKmlContainer )
{

    /***** just return if the styletable is null *****/

    if ( !poOgrStyleTable )
        return;

    /***** parse the style table *****/

    poOgrStyleTable->ResetStyleStringReading (  );
    const char *pszStyleString;

    while ( ( pszStyleString = poOgrStyleTable->GetNextStyle (  ) ) ) {
        const char *pszStyleName = poOgrStyleTable->GetLastStyleName (  );

        /***** add the style header to the kml *****/

        StylePtr poKmlStyle = poKmlFactory->CreateStyle (  );

        poKmlStyle->set_id ( pszStyleName + 1 );

        /***** parse the style string *****/

        addstylestring2kml ( pszStyleString, poKmlStyle, poKmlFactory, NULL, NULL );

        /***** add the style to the container *****/

        DocumentPtr poKmlDocument = AsDocument ( poKmlContainer );

        //ObjectPtr pokmlObject = boost::static_pointer_cast <kmldom::Object> () ;
        //poKmlContainer->add_feature ( AsFeature( poKmlStyle) );
        poKmlDocument->add_styleselector ( poKmlStyle );

    }

    return;
}
开发者ID:afarnham,项目名称:gdal,代码行数:41,代码来源:ogrlibkmlstyle.cpp

示例3: styletable2kml

void styletable2kml (
    OGRStyleTable * poOgrStyleTable,
    KmlFactory * poKmlFactory,
    ContainerPtr poKmlContainer,
    char** papszOptions )
{

    /***** just return if the styletable is null *****/

    if ( !poOgrStyleTable )
        return;

    std::set<CPLString> aoSetNormalStyles;
    std::set<CPLString> aoSetHighlightStyles;
    poOgrStyleTable->ResetStyleStringReading (  );
    const char *pszStyleString;

    /* Collect styles that end with _normal or _highlight */
    while ( poOgrStyleTable->GetNextStyle (  ) != NULL ) {
        const char *pszStyleName = poOgrStyleTable->GetLastStyleName (  );

        if( strlen(pszStyleName) > strlen("_normal") &&
            EQUAL(pszStyleName + strlen(pszStyleName) - strlen("_normal"), "_normal") )
        {
            CPLString osName(pszStyleName);
            osName.resize(strlen(pszStyleName) - strlen("_normal"));
            aoSetNormalStyles.insert(osName);
        }
        else if( strlen(pszStyleName) > strlen("_highlight") &&
                  EQUAL(pszStyleName + strlen(pszStyleName) - strlen("_highlight"), "_highlight") )
        {
            CPLString osName(pszStyleName);
            osName.resize(strlen(pszStyleName) - strlen("_highlight"));
            aoSetHighlightStyles.insert(osName);
        }
    }

    /***** parse the style table *****/

    poOgrStyleTable->ResetStyleStringReading (  );

    while ( ( pszStyleString = poOgrStyleTable->GetNextStyle (  ) ) != NULL ) {
        const char *pszStyleName = poOgrStyleTable->GetLastStyleName (  );

        if( aoSetNormalStyles.find(pszStyleName) != aoSetNormalStyles.end() &&
            aoSetHighlightStyles.find(pszStyleName) != aoSetHighlightStyles.end() )
        {
            continue;
        }

        /***** add the style header to the kml *****/

        StylePtr poKmlStyle = poKmlFactory->CreateStyle (  );

        poKmlStyle->set_id ( pszStyleName );

        /***** parse the style string *****/

        addstylestring2kml ( pszStyleString, poKmlStyle, poKmlFactory, NULL );

        /***** add balloon style *****/
        const char* pszBalloonStyleBgColor = CSLFetchNameValue(papszOptions, CPLSPrintf("%s_balloonstyle_bgcolor", pszStyleName));
        const char* pszBalloonStyleText = CSLFetchNameValue(papszOptions, CPLSPrintf("%s_balloonstyle_text", pszStyleName));
        int nR, nG, nB, nA;
        OGRStylePen oStyleTool;
        if( (pszBalloonStyleBgColor != NULL &&
             oStyleTool.GetRGBFromString ( pszBalloonStyleBgColor, nR, nG, nB, nA )  ) ||
            pszBalloonStyleText != NULL )
        {
            BalloonStylePtr poKmlBalloonStyle = poKmlFactory->CreateBalloonStyle();
            if( pszBalloonStyleBgColor != NULL &&
                oStyleTool.GetRGBFromString ( pszBalloonStyleBgColor, nR, nG, nB, nA ) )
                poKmlBalloonStyle->set_bgcolor ( Color32 ( static_cast<GByte>(nA),
                                                           static_cast<GByte>(nB),
                                                           static_cast<GByte>(nG),
                                                           static_cast<GByte>(nR) ) );
            if( pszBalloonStyleText != NULL )
                poKmlBalloonStyle->set_text(pszBalloonStyleText);
            poKmlStyle->set_balloonstyle ( poKmlBalloonStyle );
        }

        /***** add the style to the container *****/

        DocumentPtr poKmlDocument = AsDocument ( poKmlContainer );
        poKmlDocument->add_styleselector ( poKmlStyle );

    }

    /* Find style name that end with _normal and _highlight to create */
    /* a StyleMap from both */
    std::set<CPLString>::iterator aoSetNormalStylesIter =
        aoSetNormalStyles.begin();
    for( ; aoSetNormalStylesIter != aoSetNormalStyles.end(); ++aoSetNormalStylesIter )
    {
        CPLString osStyleName(*aoSetNormalStylesIter);
        if( aoSetHighlightStyles.find(osStyleName) !=
                aoSetHighlightStyles.end() )
        {
            StyleMapPtr poKmlStyleMap = poKmlFactory->CreateStyleMap (  );
            poKmlStyleMap->set_id ( osStyleName );
//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,代码来源:ogrlibkmlstyle.cpp


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