Пример #1
0
TileSource::TileSource( const TileSourceOptions& options ) :
_options( options )
{
    this->setThreadSafeRefUnref( true );

    if ( *options.L2CacheSize() > 0 )
    {
        _memCache = new MemCache( *options.L2CacheSize() );
    }
    else
    {
        OE_INFO << LC << "L2 Cache disabled" << std::endl;
    }

    if (_options.blacklistFilename().isSet())
    {
        _blacklistFilename = _options.blacklistFilename().value();
    }

    
    if (!_blacklistFilename.empty() && osgDB::fileExists(_blacklistFilename))
    {
        _blacklist = TileBlacklist::read(_blacklistFilename);
        if (_blacklist.valid())
        {
            OE_INFO << "Read blacklist from file" << _blacklistFilename << std::endl;
        }
    }

    if (!_blacklist.valid())
    {
        //Initialize the blacklist if we couldn't read it.
        _blacklist = new TileBlacklist();
    }
}
Пример #2
0
TileSource::TileSource( const TileSourceOptions& options ) :
_options( options ),
_status ( Status::Error("Not initialized") )
{
    this->setThreadSafeRefUnref( true );

    int l2CacheSize = 0;
    char const* l2env = ::getenv( "OSGEARTH_L2_CACHE_SIZE" );
    if ( l2env )
    {
        l2CacheSize = as<int>( std::string(l2env), 0 );
    }
    else if ( *options.L2CacheSize() > 0 )
    {
        _memCache = new MemCache( *options.L2CacheSize() );
    }

    if (_options.blacklistFilename().isSet())
    {
        _blacklistFilename = _options.blacklistFilename().value();
    }

    
    if (!_blacklistFilename.empty() && osgDB::fileExists(_blacklistFilename))
    {
        _blacklist = TileBlacklist::read(_blacklistFilename);
        if (_blacklist.valid())
        {
            OE_INFO << "Read blacklist from file" << _blacklistFilename << std::endl;
        }
    }

    if (!_blacklist.valid())
    {
        //Initialize the blacklist if we couldn't read it.
        _blacklist = new TileBlacklist();
    }
}
Пример #3
0
int main(int argc, char** argv)
{
    osg::ArgumentParser arguments(&argc,argv);

    osgViewer::Viewer viewer(arguments);

    s_mapNode = 0L;
    osg::Node* earthFile = MapNodeHelper().load(arguments, &viewer);
    if (earthFile)
        s_mapNode = MapNode::get(earthFile);

    if ( !s_mapNode )
    {
        OE_WARN << "Unable to load earth file." << std::endl;
        return -1;
    }

    TileSourceOptions tileSourceOptions;
    tileSourceOptions.L2CacheSize() = 0;
    s_deformations = new DeformationTileSource(tileSourceOptions);

    ElevationLayerOptions elevationOpt;
    //elevationOpt.offset() = true;
    elevationOpt.name() = "deformation";
    // This is the only way to get the l2 cache size to pass down even though we're not actually creating a tilesource from the options.
    elevationOpt.driver() = tileSourceOptions;

    ElevationLayer* layer = new ElevationLayer(elevationOpt, s_deformations);
    s_mapNode->getMap()->addElevationLayer(layer);

    osg::Group* root = new osg::Group();
    viewer.setSceneData( root );

    // install the programmable manipulator.
    viewer.setCameraManipulator( new osgEarth::Util::EarthManipulator() );

    // The MapNode will render the Map object in the scene graph.
    root->addChild( earthFile );

    viewer.addEventHandler( new DeformationHandler(root) );

    // add some stock OSG handlers:
    viewer.addEventHandler(new osgViewer::StatsHandler());
    viewer.addEventHandler(new osgViewer::WindowSizeHandler());
    viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));

    return viewer.run();
}