osgEarth 2.1.1
Defines | Functions

/home/cube/sources/osgearth/src/applications/osgearth_seed/osgearth_seed.cpp File Reference

#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osg/io_utils>
#include <osgEarth/Common>
#include <osgEarth/Map>
#include <osgEarth/CacheSeed>
#include <osgEarth/MapNode>
#include <osgEarth/Registry>
#include <osgEarth/Caching>
#include <iostream>
#include <sstream>
#include <iterator>
Include dependency graph for osgearth_seed.cpp:

Go to the source code of this file.

Defines

#define LC   "[osgearth_cache] "

Functions

int list (osg::ArgumentParser &args)
int seed (osg::ArgumentParser &args)
int purge (osg::ArgumentParser &args)
int usage (const std::string &msg)
int message (const std::string &msg)
int main (int argc, char **argv)

Define Documentation

#define LC   "[osgearth_cache] "

Definition at line 39 of file osgearth_seed.cpp.


Function Documentation

int list ( osg::ArgumentParser &  args)

Definition at line 151 of file osgearth_seed.cpp.

{
    osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
    if ( !node.valid() )
        return usage( "Failed to read .earth file." );

    MapNode* mapNode = MapNode::findMapNode( node.get() );
    if ( !mapNode )
        return usage( "Input file was not a .earth file" );

    Map* map = mapNode->getMap();
    const Cache* cache = map->getCache();

    if ( !cache )
        return message( "Earth file does not contain a cache." );

    std::cout 
        << "Cache config = " << cache->getCacheOptions().getConfig().toString() << std::endl;

    MapFrame mapf( mapNode->getMap() );

    TerrainLayerVector layers;
    std::copy( mapf.imageLayers().begin(), mapf.imageLayers().end(), std::back_inserter(layers) );
    std::copy( mapf.elevationLayers().begin(), mapf.elevationLayers().end(), std::back_inserter(layers) );

    for( TerrainLayerVector::const_iterator i =layers.begin(); i != layers.end(); ++i )
    {
        TerrainLayer* layer = i->get();
        const CacheSpec& spec = layer->getCacheSpec();
        std::cout
            << "Layer = \"" << layer->getName() << "\", cacheId = " << spec.cacheId() << std::endl;
    }

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file osgearth_seed.cpp.

{
    osg::ArgumentParser args(&argc,argv);

    if ( args.read( "--seed") )
        return seed( args );
    else if ( args.read( "--list" ) )
        return list( args );
    else if ( args.read( "--purge" ) )
        return purge( args );
    else
        return usage("");
}

Here is the call graph for this function:

int message ( const std::string &  msg)

Definition at line 92 of file osgearth_seed.cpp.

{
    if ( !msg.empty() )
    {
        std::cout << msg << std::endl << std::endl;
    }
    return 0;
}

Here is the caller graph for this function:

int purge ( osg::ArgumentParser &  args)

Definition at line 188 of file osgearth_seed.cpp.

{
    return usage( "Sorry, but purge is not yet implemented." );

    osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
    if ( !node.valid() )
        return usage( "Failed to read .earth file." );

    MapNode* mapNode = MapNode::findMapNode( node.get() );
    if ( !mapNode )
        return usage( "Input file was not a .earth file" );

    Map* map = mapNode->getMap();
    const Cache* cache = map->getCache();

    if ( !cache )
        return message( "Earth file does not contain a cache." );
}

Here is the call graph for this function:

Here is the caller graph for this function:

int seed ( osg::ArgumentParser &  args)

Definition at line 103 of file osgearth_seed.cpp.

{    
    //Read the min level
    unsigned int minLevel = 0;
    while (args.read("--min-level", minLevel));
    
    //Read the max level
    unsigned int maxLevel = 5;
    while (args.read("--max-level", maxLevel));
    
    //Read the bounds
    Bounds bounds(0, 0, 0, 0);
    while (args.read("--bounds", bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax()));
    while (args.read("-b", bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax()));

    //Read the cache override directory
    std::string cachePath;
    while (args.read("--cache-path", cachePath));

    //Read the cache type
    std::string cacheType;
    while (args.read("--cache-type", cacheType));

    bool quiet = args.read("--quiet");

    //Read in the earth file.
    osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
    if ( !node.valid() )
        return usage( "Failed to read .earth file." );

    MapNode* mapNode = MapNode::findMapNode( node.get() );
    if ( !mapNode )
        return usage( "Input file was not a .earth file" );

    CacheSeed seeder;
    seeder.setMinLevel( minLevel );
    seeder.setMaxLevel( maxLevel );
    seeder.setBounds( bounds );
    if (!quiet)
    {
        seeder.setProgressCallback(new ConsoleProgressCallback);
    }
    seeder.seed( mapNode->getMap() );

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int usage ( const std::string &  msg)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines