osgEarth 2.1.1
Public Member Functions

KML_NetworkLink Struct Reference

Inheritance diagram for KML_NetworkLink:
Collaboration diagram for KML_NetworkLink:

List of all members.

Public Member Functions

virtual void build (const Config &conf, KMLContext &cx)

Detailed Description

Definition at line 26 of file KML_NetworkLink.


Member Function Documentation

void KML_NetworkLink::build ( const Config conf,
KMLContext cx 
) [virtual]

Definition at line 29 of file KML_NetworkLink.cpp.

{
    std::string name = conf.value("name");

    // parse the link:
    Config linkConf = conf.child("link");
    if ( linkConf.empty() )
    {
        // "url" seems to be acceptable as well
        linkConf = conf.child("url");
        if ( linkConf.empty() )
            return;
    }
    std::string href = linkConf.value("href");
    if ( href.empty() )
        return;

    // "open" determines whether to load it immediately
    bool open = conf.value<bool>("open", false);

    // if it's region-bound, parse it as a paged LOD:
    const Config& regionConf = conf.child("region");
    if ( !regionConf.empty() )
    {
        const Config& llaBoxConf = regionConf.child("latlonaltbox");
        if ( llaBoxConf.empty() )
            return;

        GeoExtent llaExtent(
            cx._mapNode->getMap()->getProfile()->getSRS()->getGeographicSRS(),
            llaBoxConf.value<double>("west",  0.0),
            llaBoxConf.value<double>("south", 0.0),
            llaBoxConf.value<double>("east",  0.0),
            llaBoxConf.value<double>("north", 0.0) );

        double x, y;
        llaExtent.getCentroid( x, y );
        osg::Vec3d lodCenter;
        llaExtent.getSRS()->transformToECEF( osg::Vec3d(x,y,0), lodCenter );

        // figure the tile radius:
        double d = 0.5 * GeoMath::distance(
            osg::DegreesToRadians(llaExtent.yMin()), osg::DegreesToRadians(llaExtent.xMin()),
            osg::DegreesToRadians(llaExtent.yMax()), osg::DegreesToRadians(llaExtent.xMax()) );

        // parse the LOD ranges:
        float minRange = 0, maxRange = 1e6;
        const Config& lodConf = regionConf.child("lod");
        if ( !lodConf.empty() ) 
        {
            // swapped
            minRange = lodConf.value<float>( "minlodpixels", 0.0f );
            if ( minRange < 0.0f )
                minRange = 0.0f;
            maxRange = lodConf.value<float>( "maxlodpixels", FLT_MAX );
            if ( maxRange < 0.0f )
                maxRange = FLT_MAX;
        }

        // build the node
        osg::PagedLOD* plod = new osg::PagedLOD();
        plod->setRangeMode( osg::LOD::PIXEL_SIZE_ON_SCREEN );

        plod->setFileName( 0, href );
        plod->setRange( 0, minRange, maxRange );
        plod->setCenter( lodCenter );
        plod->setRadius( d );
#if OSG_MIN_VERSION_REQUIRED(3,0,0)
        osgDB::Options* options = new osgDB::Options();
        options->setPluginData( "osgEarth::MapNode", cx._mapNode );
        plod->setDatabaseOptions( options );
#endif;
        //plod->setNodeMask( open ? ~0 : 0 );

        OE_DEBUG << LC << 
            "PLOD: radius = " << d << ", minRange=" << minRange << ", maxRange=" << maxRange << std::endl;

        cx._groupStack.top()->addChild( plod );
    }

    else 
    {
        osg::ProxyNode* proxy = new osg::ProxyNode();
        proxy->setFileName( 0, href );                
#if OSG_MIN_VERSION_REQUIRED(3,0,0)
        osgDB::Options* options = new osgDB::Options();
        options->setPluginData( "osgEarth::MapNode", cx._mapNode );
        proxy->setDatabaseOptions( options );
#endif
        //proxy->setNodeMask( open ? ~0 : 0 );

        cx._groupStack.top()->addChild( proxy );
    }

}

Here is the call graph for this function:


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines